omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / nucleotide-count / 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/nucleotide-count/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 5 cases kept, 0 skipped |
| 50 | fn tueq a view ulong * b view ulong * 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 z0 "z" |
| 62 | text c1 "nucleotideCounts: empty strand" |
| 63 | text s2 "G" |
| 64 | text c3 "nucleotideCounts: can count one nucleotide in single-character input" |
| 65 | text s4 "GGGGGGG" |
| 66 | text c5 "nucleotideCounts: strand with repeated nucleotide" |
| 67 | text s6 "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC" |
| 68 | text c7 "nucleotideCounts: strand with multiple nucleotides" |
| 69 | text s8 "AGXXACT" |
| 70 | text c9 "nucleotideCounts: strand with invalid nucleotides" |
| 71 | note canonical case 3e5c30a8-87e2-4845-a815-a49671ade970 |
| 72 | fn tc0 to bool |
| 73 | o = new ulong 4 0 |
| 74 | a0 = new ulong 4 0 |
| 75 | put a0 0 0 |
| 76 | put a0 1 0 |
| 77 | put a0 2 0 |
| 78 | put a0 3 0 |
| 79 | ok = nucleotidecounts part z0 0 0 o |
| 80 | if not ok |
| 81 | ret false |
| 82 | end |
| 83 | ret tueq o a0 |
| 84 | end |
| 85 | note canonical case a0ea42a6-06d9-4ac6-828c-7ccaccf98fec |
| 86 | fn tc1 to bool |
| 87 | o = new ulong 4 0 |
| 88 | a0 = new ulong 4 0 |
| 89 | put a0 0 0 |
| 90 | put a0 1 0 |
| 91 | put a0 2 1 |
| 92 | put a0 3 0 |
| 93 | ok = nucleotidecounts s2 o |
| 94 | if not ok |
| 95 | ret false |
| 96 | end |
| 97 | ret tueq o a0 |
| 98 | end |
| 99 | note canonical case eca0d565-ed8c-43e7-9033-6cefbf5115b5 |
| 100 | fn tc2 to bool |
| 101 | o = new ulong 4 0 |
| 102 | a0 = new ulong 4 0 |
| 103 | put a0 0 0 |
| 104 | put a0 1 0 |
| 105 | put a0 2 7 |
| 106 | put a0 3 0 |
| 107 | ok = nucleotidecounts s4 o |
| 108 | if not ok |
| 109 | ret false |
| 110 | end |
| 111 | ret tueq o a0 |
| 112 | end |
| 113 | note canonical case 40a45eac-c83f-4740-901a-20b22d15a39f |
| 114 | fn tc3 to bool |
| 115 | o = new ulong 4 0 |
| 116 | a0 = new ulong 4 0 |
| 117 | put a0 0 20 |
| 118 | put a0 1 12 |
| 119 | put a0 2 17 |
| 120 | put a0 3 21 |
| 121 | ok = nucleotidecounts s6 o |
| 122 | if not ok |
| 123 | ret false |
| 124 | end |
| 125 | ret tueq o a0 |
| 126 | end |
| 127 | note canonical case b4c47851-ee9e-4b0a-be70-a86e343bd851 |
| 128 | fn tc4 to bool |
| 129 | o = new ulong 4 0 |
| 130 | ret not nucleotidecounts s8 o |
| 131 | end |
| 132 | fn main to int |
| 133 | tcheck tc0 c1 |
| 134 | tcheck tc1 c3 |
| 135 | tcheck tc2 c5 |
| 136 | tcheck tc3 c7 |
| 137 | tcheck tc4 c9 |
| 138 | ret int get tfails 0 |
| 139 | end |