omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / hamming / 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/hamming/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, 6 superseded (reimplemented) cases omitted |
| 50 | text z0 "z" |
| 51 | text z1 "z" |
| 52 | text c2 "distance: empty strands" |
| 53 | text s3 "A" |
| 54 | text s4 "A" |
| 55 | text c5 "distance: single letter identical strands" |
| 56 | text s6 "G" |
| 57 | text s7 "T" |
| 58 | text c8 "distance: single letter different strands" |
| 59 | text s9 "GGACTGAAATCTG" |
| 60 | text s10 "GGACTGAAATCTG" |
| 61 | text c11 "distance: long identical strands" |
| 62 | text s12 "GGACGGATTCTG" |
| 63 | text s13 "AGGACGGATTCT" |
| 64 | text c14 "distance: long different strands" |
| 65 | text s15 "AATG" |
| 66 | text s16 "AAA" |
| 67 | text c17 "distance: disallow first strand longer" |
| 68 | text s18 "ATA" |
| 69 | text s19 "AGTG" |
| 70 | text c20 "distance: disallow second strand longer" |
| 71 | text z21 "z" |
| 72 | text s22 "G" |
| 73 | text c23 "distance: disallow empty first strand" |
| 74 | text s24 "G" |
| 75 | text z25 "z" |
| 76 | text c26 "distance: disallow empty second strand" |
| 77 | note canonical case f6dcb64f-03b0-4b60-81b1-3c9dbf47e887 |
| 78 | fn tc0 to bool |
| 79 | ret eq distance part z0 0 0 part z1 0 0 0 |
| 80 | end |
| 81 | note canonical case 54681314-eee2-439a-9db0-b0636c656156 |
| 82 | fn tc1 to bool |
| 83 | ret eq distance s3 s4 0 |
| 84 | end |
| 85 | note canonical case 294479a3-a4c8-478f-8d63-6209815a827b |
| 86 | fn tc2 to bool |
| 87 | ret eq distance s6 s7 1 |
| 88 | end |
| 89 | note canonical case 9aed5f34-5693-4344-9b31-40c692fb5592 |
| 90 | fn tc3 to bool |
| 91 | ret eq distance s9 s10 0 |
| 92 | end |
| 93 | note canonical case cd2273a5-c576-46c8-a52b-dee251c3e6e5 |
| 94 | fn tc4 to bool |
| 95 | ret eq distance s12 s13 9 |
| 96 | end |
| 97 | note canonical case b9228bb1-465f-4141-b40f-1f99812de5a8 |
| 98 | fn tc5 to bool |
| 99 | ret eq distance s15 s16 -1 |
| 100 | end |
| 101 | note canonical case dab38838-26bb-4fff-acbe-3b0a9bfeba2d |
| 102 | fn tc6 to bool |
| 103 | ret eq distance s18 s19 -1 |
| 104 | end |
| 105 | note canonical case b764d47c-83ff-4de2-ab10-6cfe4b15c0f3 |
| 106 | fn tc7 to bool |
| 107 | ret eq distance part z21 0 0 s22 -1 |
| 108 | end |
| 109 | note canonical case 9ab9262f-3521-4191-81f5-0ed184a5aa89 |
| 110 | fn tc8 to bool |
| 111 | ret eq distance s24 part z25 0 0 -1 |
| 112 | end |
| 113 | fn main to int |
| 114 | tcheck tc0 c2 |
| 115 | tcheck tc1 c5 |
| 116 | tcheck tc2 c8 |
| 117 | tcheck tc3 c11 |
| 118 | tcheck tc4 c14 |
| 119 | tcheck tc5 c17 |
| 120 | tcheck tc6 c20 |
| 121 | tcheck tc7 c23 |
| 122 | tcheck tc8 c26 |
| 123 | ret int get tfails 0 |
| 124 | end |