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/si/rosetta/exercises/all-your-base/test.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 / si / rosetta / exercises / all-your-base / test.om` 370 lines ยท 6979 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/all-your-base/canonical-data.json at 47 note commit `650bebeb39ad40439175288042aece982b0a90a9` (2026-10-19), MIT licence, 48 note https://github.com/exercism/problem-specifications 49 note 21 cases kept, 0 skipped 50 fn tleq a view long * b view long * to bool 51 if ne len a len b 52 ret false 53 end 54 for i ulong len a 55 if ne get a i get b i 56 ret false 57 end 58 end 59 ret true 60 end 61 text c0 "rebase: single bit one to decimal" 62 text c1 "rebase: binary to single decimal" 63 text c2 "rebase: single decimal to binary" 64 text c3 "rebase: binary to multiple decimal" 65 text c4 "rebase: decimal to binary" 66 text c5 "rebase: trinary to hexadecimal" 67 text c6 "rebase: hexadecimal to trinary" 68 text c7 "rebase: 15-bit integer" 69 text c8 "rebase: empty list" 70 text c9 "rebase: single zero" 71 text c10 "rebase: multiple zeros" 72 text c11 "rebase: leading zeros" 73 text c12 "rebase: input base is one" 74 text c13 "rebase: input base is zero" 75 text c14 "rebase: input base is negative" 76 text c15 "rebase: negative digit" 77 text c16 "rebase: invalid positive digit" 78 text c17 "rebase: output base is one" 79 text c18 "rebase: output base is zero" 80 text c19 "rebase: output base is negative" 81 text c20 "rebase: both bases are negative" 82 note canonical case `5ce422f9`-7a4b-4f44-ad29-`49c67cb32d2c` 83 fn tc0 to bool 84 a0 = new long 1 0 85 put a0 0 1 86 o = new long 256 0 87 n = rebase 2 a0 10 o 88 if lt n 0 89 ret false 90 end 91 a1 = new long 1 0 92 put a1 0 1 93 ret tleq part o 0 ulong n a1 94 end 95 note canonical case `0cc3fea8`-bb79-46ac-a2ab-`5a2c93051033` 96 fn tc1 to bool 97 a0 = new long 3 0 98 put a0 0 1 99 put a0 1 0 100 put a0 2 1 101 o = new long 256 0 102 n = rebase 2 a0 10 o 103 if lt n 0 104 ret false 105 end 106 a1 = new long 1 0 107 put a1 0 5 108 ret tleq part o 0 ulong n a1 109 end 110 note canonical case `f12db0f9`-0d3d-42c2-b3ba-`e38cb375a2b8` 111 fn tc2 to bool 112 a0 = new long 1 0 113 put a0 0 5 114 o = new long 256 0 115 n = rebase 10 a0 2 o 116 if lt n 0 117 ret false 118 end 119 a1 = new long 3 0 120 put a1 0 1 121 put a1 1 0 122 put a1 2 1 123 ret tleq part o 0 ulong n a1 124 end 125 note canonical case `2c45cf54`-6da3-4748-9733-`5a3c765d925b` 126 fn tc3 to bool 127 a0 = new long 6 0 128 put a0 0 1 129 put a0 1 0 130 put a0 2 1 131 put a0 3 0 132 put a0 4 1 133 put a0 5 0 134 o = new long 256 0 135 n = rebase 2 a0 10 o 136 if lt n 0 137 ret false 138 end 139 a1 = new long 2 0 140 put a1 0 4 141 put a1 1 2 142 ret tleq part o 0 ulong n a1 143 end 144 note canonical case `65ddb8b4`-8899-4fcc-8618-`181b2cf0002d` 145 fn tc4 to bool 146 a0 = new long 2 0 147 put a0 0 4 148 put a0 1 2 149 o = new long 256 0 150 n = rebase 10 a0 2 o 151 if lt n 0 152 ret false 153 end 154 a1 = new long 6 0 155 put a1 0 1 156 put a1 1 0 157 put a1 2 1 158 put a1 3 0 159 put a1 4 1 160 put a1 5 0 161 ret tleq part o 0 ulong n a1 162 end 163 note canonical case `8d418419`-02a7-4824-8b7a-`352d33c6987e` 164 fn tc5 to bool 165 a0 = new long 4 0 166 put a0 0 1 167 put a0 1 1 168 put a0 2 2 169 put a0 3 0 170 o = new long 256 0 171 n = rebase 3 a0 16 o 172 if lt n 0 173 ret false 174 end 175 a1 = new long 2 0 176 put a1 0 2 177 put a1 1 10 178 ret tleq part o 0 ulong n a1 179 end 180 note canonical case `d3901c80`-8190-41b9-bd86-`38d988efa956` 181 fn tc6 to bool 182 a0 = new long 2 0 183 put a0 0 2 184 put a0 1 10 185 o = new long 256 0 186 n = rebase 16 a0 3 o 187 if lt n 0 188 ret false 189 end 190 a1 = new long 4 0 191 put a1 0 1 192 put a1 1 1 193 put a1 2 2 194 put a1 3 0 195 ret tleq part o 0 ulong n a1 196 end 197 note canonical case `5d42f85e`-21ad-41bd-b9be-`a3e8e4258bbf` 198 fn tc7 to bool 199 a0 = new long 3 0 200 put a0 0 3 201 put a0 1 46 202 put a0 2 60 203 o = new long 256 0 204 n = rebase 97 a0 73 o 205 if lt n 0 206 ret false 207 end 208 a1 = new long 3 0 209 put a1 0 6 210 put a1 1 10 211 put a1 2 45 212 ret tleq part o 0 ulong n a1 213 end 214 note canonical case `d68788f7`-66dd-43f8-a543-`f15b6d233f83` 215 fn tc8 to bool 216 a0 = new long 1 0 217 o = new long 256 0 218 n = rebase 2 part a0 0 0 10 o 219 if lt n 0 220 ret false 221 end 222 a1 = new long 1 0 223 put a1 0 0 224 ret tleq part o 0 ulong n a1 225 end 226 note canonical case `5e27e8da`-5862-4c5f-b2a9-`26c0382b6be7` 227 fn tc9 to bool 228 a0 = new long 1 0 229 put a0 0 0 230 o = new long 256 0 231 n = rebase 10 a0 2 o 232 if lt n 0 233 ret false 234 end 235 a1 = new long 1 0 236 put a1 0 0 237 ret tleq part o 0 ulong n a1 238 end 239 note canonical case `2e1c2573`-77e4-4b9c-8517-`6c56c5bcfdf2` 240 fn tc10 to bool 241 a0 = new long 3 0 242 put a0 0 0 243 put a0 1 0 244 put a0 2 0 245 o = new long 256 0 246 n = rebase 10 a0 2 o 247 if lt n 0 248 ret false 249 end 250 a1 = new long 1 0 251 put a1 0 0 252 ret tleq part o 0 ulong n a1 253 end 254 note canonical case `3530cd9f`-8d6d-43f5-bc6e-`b30b1db9629b` 255 fn tc11 to bool 256 a0 = new long 3 0 257 put a0 0 0 258 put a0 1 6 259 put a0 2 0 260 o = new long 256 0 261 n = rebase 7 a0 10 o 262 if lt n 0 263 ret false 264 end 265 a1 = new long 2 0 266 put a1 0 4 267 put a1 1 2 268 ret tleq part o 0 ulong n a1 269 end 270 note canonical case `a6b476a1`-1901-4f2a-92c4-`4d91917ae023` 271 fn tc12 to bool 272 a0 = new long 1 0 273 put a0 0 0 274 o = new long 256 0 275 ret eq rebase 1 a0 10 o -1 276 end 277 note canonical case `e21a693a`-7a69-450b-b393-`27415c26a016` 278 fn tc13 to bool 279 a0 = new long 1 0 280 o = new long 256 0 281 ret eq rebase 0 part a0 0 0 10 o -1 282 end 283 note canonical case `54a23be5`-d99e-41cc-88e0-`a650ffe5fcc2` 284 fn tc14 to bool 285 a0 = new long 1 0 286 put a0 0 1 287 o = new long 256 0 288 ret eq rebase -2 a0 10 o -1 289 end 290 note canonical case `9eccf60c`-dcc9-407b-95d8-`c37b8be56bb6` 291 fn tc15 to bool 292 a0 = new long 6 0 293 put a0 0 1 294 put a0 1 -1 295 put a0 2 1 296 put a0 3 0 297 put a0 4 1 298 put a0 5 0 299 o = new long 256 0 300 ret eq rebase 2 a0 10 o -2 301 end 302 note canonical case `232fa4a5`-e761-4939-ba0c-`ed046cd0676a` 303 fn tc16 to bool 304 a0 = new long 6 0 305 put a0 0 1 306 put a0 1 2 307 put a0 2 1 308 put a0 3 0 309 put a0 4 1 310 put a0 5 0 311 o = new long 256 0 312 ret eq rebase 2 a0 10 o -2 313 end 314 note canonical case `14238f95`-45da-41dc-95ce-`18f860b30ad3` 315 fn tc17 to bool 316 a0 = new long 6 0 317 put a0 0 1 318 put a0 1 0 319 put a0 2 1 320 put a0 3 0 321 put a0 4 1 322 put a0 5 0 323 o = new long 256 0 324 ret eq rebase 2 a0 1 o -3 325 end 326 note canonical case `73dac367`-da5c-4a37-95fe-`c87fad0a4047` 327 fn tc18 to bool 328 a0 = new long 1 0 329 put a0 0 7 330 o = new long 256 0 331 ret eq rebase 10 a0 0 o -3 332 end 333 note canonical case `13f81f42`-ff53-4e24-89d9-`37603a48ebd9` 334 fn tc19 to bool 335 a0 = new long 1 0 336 put a0 0 1 337 o = new long 256 0 338 ret eq rebase 2 a0 -7 o -3 339 end 340 note canonical case `0e6c895d`-8a5d-4868-a345-`309d094cfe8d` 341 fn tc20 to bool 342 a0 = new long 1 0 343 put a0 0 1 344 o = new long 256 0 345 ret eq rebase -2 a0 -7 o -1 346 end 347 fn main to int 348 tcheck tc0 c0 349 tcheck tc1 c1 350 tcheck tc2 c2 351 tcheck tc3 c3 352 tcheck tc4 c4 353 tcheck tc5 c5 354 tcheck tc6 c6 355 tcheck tc7 c7 356 tcheck tc8 c8 357 tcheck tc9 c9 358 tcheck tc10 c10 359 tcheck tc11 c11 360 tcheck tc12 c12 361 tcheck tc13 c13 362 tcheck tc14 c14 363 tcheck tc15 c15 364 tcheck tc16 c16 365 tcheck tc17 c17 366 tcheck tc18 c18 367 tcheck tc19 c19 368 tcheck tc20 c20 369 ret int get tfails 0 370 end