omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / bob / 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/bob/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 26 cases kept, 0 skipped, 1 superseded (reimplemented) cases omitted |
| 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 "Does this cryogenic chamber make me look fat?" |
| 62 | text e1 "Sure." |
| 63 | text c2 "response: asking a question" |
| 64 | text s3 "WATCH OUT!" |
| 65 | text e4 "Whoa, chill out!" |
| 66 | text c5 "response: shouting" |
| 67 | text s6 "WHAT'S GOING ON?" |
| 68 | text e7 "Calm down, I know what I'm doing!" |
| 69 | text c8 "response: forceful question" |
| 70 | text z9 "z" |
| 71 | text e10 "Fine. Be that way!" |
| 72 | text c11 "response: silence" |
| 73 | text s12 "Tom-ay-to, tom-aaaah-to." |
| 74 | text e13 "Whatever." |
| 75 | text c14 "response: stating something" |
| 76 | text s15 "You are, what, like 15?" |
| 77 | text e16 "Sure." |
| 78 | text c17 "response: asking a numeric question" |
| 79 | text s18 "fffbbcbeab?" |
| 80 | text e19 "Sure." |
| 81 | text c20 "response: asking gibberish" |
| 82 | text s21 "4?" |
| 83 | text e22 "Sure." |
| 84 | text c23 "response: question with no letters" |
| 85 | text s24 ":) ?" |
| 86 | text e25 "Sure." |
| 87 | text c26 "response: non-letters with question" |
| 88 | text s27 "Wait! Hang on. Are you going to be OK?" |
| 89 | text e28 "Sure." |
| 90 | text c29 "response: prattling on" |
| 91 | text s30 "Okay if like my spacebar quite a bit? " |
| 92 | text e31 "Sure." |
| 93 | text c32 "response: ending with whitespace" |
| 94 | text s33 "\nDoes this cryogenic chamber make\n me look fat?" |
| 95 | text e34 "Sure." |
| 96 | text c35 "response: multiple line question" |
| 97 | text s36 "FCECDFCAAB" |
| 98 | text e37 "Whoa, chill out!" |
| 99 | text c38 "response: shouting gibberish" |
| 100 | text s39 "DO LIONS EAT PEOPLE? AHHHHH." |
| 101 | text e40 "Whoa, chill out!" |
| 102 | text c41 "response: shouting a statement containing a question mark" |
| 103 | text s42 "1, 2, 3 GO!" |
| 104 | text e43 "Whoa, chill out!" |
| 105 | text c44 "response: shouting numbers" |
| 106 | text s45 "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!" |
| 107 | text e46 "Whoa, chill out!" |
| 108 | text c47 "response: shouting with special characters" |
| 109 | text s48 "I HATE THE DENTIST" |
| 110 | text e49 "Whoa, chill out!" |
| 111 | text c50 "response: shouting with no exclamation mark" |
| 112 | text s51 " " |
| 113 | text e52 "Fine. Be that way!" |
| 114 | text c53 "response: prolonged silence" |
| 115 | text s54 "\t\t\t\t\t\t\t\t\t\t" |
| 116 | text e55 "Fine. Be that way!" |
| 117 | text c56 "response: alternate silence" |
| 118 | text e57 "Fine. Be that way!" |
| 119 | text c58 "response: other whitespace" |
| 120 | text s59 "Hi there!" |
| 121 | text e60 "Whatever." |
| 122 | text c61 "response: talking forcefully" |
| 123 | text s62 "It's OK if you don't want to go work for NASA." |
| 124 | text e63 "Whatever." |
| 125 | text c64 "response: using acronyms in regular speech" |
| 126 | text s65 "1, 2, 3" |
| 127 | text e66 "Whatever." |
| 128 | text c67 "response: no letters" |
| 129 | text s68 "Ending with ? means a question." |
| 130 | text e69 "Whatever." |
| 131 | text c70 "response: statement containing question mark" |
| 132 | text s71 " hmmmmmmm..." |
| 133 | text e72 "Whatever." |
| 134 | text c73 "response: starting with whitespace" |
| 135 | text s74 "This is a statement ending with whitespace " |
| 136 | text e75 "Whatever." |
| 137 | text c76 "response: non-question ending with whitespace" |
| 138 | note canonical case 8a2e771d-d6f1-4e3f-b6c6-b41495556e37 |
| 139 | fn tc0 to bool |
| 140 | o = new uchar 1024 0 |
| 141 | n = response s0 o |
| 142 | ret tbeq part o 0 n e1 |
| 143 | end |
| 144 | note canonical case 73a966dc-8017-47d6-bb32-cf07d1a5fcd9 |
| 145 | fn tc1 to bool |
| 146 | o = new uchar 1024 0 |
| 147 | n = response s3 o |
| 148 | ret tbeq part o 0 n e4 |
| 149 | end |
| 150 | note canonical case a5193c61-4a92-4f68-93e2-f554eb385ec6 |
| 151 | fn tc2 to bool |
| 152 | o = new uchar 1024 0 |
| 153 | n = response s6 o |
| 154 | ret tbeq part o 0 n e7 |
| 155 | end |
| 156 | note canonical case bc39f7c6-f543-41be-9a43-fd1c2f753fc0 |
| 157 | fn tc3 to bool |
| 158 | o = new uchar 1024 0 |
| 159 | n = response part z9 0 0 o |
| 160 | ret tbeq part o 0 n e10 |
| 161 | end |
| 162 | note canonical case e162fead-606f-437a-a166-d051915cea8e |
| 163 | fn tc4 to bool |
| 164 | o = new uchar 1024 0 |
| 165 | n = response s12 o |
| 166 | ret tbeq part o 0 n e13 |
| 167 | end |
| 168 | note canonical case 81080c62-4e4d-4066-b30a-48d8d76920d9 |
| 169 | fn tc5 to bool |
| 170 | o = new uchar 1024 0 |
| 171 | n = response s15 o |
| 172 | ret tbeq part o 0 n e16 |
| 173 | end |
| 174 | note canonical case 2a02716d-685b-4e2e-a804-2adaf281c01e |
| 175 | fn tc6 to bool |
| 176 | o = new uchar 1024 0 |
| 177 | n = response s18 o |
| 178 | ret tbeq part o 0 n e19 |
| 179 | end |
| 180 | note canonical case bb0011c5-cd52-4a5b-8bfb-a87b6283b0e2 |
| 181 | fn tc7 to bool |
| 182 | o = new uchar 1024 0 |
| 183 | n = response s21 o |
| 184 | ret tbeq part o 0 n e22 |
| 185 | end |
| 186 | note canonical case 9bfc677d-ea3a-45f2-be44-35bc8fa3753e |
| 187 | fn tc8 to bool |
| 188 | o = new uchar 1024 0 |
| 189 | n = response s24 o |
| 190 | ret tbeq part o 0 n e25 |
| 191 | end |
| 192 | note canonical case 8608c508-f7de-4b17-985b-811878b3cf45 |
| 193 | fn tc9 to bool |
| 194 | o = new uchar 1024 0 |
| 195 | n = response s27 o |
| 196 | ret tbeq part o 0 n e28 |
| 197 | end |
| 198 | note canonical case 05b304d6-f83b-46e7-81e0-4cd3ca647900 |
| 199 | fn tc10 to bool |
| 200 | o = new uchar 1024 0 |
| 201 | n = response s30 o |
| 202 | ret tbeq part o 0 n e31 |
| 203 | end |
| 204 | note canonical case 2c7278ac-f955-4eb4-bf8f-e33eb4116a15 |
| 205 | fn tc11 to bool |
| 206 | o = new uchar 1024 0 |
| 207 | n = response s33 o |
| 208 | ret tbeq part o 0 n e34 |
| 209 | end |
| 210 | note canonical case d6c98afd-df35-4806-b55e-2c457c3ab748 |
| 211 | fn tc12 to bool |
| 212 | o = new uchar 1024 0 |
| 213 | n = response s36 o |
| 214 | ret tbeq part o 0 n e37 |
| 215 | end |
| 216 | note canonical case 3c954328-86fb-4c71-8961-e18d6a5e2517 |
| 217 | fn tc13 to bool |
| 218 | o = new uchar 1024 0 |
| 219 | n = response s39 o |
| 220 | ret tbeq part o 0 n e40 |
| 221 | end |
| 222 | note canonical case a20e0c54-2224-4dde-8b10-bd2cdd4f61bc |
| 223 | fn tc14 to bool |
| 224 | o = new uchar 1024 0 |
| 225 | n = response s42 o |
| 226 | ret tbeq part o 0 n e43 |
| 227 | end |
| 228 | note canonical case 496143c8-1c31-4c01-8a08-88427af85c66 |
| 229 | fn tc15 to bool |
| 230 | o = new uchar 1024 0 |
| 231 | n = response s45 o |
| 232 | ret tbeq part o 0 n e46 |
| 233 | end |
| 234 | note canonical case e6793c1c-43bd-4b8d-bc11-499aea73925f |
| 235 | fn tc16 to bool |
| 236 | o = new uchar 1024 0 |
| 237 | n = response s48 o |
| 238 | ret tbeq part o 0 n e49 |
| 239 | end |
| 240 | note canonical case d6c47565-372b-4b09-b1dd-c40552b8378b |
| 241 | fn tc17 to bool |
| 242 | o = new uchar 1024 0 |
| 243 | n = response s51 o |
| 244 | ret tbeq part o 0 n e52 |
| 245 | end |
| 246 | note canonical case 4428f28d-4100-4d85-a902-e5a78cb0ecd3 |
| 247 | fn tc18 to bool |
| 248 | o = new uchar 1024 0 |
| 249 | n = response s54 o |
| 250 | ret tbeq part o 0 n e55 |
| 251 | end |
| 252 | note canonical case 72bd5ad3-9b2f-4931-a988-dce1f5771de2 |
| 253 | fn tc19 to bool |
| 254 | a0 = new uchar 4 0 |
| 255 | put a0 0 10 |
| 256 | put a0 1 13 |
| 257 | put a0 2 32 |
| 258 | put a0 3 9 |
| 259 | o = new uchar 1024 0 |
| 260 | n = response a0 o |
| 261 | ret tbeq part o 0 n e57 |
| 262 | end |
| 263 | note canonical case c02f9179-ab16-4aa7-a8dc-940145c385f7 |
| 264 | fn tc20 to bool |
| 265 | o = new uchar 1024 0 |
| 266 | n = response s59 o |
| 267 | ret tbeq part o 0 n e60 |
| 268 | end |
| 269 | note canonical case 153c0e25-9bb5-4ec5-966e-598463658bcd |
| 270 | fn tc21 to bool |
| 271 | o = new uchar 1024 0 |
| 272 | n = response s62 o |
| 273 | ret tbeq part o 0 n e63 |
| 274 | end |
| 275 | note canonical case f7bc4b92-bdff-421e-a238-ae97f230ccac |
| 276 | fn tc22 to bool |
| 277 | o = new uchar 1024 0 |
| 278 | n = response s65 o |
| 279 | ret tbeq part o 0 n e66 |
| 280 | end |
| 281 | note canonical case aa8097cc-c548-4951-8856-14a404dd236a |
| 282 | fn tc23 to bool |
| 283 | o = new uchar 1024 0 |
| 284 | n = response s68 o |
| 285 | ret tbeq part o 0 n e69 |
| 286 | end |
| 287 | note canonical case 5371ef75-d9ea-4103-bcfa-2da973ddec1b |
| 288 | fn tc24 to bool |
| 289 | o = new uchar 1024 0 |
| 290 | n = response s71 o |
| 291 | ret tbeq part o 0 n e72 |
| 292 | end |
| 293 | note canonical case 12983553-8601-46a8-92fa-fcaa3bc4a2a0 |
| 294 | fn tc25 to bool |
| 295 | o = new uchar 1024 0 |
| 296 | n = response s74 o |
| 297 | ret tbeq part o 0 n e75 |
| 298 | end |
| 299 | fn main to int |
| 300 | tcheck tc0 c2 |
| 301 | tcheck tc1 c5 |
| 302 | tcheck tc2 c8 |
| 303 | tcheck tc3 c11 |
| 304 | tcheck tc4 c14 |
| 305 | tcheck tc5 c17 |
| 306 | tcheck tc6 c20 |
| 307 | tcheck tc7 c23 |
| 308 | tcheck tc8 c26 |
| 309 | tcheck tc9 c29 |
| 310 | tcheck tc10 c32 |
| 311 | tcheck tc11 c35 |
| 312 | tcheck tc12 c38 |
| 313 | tcheck tc13 c41 |
| 314 | tcheck tc14 c44 |
| 315 | tcheck tc15 c47 |
| 316 | tcheck tc16 c50 |
| 317 | tcheck tc17 c53 |
| 318 | tcheck tc18 c56 |
| 319 | tcheck tc19 c58 |
| 320 | tcheck tc20 c61 |
| 321 | tcheck tc21 c64 |
| 322 | tcheck tc22 c67 |
| 323 | tcheck tc23 c70 |
| 324 | tcheck tc24 c73 |
| 325 | tcheck tc25 c76 |
| 326 | ret int get tfails 0 |
| 327 | end |