interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / nucleotide-count / test.om

139 lines · 2769 bytes Raw Blame History
1note ---- test harness (appended after the solution by exercise.sh) ----
2text tok "ok "
3text tnok "not ok "
4text tsep " - "
5text tnl "\n"
6global tfails ulong 1
7global tnum ulong 1
8fn temit a view uchar * to void
9o = ulong 0
10while lt o len a bound 4096
11k = write 1 a o sub len a o
12if le k 0
13exit 2
14end
15o = add o ulong k
16end
17end
18fn temitu n ulong to void
19d = new uchar 20 0
20i = ulong 20
21v = n
22while true bound 20
23i = sub i 1
24put d i uchar add rem v 10 48
25v = div v 10
26if eq v 0
27break
28end
29end
30temit part d i sub 20 i
31end
32note one TAP-style line per case; main returns the number of failed cases
33fn tcheck c bool what view uchar * to void
34put tnum 0 add get tnum 0 1
35if c
36temit tok
37else
38temit tnok
39put tfails 0 add get tfails 0 1
40end
41temitu get tnum 0
42temit tsep
43temit what
44temit tnl
45end
46note cases: exercism/problem-specifications exercises/nucleotide-count/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 5 cases kept, 0 skipped
50fn tueq a view ulong * b view ulong * to bool
51if ne len a len b
52ret false
53end
54for i ulong len a
55if ne get a i get b i
56ret false
57end
58end
59ret true
60end
61text z0 "z"
62text c1 "nucleotideCounts: empty strand"
63text s2 "G"
64text c3 "nucleotideCounts: can count one nucleotide in single-character input"
65text s4 "GGGGGGG"
66text c5 "nucleotideCounts: strand with repeated nucleotide"
67text s6 "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC"
68text c7 "nucleotideCounts: strand with multiple nucleotides"
69text s8 "AGXXACT"
70text c9 "nucleotideCounts: strand with invalid nucleotides"
71note canonical case 3e5c30a8-87e2-4845-a815-a49671ade970
72fn tc0 to bool
73o = new ulong 4 0
74a0 = new ulong 4 0
75put a0 0 0
76put a0 1 0
77put a0 2 0
78put a0 3 0
79ok = nucleotidecounts part z0 0 0 o
80if not ok
81ret false
82end
83ret tueq o a0
84end
85note canonical case a0ea42a6-06d9-4ac6-828c-7ccaccf98fec
86fn tc1 to bool
87o = new ulong 4 0
88a0 = new ulong 4 0
89put a0 0 0
90put a0 1 0
91put a0 2 1
92put a0 3 0
93ok = nucleotidecounts s2 o
94if not ok
95ret false
96end
97ret tueq o a0
98end
99note canonical case eca0d565-ed8c-43e7-9033-6cefbf5115b5
100fn tc2 to bool
101o = new ulong 4 0
102a0 = new ulong 4 0
103put a0 0 0
104put a0 1 0
105put a0 2 7
106put a0 3 0
107ok = nucleotidecounts s4 o
108if not ok
109ret false
110end
111ret tueq o a0
112end
113note canonical case 40a45eac-c83f-4740-901a-20b22d15a39f
114fn tc3 to bool
115o = new ulong 4 0
116a0 = new ulong 4 0
117put a0 0 20
118put a0 1 12
119put a0 2 17
120put a0 3 21
121ok = nucleotidecounts s6 o
122if not ok
123ret false
124end
125ret tueq o a0
126end
127note canonical case b4c47851-ee9e-4b0a-be70-a86e343bd851
128fn tc4 to bool
129o = new ulong 4 0
130ret not nucleotidecounts s8 o
131end
132fn main to int
133tcheck tc0 c1
134tcheck tc1 c3
135tcheck tc2 c5
136tcheck tc3 c7
137tcheck tc4 c9
138ret int get tfails 0
139end