Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/native/control/tests/delegate.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / native / control / tests / delegate.om` 198 lines ยท 3397 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 global checks ulong 1 3 global fails ulong 1 4 global report uchar 64 5 text title "delegate checks=" 6 fn check got ulong want ulong to void 7 put checks 0 add get checks 0 1 8 if ne got want 9 put fails 0 add get fails 0 1 10 end 11 end 12 fn parent p edit ulong 24 to void 13 for i ulong 24 14 put p i 0 15 end 16 put p 0 1 17 put p 1 7 18 put p 2 1024 19 put p 3 200 20 put p 4 100 21 put p 5 4 22 for i ulong 16 23 put p add i 8 add i 100 24 end 25 end 26 fn child c edit ulong 24 to void 27 parent c 28 put c 1 3 29 put c 2 512 30 put c 3 100 31 put c 4 90 32 put c 5 3 33 put c 16 200 34 put c 20 300 35 end 36 fn summary to int 37 for i ulong len title 38 put report i get title i 39 end 40 n = get checks 0 41 at = len title 42 put report at uchar add 48 div n 100 43 put report add at 1 uchar add 48 rem div n 10 10 44 put report add at 2 uchar add 48 rem n 10 45 put report add at 3 32 46 put report add at 4 uchar add 48 div get fails 0 100 47 put report add at 5 uchar add 48 rem div get fails 0 10 10 48 put report add at 6 uchar add 48 rem get fails 0 10 49 put report add at 7 10 50 w = write 1 report 0 add at 8 51 if ne w long add at 8 52 ret 2 53 end 54 if ne get fails 0 0 55 ret 1 56 end 57 ret 0 58 end 59 fn main to int 60 p = new ulong 24 0 61 c = new ulong 24 0 62 parent p 63 child c 64 check capchild p c 50 0 65 put c 1 8 66 check capchild p c 50 66 67 child c 68 put c 2 1025 69 check capchild p c 50 67 70 child c 71 put c 3 201 72 check capchild p c 50 68 73 child c 74 put c 4 101 75 check capchild p c 50 69 76 child c 77 put c 5 4 78 check capchild p c 50 73 79 child c 80 put p 5 0 81 check capchild p c 50 72 82 parent p 83 child c 84 put c 4 50 85 check capchild p c 50 65 86 child c 87 put c 4 100 88 check capchild p c 50 0 89 note Rights are a bit subset: a numerically smaller child is still refused if it has a bit the parent lacks. 90 child c 91 put p 1 5 92 put c 1 2 93 check capchild p c 50 66 94 put p 1 6 95 put c 1 1 96 check capchild p c 50 66 97 put p 1 `9223372036854775808` 98 check capchild p c 50 66 99 parent p 100 child c 101 check capchild p c 100 64 102 child c 103 put c 1 0 104 put c 2 0 105 put c 3 0 106 put c 5 0 107 check capchild p c 50 0 108 put p 1 0 109 put p 2 0 110 put p 3 0 111 check capchild p c 50 0 112 put c 1 1 113 check capchild p c 50 66 114 115 for i ulong 8 116 parent p 117 child c 118 put c add i 8 add get c add i 8 1 119 check capchild p c 50 add 70 div i 4 120 end 121 parent p 122 child c 123 for i ulong 4 124 put c add i 16 get p add i 16 125 end 126 check capchild p c 50 74 127 child c 128 for i ulong 4 129 put c add i 20 get p add i 20 130 end 131 check capchild p c 50 75 132 for group ulong 4 133 parent p 134 child c 135 for j ulong 4 136 put p add 8 add mul group 4 j 0 137 end 138 check capchild p c 50 62 139 parent p 140 for j ulong 4 141 put c add 8 add mul group 4 j 0 142 end 143 check capchild p c 50 62 144 end 145 146 parent p 147 child c 148 put p 0 2 149 check capchild p c 50 61 150 parent p 151 put c 0 2 152 check capchild p c 50 61 153 child c 154 put c 1 512 155 check capchild p c 50 66 156 child c 157 put c 6 1 158 check capchild p c 50 62 159 child c 160 put c 7 1 161 check capchild p c 50 62 162 child c 163 put c 5 `18446744073709551615` 164 check capchild p c 50 62 165 child c 166 put p 5 65 167 check capchild p c 50 62 168 parent p 169 child c 170 put p 5 1 171 put c 5 0 172 check capchild p c 50 0 173 put p 2 `18446744073709551615` 174 put c 2 `18446744073709551615` 175 check capchild p c 50 0 176 put p 2 `18446744073709551614` 177 check capchild p c 50 67 178 parent p 179 child c 180 put p 1 `9223372036854775808` 181 put c 1 `9223372036854775808` 182 check capchild p c 50 0 183 put c 1 `9223372036854775809` 184 check capchild p c 50 66 185 186 note Exhaust all subsets of the small rights profile, not only one happy case. 187 for rights ulong 32 188 parent p 189 child c 190 put c 1 rights 191 want = ulong 66 192 if lt rights 8 193 want = 0 194 end 195 check capchild p c 50 want 196 end 197 ret summary 198 end