omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / acronym / 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/acronym/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 9 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 "Portable Network Graphics" |
| 62 | text e1 "PNG" |
| 63 | text c2 "abbreviate: basic" |
| 64 | text s3 "Ruby on Rails" |
| 65 | text e4 "ROR" |
| 66 | text c5 "abbreviate: lowercase words" |
| 67 | text s6 "First In, First Out" |
| 68 | text e7 "FIFO" |
| 69 | text c8 "abbreviate: punctuation" |
| 70 | text s9 "GNU Image Manipulation Program" |
| 71 | text e10 "GIMP" |
| 72 | text c11 "abbreviate: all caps word" |
| 73 | text s12 "Complementary metal-oxide semiconductor" |
| 74 | text e13 "CMOS" |
| 75 | text c14 "abbreviate: punctuation without whitespace" |
| 76 | text s15 "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me" |
| 77 | text e16 "ROTFLSHTMDCOALM" |
| 78 | text c17 "abbreviate: very long abbreviation" |
| 79 | text s18 "Something - I made up from thin air" |
| 80 | text e19 "SIMUFTA" |
| 81 | text c20 "abbreviate: consecutive delimiters" |
| 82 | text s21 "Halley's Comet" |
| 83 | text e22 "HC" |
| 84 | text c23 "abbreviate: apostrophes" |
| 85 | text s24 "The Road _Not_ Taken" |
| 86 | text e25 "TRNT" |
| 87 | text c26 "abbreviate: underscore emphasis" |
| 88 | note canonical case 1e22cceb-c5e4-4562-9afe-aef07ad1eaf4 |
| 89 | fn tc0 to bool |
| 90 | o = new uchar 1024 0 |
| 91 | n = abbreviate s0 o |
| 92 | ret tbeq part o 0 n e1 |
| 93 | end |
| 94 | note canonical case 79ae3889-a5c0-4b01-baf0-232d31180c08 |
| 95 | fn tc1 to bool |
| 96 | o = new uchar 1024 0 |
| 97 | n = abbreviate s3 o |
| 98 | ret tbeq part o 0 n e4 |
| 99 | end |
| 100 | note canonical case ec7000a7-3931-4a17-890e-33ca2073a548 |
| 101 | fn tc2 to bool |
| 102 | o = new uchar 1024 0 |
| 103 | n = abbreviate s6 o |
| 104 | ret tbeq part o 0 n e7 |
| 105 | end |
| 106 | note canonical case 32dd261c-0c92-469a-9c5c-b192e94a63b0 |
| 107 | fn tc3 to bool |
| 108 | o = new uchar 1024 0 |
| 109 | n = abbreviate s9 o |
| 110 | ret tbeq part o 0 n e10 |
| 111 | end |
| 112 | note canonical case ae2ac9fa-a606-4d05-8244-3bcc4659c1d4 |
| 113 | fn tc4 to bool |
| 114 | o = new uchar 1024 0 |
| 115 | n = abbreviate s12 o |
| 116 | ret tbeq part o 0 n e13 |
| 117 | end |
| 118 | note canonical case 0e4b1e7c-1a6d-48fb-81a7-bf65eb9e69f9 |
| 119 | fn tc5 to bool |
| 120 | o = new uchar 1024 0 |
| 121 | n = abbreviate s15 o |
| 122 | ret tbeq part o 0 n e16 |
| 123 | end |
| 124 | note canonical case 6a078f49-c68d-4b7b-89af-33a1a98c28cc |
| 125 | fn tc6 to bool |
| 126 | o = new uchar 1024 0 |
| 127 | n = abbreviate s18 o |
| 128 | ret tbeq part o 0 n e19 |
| 129 | end |
| 130 | note canonical case 5118b4b1-4572-434c-8d57-5b762e57973e |
| 131 | fn tc7 to bool |
| 132 | o = new uchar 1024 0 |
| 133 | n = abbreviate s21 o |
| 134 | ret tbeq part o 0 n e22 |
| 135 | end |
| 136 | note canonical case adc12eab-ec2d-414f-b48c-66a4fc06cdef |
| 137 | fn tc8 to bool |
| 138 | o = new uchar 1024 0 |
| 139 | n = abbreviate s24 o |
| 140 | ret tbeq part o 0 n e25 |
| 141 | end |
| 142 | fn main to int |
| 143 | tcheck tc0 c2 |
| 144 | tcheck tc1 c5 |
| 145 | tcheck tc2 c8 |
| 146 | tcheck tc3 c11 |
| 147 | tcheck tc4 c14 |
| 148 | tcheck tc5 c17 |
| 149 | tcheck tc6 c20 |
| 150 | tcheck tc7 c23 |
| 151 | tcheck tc8 c26 |
| 152 | ret int get tfails 0 |
| 153 | end |