omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / allergies / test.om
| 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/allergies/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 50 cases kept, 0 skipped |
| 50 | fn tbeq a view uchar * b view uchar * 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 s0 "eggs" |
| 62 | text c1 "allergicTo: testing for eggs allergy / not allergic to anything" |
| 63 | text s2 "eggs" |
| 64 | text c3 "allergicTo: testing for eggs allergy / allergic only to eggs" |
| 65 | text s4 "eggs" |
| 66 | text c5 "allergicTo: testing for eggs allergy / allergic to eggs and something else" |
| 67 | text s6 "eggs" |
| 68 | text c7 "allergicTo: testing for eggs allergy / allergic to something, but not eggs" |
| 69 | text s8 "eggs" |
| 70 | text c9 "allergicTo: testing for eggs allergy / allergic to everything" |
| 71 | text s10 "peanuts" |
| 72 | text c11 "allergicTo: testing for peanuts allergy / not allergic to anything" |
| 73 | text s12 "peanuts" |
| 74 | text c13 "allergicTo: testing for peanuts allergy / allergic only to peanuts" |
| 75 | text s14 "peanuts" |
| 76 | text c15 "allergicTo: testing for peanuts allergy / allergic to peanuts and something else" |
| 77 | text s16 "peanuts" |
| 78 | text c17 "allergicTo: testing for peanuts allergy / allergic to something, but not peanuts" |
| 79 | text s18 "peanuts" |
| 80 | text c19 "allergicTo: testing for peanuts allergy / allergic to everything" |
| 81 | text s20 "shellfish" |
| 82 | text c21 "allergicTo: testing for shellfish allergy / not allergic to anything" |
| 83 | text s22 "shellfish" |
| 84 | text c23 "allergicTo: testing for shellfish allergy / allergic only to shellfish" |
| 85 | text s24 "shellfish" |
| 86 | text c25 "allergicTo: testing for shellfish allergy / allergic to shellfish and something else" |
| 87 | text s26 "shellfish" |
| 88 | text c27 "allergicTo: testing for shellfish allergy / allergic to something, but not shellfish" |
| 89 | text s28 "shellfish" |
| 90 | text c29 "allergicTo: testing for shellfish allergy / allergic to everything" |
| 91 | text s30 "strawberries" |
| 92 | text c31 "allergicTo: testing for strawberries allergy / not allergic to anything" |
| 93 | text s32 "strawberries" |
| 94 | text c33 "allergicTo: testing for strawberries allergy / allergic only to strawberries" |
| 95 | text s34 "strawberries" |
| 96 | text c35 "allergicTo: testing for strawberries allergy / allergic to strawberries and something else" |
| 97 | text s36 "strawberries" |
| 98 | text c37 "allergicTo: testing for strawberries allergy / allergic to something, but not strawberries" |
| 99 | text s38 "strawberries" |
| 100 | text c39 "allergicTo: testing for strawberries allergy / allergic to everything" |
| 101 | text s40 "tomatoes" |
| 102 | text c41 "allergicTo: testing for tomatoes allergy / not allergic to anything" |
| 103 | text s42 "tomatoes" |
| 104 | text c43 "allergicTo: testing for tomatoes allergy / allergic only to tomatoes" |
| 105 | text s44 "tomatoes" |
| 106 | text c45 "allergicTo: testing for tomatoes allergy / allergic to tomatoes and something else" |
| 107 | text s46 "tomatoes" |
| 108 | text c47 "allergicTo: testing for tomatoes allergy / allergic to something, but not tomatoes" |
| 109 | text s48 "tomatoes" |
| 110 | text c49 "allergicTo: testing for tomatoes allergy / allergic to everything" |
| 111 | text s50 "chocolate" |
| 112 | text c51 "allergicTo: testing for chocolate allergy / not allergic to anything" |
| 113 | text s52 "chocolate" |
| 114 | text c53 "allergicTo: testing for chocolate allergy / allergic only to chocolate" |
| 115 | text s54 "chocolate" |
| 116 | text c55 "allergicTo: testing for chocolate allergy / allergic to chocolate and something else" |
| 117 | text s56 "chocolate" |
| 118 | text c57 "allergicTo: testing for chocolate allergy / allergic to something, but not chocolate" |
| 119 | text s58 "chocolate" |
| 120 | text c59 "allergicTo: testing for chocolate allergy / allergic to everything" |
| 121 | text s60 "pollen" |
| 122 | text c61 "allergicTo: testing for pollen allergy / not allergic to anything" |
| 123 | text s62 "pollen" |
| 124 | text c63 "allergicTo: testing for pollen allergy / allergic only to pollen" |
| 125 | text s64 "pollen" |
| 126 | text c65 "allergicTo: testing for pollen allergy / allergic to pollen and something else" |
| 127 | text s66 "pollen" |
| 128 | text c67 "allergicTo: testing for pollen allergy / allergic to something, but not pollen" |
| 129 | text s68 "pollen" |
| 130 | text c69 "allergicTo: testing for pollen allergy / allergic to everything" |
| 131 | text s70 "cats" |
| 132 | text c71 "allergicTo: testing for cats allergy / not allergic to anything" |
| 133 | text s72 "cats" |
| 134 | text c73 "allergicTo: testing for cats allergy / allergic only to cats" |
| 135 | text s74 "cats" |
| 136 | text c75 "allergicTo: testing for cats allergy / allergic to cats and something else" |
| 137 | text s76 "cats" |
| 138 | text c77 "allergicTo: testing for cats allergy / allergic to something, but not cats" |
| 139 | text s78 "cats" |
| 140 | text c79 "allergicTo: testing for cats allergy / allergic to everything" |
| 141 | text c80 "list: list when: / no allergies" |
| 142 | text e81 "eggs" |
| 143 | text c82 "list: list when: / just eggs" |
| 144 | text e83 "peanuts" |
| 145 | text c84 "list: list when: / just peanuts" |
| 146 | text e85 "strawberries" |
| 147 | text c86 "list: list when: / just strawberries" |
| 148 | text e87 "eggs,peanuts" |
| 149 | text c88 "list: list when: / eggs and peanuts" |
| 150 | text e89 "eggs,shellfish" |
| 151 | text c90 "list: list when: / more than eggs but not peanuts" |
| 152 | text e91 "strawberries,tomatoes,chocolate,pollen,cats" |
| 153 | text c92 "list: list when: / lots of stuff" |
| 154 | text e93 "eggs,peanuts,shellfish,strawberries,tomatoes,chocolate,pollen,cats" |
| 155 | text c94 "list: list when: / everything" |
| 156 | text e95 "eggs,shellfish,strawberries,tomatoes,chocolate,pollen,cats" |
| 157 | text c96 "list: list when: / no allergen score parts" |
| 158 | text e97 "eggs" |
| 159 | text c98 "list: list when: / no allergen score parts without highest valid score" |
| 160 | note canonical case 17fc7296-2440-4ac4-ad7b-d07c321bc5a0 |
| 161 | fn tc0 to bool |
| 162 | ret eq allergicto s0 0 false |
| 163 | end |
| 164 | note canonical case 07ced27b-1da5-4c2e-8ae2-cb2791437546 |
| 165 | fn tc1 to bool |
| 166 | ret eq allergicto s2 1 true |
| 167 | end |
| 168 | note canonical case 5035b954-b6fa-4b9b-a487-dae69d8c5f96 |
| 169 | fn tc2 to bool |
| 170 | ret eq allergicto s4 3 true |
| 171 | end |
| 172 | note canonical case 64a6a83a-5723-4b5b-a896-663307403310 |
| 173 | fn tc3 to bool |
| 174 | ret eq allergicto s6 2 false |
| 175 | end |
| 176 | note canonical case 90c8f484-456b-41c4-82ba-2d08d93231c6 |
| 177 | fn tc4 to bool |
| 178 | ret eq allergicto s8 255 true |
| 179 | end |
| 180 | note canonical case d266a59a-fccc-413b-ac53-d57cb1f0db9d |
| 181 | fn tc5 to bool |
| 182 | ret eq allergicto s10 0 false |
| 183 | end |
| 184 | note canonical case ea210a98-860d-46b2-a5bf-50d8995b3f2a |
| 185 | fn tc6 to bool |
| 186 | ret eq allergicto s12 2 true |
| 187 | end |
| 188 | note canonical case eac69ae9-8d14-4291-ac4b-7fd2c73d3a5b |
| 189 | fn tc7 to bool |
| 190 | ret eq allergicto s14 7 true |
| 191 | end |
| 192 | note canonical case 9152058c-ce39-4b16-9b1d-283ec6d25085 |
| 193 | fn tc8 to bool |
| 194 | ret eq allergicto s16 5 false |
| 195 | end |
| 196 | note canonical case d2d71fd8-63d5-40f9-a627-fbdaf88caeab |
| 197 | fn tc9 to bool |
| 198 | ret eq allergicto s18 255 true |
| 199 | end |
| 200 | note canonical case b948b0a1-cbf7-4b28-a244-73ff56687c80 |
| 201 | fn tc10 to bool |
| 202 | ret eq allergicto s20 0 false |
| 203 | end |
| 204 | note canonical case 9ce9a6f3-53e9-4923-85e0-73019047c567 |
| 205 | fn tc11 to bool |
| 206 | ret eq allergicto s22 4 true |
| 207 | end |
| 208 | note canonical case b272fca5-57ba-4b00-bd0c-43a737ab2131 |
| 209 | fn tc12 to bool |
| 210 | ret eq allergicto s24 14 true |
| 211 | end |
| 212 | note canonical case 21ef8e17-c227-494e-8e78-470a1c59c3d8 |
| 213 | fn tc13 to bool |
| 214 | ret eq allergicto s26 10 false |
| 215 | end |
| 216 | note canonical case cc789c19-2b5e-4c67-b146-625dc8cfa34e |
| 217 | fn tc14 to bool |
| 218 | ret eq allergicto s28 255 true |
| 219 | end |
| 220 | note canonical case 651bde0a-2a74-46c4-ab55-02a0906ca2f5 |
| 221 | fn tc15 to bool |
| 222 | ret eq allergicto s30 0 false |
| 223 | end |
| 224 | note canonical case b649a750-9703-4f5f-b7f7-91da2c160ece |
| 225 | fn tc16 to bool |
| 226 | ret eq allergicto s32 8 true |
| 227 | end |
| 228 | note canonical case 50f5f8f3-3bac-47e6-8dba-2d94470a4bc6 |
| 229 | fn tc17 to bool |
| 230 | ret eq allergicto s34 28 true |
| 231 | end |
| 232 | note canonical case 23dd6952-88c9-48d7-a7d5-5d0343deb18d |
| 233 | fn tc18 to bool |
| 234 | ret eq allergicto s36 20 false |
| 235 | end |
| 236 | note canonical case 74afaae2-13b6-43a2-837a-286cd42e7d7e |
| 237 | fn tc19 to bool |
| 238 | ret eq allergicto s38 255 true |
| 239 | end |
| 240 | note canonical case c49a91ef-6252-415e-907e-a9d26ef61723 |
| 241 | fn tc20 to bool |
| 242 | ret eq allergicto s40 0 false |
| 243 | end |
| 244 | note canonical case b69c5131-b7d0-41ad-a32c-e1b2cc632df8 |
| 245 | fn tc21 to bool |
| 246 | ret eq allergicto s42 16 true |
| 247 | end |
| 248 | note canonical case 1ca50eb1-f042-4ccf-9050-341521b929ec |
| 249 | fn tc22 to bool |
| 250 | ret eq allergicto s44 56 true |
| 251 | end |
| 252 | note canonical case e9846baa-456b-4eff-8025-034b9f77bd8e |
| 253 | fn tc23 to bool |
| 254 | ret eq allergicto s46 40 false |
| 255 | end |
| 256 | note canonical case b2414f01-f3ad-4965-8391-e65f54dad35f |
| 257 | fn tc24 to bool |
| 258 | ret eq allergicto s48 255 true |
| 259 | end |
| 260 | note canonical case 978467ab-bda4-49f7-b004-1d011ead947c |
| 261 | fn tc25 to bool |
| 262 | ret eq allergicto s50 0 false |
| 263 | end |
| 264 | note canonical case 59cf4e49-06ea-4139-a2c1-d7aad28f8cbc |
| 265 | fn tc26 to bool |
| 266 | ret eq allergicto s52 32 true |
| 267 | end |
| 268 | note canonical case b0a7c07b-2db7-4f73-a180-565e07040ef1 |
| 269 | fn tc27 to bool |
| 270 | ret eq allergicto s54 112 true |
| 271 | end |
| 272 | note canonical case f5506893-f1ae-482a-b516-7532ba5ca9d2 |
| 273 | fn tc28 to bool |
| 274 | ret eq allergicto s56 80 false |
| 275 | end |
| 276 | note canonical case 02debb3d-d7e2-4376-a26b-3c974b6595c6 |
| 277 | fn tc29 to bool |
| 278 | ret eq allergicto s58 255 true |
| 279 | end |
| 280 | note canonical case 17f4a42b-c91e-41b8-8a76-4797886c2d96 |
| 281 | fn tc30 to bool |
| 282 | ret eq allergicto s60 0 false |
| 283 | end |
| 284 | note canonical case 7696eba7-1837-4488-882a-14b7b4e3e399 |
| 285 | fn tc31 to bool |
| 286 | ret eq allergicto s62 64 true |
| 287 | end |
| 288 | note canonical case 9a49aec5-fa1f-405d-889e-4dfc420db2b6 |
| 289 | fn tc32 to bool |
| 290 | ret eq allergicto s64 224 true |
| 291 | end |
| 292 | note canonical case 3cb8e79f-d108-4712-b620-aa146b1954a9 |
| 293 | fn tc33 to bool |
| 294 | ret eq allergicto s66 160 false |
| 295 | end |
| 296 | note canonical case 1dc3fe57-7c68-4043-9d51-5457128744b2 |
| 297 | fn tc34 to bool |
| 298 | ret eq allergicto s68 255 true |
| 299 | end |
| 300 | note canonical case d3f523d6-3d50-419b-a222-d4dfd62ce314 |
| 301 | fn tc35 to bool |
| 302 | ret eq allergicto s70 0 false |
| 303 | end |
| 304 | note canonical case eba541c3-c886-42d3-baef-c048cb7fcd8f |
| 305 | fn tc36 to bool |
| 306 | ret eq allergicto s72 128 true |
| 307 | end |
| 308 | note canonical case ba718376-26e0-40b7-bbbe-060287637ea5 |
| 309 | fn tc37 to bool |
| 310 | ret eq allergicto s74 192 true |
| 311 | end |
| 312 | note canonical case 3c6dbf4a-5277-436f-8b88-15a206f2d6c4 |
| 313 | fn tc38 to bool |
| 314 | ret eq allergicto s76 64 false |
| 315 | end |
| 316 | note canonical case 1faabb05-2b98-4995-9046-d83e4a48a7c1 |
| 317 | fn tc39 to bool |
| 318 | ret eq allergicto s78 255 true |
| 319 | end |
| 320 | note canonical case f9c1b8e7-7dc5-4887-aa93-cebdcc29dd8f |
| 321 | fn tc40 to bool |
| 322 | o = new uchar 1024 0 |
| 323 | n = list 0 o |
| 324 | ret eq n 0 |
| 325 | end |
| 326 | note canonical case 9e1a4364-09a6-4d94-990f-541a94a4c1e8 |
| 327 | fn tc41 to bool |
| 328 | o = new uchar 1024 0 |
| 329 | n = list 1 o |
| 330 | ret tbeq part o 0 n e81 |
| 331 | end |
| 332 | note canonical case 8851c973-805e-4283-9e01-d0c0da0e4695 |
| 333 | fn tc42 to bool |
| 334 | o = new uchar 1024 0 |
| 335 | n = list 2 o |
| 336 | ret tbeq part o 0 n e83 |
| 337 | end |
| 338 | note canonical case 2c8943cb-005e-435f-ae11-3e8fb558ea98 |
| 339 | fn tc43 to bool |
| 340 | o = new uchar 1024 0 |
| 341 | n = list 8 o |
| 342 | ret tbeq part o 0 n e85 |
| 343 | end |
| 344 | note canonical case 6fa95d26-044c-48a9-8a7b-9ee46ec32c5c |
| 345 | fn tc44 to bool |
| 346 | o = new uchar 1024 0 |
| 347 | n = list 3 o |
| 348 | ret tbeq part o 0 n e87 |
| 349 | end |
| 350 | note canonical case 19890e22-f63f-4c5c-a9fb-fb6eacddfe8e |
| 351 | fn tc45 to bool |
| 352 | o = new uchar 1024 0 |
| 353 | n = list 5 o |
| 354 | ret tbeq part o 0 n e89 |
| 355 | end |
| 356 | note canonical case 4b68f470-067c-44e4-889f-c9fe28917d2f |
| 357 | fn tc46 to bool |
| 358 | o = new uchar 1024 0 |
| 359 | n = list 248 o |
| 360 | ret tbeq part o 0 n e91 |
| 361 | end |
| 362 | note canonical case 0881b7c5-9efa-4530-91bd-68370d054bc7 |
| 363 | fn tc47 to bool |
| 364 | o = new uchar 1024 0 |
| 365 | n = list 255 o |
| 366 | ret tbeq part o 0 n e93 |
| 367 | end |
| 368 | note canonical case 12ce86de-b347-42a0-ab7c-2e0570f0c65b |
| 369 | fn tc48 to bool |
| 370 | o = new uchar 1024 0 |
| 371 | n = list 509 o |
| 372 | ret tbeq part o 0 n e95 |
| 373 | end |
| 374 | note canonical case 93c2df3e-4f55-4fed-8116-7513092819cd |
| 375 | fn tc49 to bool |
| 376 | o = new uchar 1024 0 |
| 377 | n = list 257 o |
| 378 | ret tbeq part o 0 n e97 |
| 379 | end |
| 380 | fn main to int |
| 381 | tcheck tc0 c1 |
| 382 | tcheck tc1 c3 |
| 383 | tcheck tc2 c5 |
| 384 | tcheck tc3 c7 |
| 385 | tcheck tc4 c9 |
| 386 | tcheck tc5 c11 |
| 387 | tcheck tc6 c13 |
| 388 | tcheck tc7 c15 |
| 389 | tcheck tc8 c17 |
| 390 | tcheck tc9 c19 |
| 391 | tcheck tc10 c21 |
| 392 | tcheck tc11 c23 |
| 393 | tcheck tc12 c25 |
| 394 | tcheck tc13 c27 |
| 395 | tcheck tc14 c29 |
| 396 | tcheck tc15 c31 |
| 397 | tcheck tc16 c33 |
| 398 | tcheck tc17 c35 |
| 399 | tcheck tc18 c37 |
| 400 | tcheck tc19 c39 |
| 401 | tcheck tc20 c41 |
| 402 | tcheck tc21 c43 |
| 403 | tcheck tc22 c45 |
| 404 | tcheck tc23 c47 |
| 405 | tcheck tc24 c49 |
| 406 | tcheck tc25 c51 |
| 407 | tcheck tc26 c53 |
| 408 | tcheck tc27 c55 |
| 409 | tcheck tc28 c57 |
| 410 | tcheck tc29 c59 |
| 411 | tcheck tc30 c61 |
| 412 | tcheck tc31 c63 |
| 413 | tcheck tc32 c65 |
| 414 | tcheck tc33 c67 |
| 415 | tcheck tc34 c69 |
| 416 | tcheck tc35 c71 |
| 417 | tcheck tc36 c73 |
| 418 | tcheck tc37 c75 |
| 419 | tcheck tc38 c77 |
| 420 | tcheck tc39 c79 |
| 421 | tcheck tc40 c80 |
| 422 | tcheck tc41 c82 |
| 423 | tcheck tc42 c84 |
| 424 | tcheck tc43 c86 |
| 425 | tcheck tc44 c88 |
| 426 | tcheck tc45 c90 |
| 427 | tcheck tc46 c92 |
| 428 | tcheck tc47 c94 |
| 429 | tcheck tc48 c96 |
| 430 | tcheck tc49 c98 |
| 431 | ret int get tfails 0 |
| 432 | end |