interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / hamming / test.om

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