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-rosetta/blob/main/exercises/binary-search/test.om # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / exercises / binary-search / test.om` 199 lines ยท 4001 bytes Raw Blame History 1 note ---- test harness (appended after the solution by exercise.sh) ---- 2 text tok "ok " 3 text tnok "not ok " 4 text tsep " - " 5 text tnl "\n" 6 global tfails ulong 1 7 global tnum ulong 1 8 fn temit a view uchar * to void 9 o = ulong 0 10 while lt o len a bound 4096 11 k = write 1 a o sub len a o 12 if le k 0 13 exit 2 14 end 15 o = add o ulong k 16 end 17 end 18 fn temitu n ulong to void 19 d = new uchar 20 0 20 i = ulong 20 21 v = n 22 while true bound 20 23 i = sub i 1 24 put d i uchar add rem v 10 48 25 v = div v 10 26 if eq v 0 27 break 28 end 29 end 30 temit part d i sub 20 i 31 end 32 note one TAP-style line per case; main returns the number of failed cases 33 fn tcheck c bool what view uchar * to void 34 put tnum 0 add get tnum 0 1 35 if c 36 temit tok 37 else 38 temit tnok 39 put tfails 0 add get tfails 0 1 40 end 41 temitu get tnum 0 42 temit tsep 43 temit what 44 temit tnl 45 end 46 note cases: exercism/problem-specifications exercises/binary-search/canonical-data.json at 47 note commit `650bebeb39ad40439175288042aece982b0a90a9` (2026-10-19), MIT licence, 48 note https://github.com/exercism/problem-specifications 49 note 11 cases kept, 0 skipped 50 text c0 "find: finds a value in an array with one element" 51 text c1 "find: finds a value in the middle of an array" 52 text c2 "find: finds a value at the beginning of an array" 53 text c3 "find: finds a value at the end of an array" 54 text c4 "find: finds a value in an array of odd length" 55 text c5 "find: finds a value in an array of even length" 56 text c6 "find: identifies that a value is not included in the array" 57 text c7 "find: a value smaller than the array's smallest value is not found" 58 text c8 "find: a value larger than the array's largest value is not found" 59 text c9 "find: nothing is found in an empty array" 60 text c10 "find: nothing is found when the left and right bounds cross" 61 note canonical case `b55c24a9`-a98d-4379-a08c-`2adcf8ebeee8` 62 fn tc0 to bool 63 a0 = new ulong 1 0 64 put a0 0 6 65 ret eq find a0 6 0 66 end 67 note canonical case `73469346`-b0a0-4011-89bf-`989e443d503d` 68 fn tc1 to bool 69 a0 = new ulong 7 0 70 put a0 0 1 71 put a0 1 3 72 put a0 2 4 73 put a0 3 6 74 put a0 4 8 75 put a0 5 9 76 put a0 6 11 77 ret eq find a0 6 3 78 end 79 note canonical case `327bc482`-ab85-424e-a724-`fb4658e66ddb` 80 fn tc2 to bool 81 a0 = new ulong 7 0 82 put a0 0 1 83 put a0 1 3 84 put a0 2 4 85 put a0 3 6 86 put a0 4 8 87 put a0 5 9 88 put a0 6 11 89 ret eq find a0 1 0 90 end 91 note canonical case `f9f94b16`-fe5e-472c-85ea-`c513804c7d59` 92 fn tc3 to bool 93 a0 = new ulong 7 0 94 put a0 0 1 95 put a0 1 3 96 put a0 2 4 97 put a0 3 6 98 put a0 4 8 99 put a0 5 9 100 put a0 6 11 101 ret eq find a0 11 6 102 end 103 note canonical case `f0068905`-26e3-4342-856d-`ad153cadb338` 104 fn tc4 to bool 105 a0 = new ulong 13 0 106 put a0 0 1 107 put a0 1 3 108 put a0 2 5 109 put a0 3 8 110 put a0 4 13 111 put a0 5 21 112 put a0 6 34 113 put a0 7 55 114 put a0 8 89 115 put a0 9 144 116 put a0 10 233 117 put a0 11 377 118 put a0 12 634 119 ret eq find a0 144 9 120 end 121 note canonical case `fc316b12`-c8b3-4f5e-9e89-`532b3389de8c` 122 fn tc5 to bool 123 a0 = new ulong 12 0 124 put a0 0 1 125 put a0 1 3 126 put a0 2 5 127 put a0 3 8 128 put a0 4 13 129 put a0 5 21 130 put a0 6 34 131 put a0 7 55 132 put a0 8 89 133 put a0 9 144 134 put a0 10 233 135 put a0 11 377 136 ret eq find a0 21 5 137 end 138 note canonical case `da7db20a`-354f-49f7-a6a1-`650a54998aa6` 139 fn tc6 to bool 140 a0 = new ulong 7 0 141 put a0 0 1 142 put a0 1 3 143 put a0 2 4 144 put a0 3 6 145 put a0 4 8 146 put a0 5 9 147 put a0 6 11 148 ret eq find a0 7 -1 149 end 150 note canonical case `95d869ff`-3daf-4c79-b622-`6e805c675f97` 151 fn tc7 to bool 152 a0 = new ulong 7 0 153 put a0 0 1 154 put a0 1 3 155 put a0 2 4 156 put a0 3 6 157 put a0 4 8 158 put a0 5 9 159 put a0 6 11 160 ret eq find a0 0 -1 161 end 162 note canonical case `8b24ef45`-6e51-4a94-9eac-`c2bf38fdb0ba` 163 fn tc8 to bool 164 a0 = new ulong 7 0 165 put a0 0 1 166 put a0 1 3 167 put a0 2 4 168 put a0 3 6 169 put a0 4 8 170 put a0 5 9 171 put a0 6 11 172 ret eq find a0 13 -1 173 end 174 note canonical case `f439a0fa`-cf42-4262-8ad1-`64bf41ce566a` 175 fn tc9 to bool 176 a0 = new ulong 1 0 177 ret eq find part a0 0 0 1 -1 178 end 179 note canonical case `2c353967`-b56d-40b8-acff-`ce43115eed64` 180 fn tc10 to bool 181 a0 = new ulong 2 0 182 put a0 0 1 183 put a0 1 2 184 ret eq find a0 0 -1 185 end 186 fn main to int 187 tcheck tc0 c0 188 tcheck tc1 c1 189 tcheck tc2 c2 190 tcheck tc3 c3 191 tcheck tc4 c4 192 tcheck tc5 c5 193 tcheck tc6 c6 194 tcheck tc7 c7 195 tcheck tc8 c8 196 tcheck tc9 c9 197 tcheck tc10 c10 198 ret int get tfails 0 199 end