interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / run-length-encoding / test.om

193 lines · 4852 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/run-length-encoding/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 13 cases kept, 0 skipped
50fn tbeq a view uchar * b view uchar * 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 "encode: run-length encode a string / empty string"
63text s2 "XYZ"
64text e3 "XYZ"
65text c4 "encode: run-length encode a string / single characters only are encoded without count"
66text s5 "AABBBCCCC"
67text e6 "2A3B4C"
68text c7 "encode: run-length encode a string / string with no single characters"
69text s8 "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"
70text e9 "12WB12W3B24WB"
71text c10 "encode: run-length encode a string / single characters mixed with repeated characters"
72text s11 " hsqq qww "
73text e12 "2 hs2q q2w2 "
74text c13 "encode: run-length encode a string / multiple whitespace mixed in string"
75text s14 "aabbbcccc"
76text e15 "2a3b4c"
77text c16 "encode: run-length encode a string / lowercase characters"
78text z17 "z"
79text c18 "decode: run-length decode a string / empty string"
80text s19 "XYZ"
81text e20 "XYZ"
82text c21 "decode: run-length decode a string / single characters only"
83text s22 "2A3B4C"
84text e23 "AABBBCCCC"
85text c24 "decode: run-length decode a string / string with no single characters"
86text s25 "12WB12W3B24WB"
87text e26 "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"
88text c27 "decode: run-length decode a string / single characters with repeated characters"
89text s28 "2 hs2q q2w2 "
90text e29 " hsqq qww "
91text c30 "decode: run-length decode a string / multiple whitespace mixed in string"
92text s31 "2a3b4c"
93text e32 "aabbbcccc"
94text c33 "decode: run-length decode a string / lowercase string"
95text s34 "zzz ZZ zZ"
96text e35 "zzz ZZ zZ"
97text c36 "consistency: encode and then decode / encode followed by decode gives original string"
98note canonical case ad53b61b-6ffc-422f-81a6-61f7df92a231
99fn tc0 to bool
100o = new uchar 1024 0
101n = encode part z0 0 0 o
102ret eq n 0
103end
104note canonical case 52012823-b7e6-4277-893c-5b96d42f82de
105fn tc1 to bool
106o = new uchar 1024 0
107n = encode s2 o
108ret tbeq part o 0 n e3
109end
110note canonical case b7868492-7e3a-415f-8da3-d88f51f80409
111fn tc2 to bool
112o = new uchar 1024 0
113n = encode s5 o
114ret tbeq part o 0 n e6
115end
116note canonical case 859b822b-6e9f-44d6-9c46-6091ee6ae358
117fn tc3 to bool
118o = new uchar 1024 0
119n = encode s8 o
120ret tbeq part o 0 n e9
121end
122note canonical case 1b34de62-e152-47be-bc88-469746df63b3
123fn tc4 to bool
124o = new uchar 1024 0
125n = encode s11 o
126ret tbeq part o 0 n e12
127end
128note canonical case abf176e2-3fbd-40ad-bb2f-2dd6d4df721a
129fn tc5 to bool
130o = new uchar 1024 0
131n = encode s14 o
132ret tbeq part o 0 n e15
133end
134note canonical case 7ec5c390-f03c-4acf-ac29-5f65861cdeb5
135fn tc6 to bool
136o = new uchar 1024 0
137n = decode part z17 0 0 o
138ret eq n 0
139end
140note canonical case ad23f455-1ac2-4b0e-87d0-b85b10696098
141fn tc7 to bool
142o = new uchar 1024 0
143n = decode s19 o
144ret tbeq part o 0 n e20
145end
146note canonical case 21e37583-5a20-4a0e-826c-3dee2c375f54
147fn tc8 to bool
148o = new uchar 1024 0
149n = decode s22 o
150ret tbeq part o 0 n e23
151end
152note canonical case 1389ad09-c3a8-4813-9324-99363fba429c
153fn tc9 to bool
154o = new uchar 1024 0
155n = decode s25 o
156ret tbeq part o 0 n e26
157end
158note canonical case 3f8e3c51-6aca-4670-b86c-a213bf4706b0
159fn tc10 to bool
160o = new uchar 1024 0
161n = decode s28 o
162ret tbeq part o 0 n e29
163end
164note canonical case 29f721de-9aad-435f-ba37-7662df4fb551
165fn tc11 to bool
166o = new uchar 1024 0
167n = decode s31 o
168ret tbeq part o 0 n e32
169end
170note canonical case 2a762efd-8695-4e04-b0d6-9736899fbc16
171fn tc12 to bool
172o = new uchar 1024 0
173o2 = new uchar 1024 0
174n = encode s34 o
175m = decode part o 0 n o2
176ret tbeq part o2 0 m e35
177end
178fn main to int
179tcheck tc0 c1
180tcheck tc1 c4
181tcheck tc2 c7
182tcheck tc3 c10
183tcheck tc4 c13
184tcheck tc5 c16
185tcheck tc6 c18
186tcheck tc7 c21
187tcheck tc8 c24
188tcheck tc9 c27
189tcheck tc10 c30
190tcheck tc11 c33
191tcheck tc12 c36
192ret int get tfails 0
193end