interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / atbash-cipher / test.om

203 lines · 4830 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/atbash-cipher/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 14 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 s0 "yes"
62text e1 "bvh"
63text c2 "encode: encode / encode yes"
64text s3 "no"
65text e4 "ml"
66text c5 "encode: encode / encode no"
67text s6 "OMG"
68text e7 "lnt"
69text c8 "encode: encode / encode OMG"
70text s9 "O M G"
71text e10 "lnt"
72text c11 "encode: encode / encode spaces"
73text s12 "mindblowingly"
74text e13 "nrmwy oldrm tob"
75text c14 "encode: encode / encode mindblowingly"
76text s15 "Testing,1 2 3, testing."
77text e16 "gvhgr mt123 gvhgr mt"
78text c17 "encode: encode / encode numbers"
79text s18 "Truth is fiction."
80text e19 "gifgs rhurx grlm"
81text c20 "encode: encode / encode deep thought"
82text s21 "The quick brown fox jumps over the lazy dog."
83text e22 "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
84text c23 "encode: encode / encode all the letters"
85text s24 "vcvix rhn"
86text e25 "exercism"
87text c26 "decode: decode / decode exercism"
88text s27 "zmlyh gzxov rhlug vmzhg vkkrm thglm v"
89text e28 "anobstacleisoftenasteppingstone"
90text c29 "decode: decode / decode a sentence"
91text s30 "gvhgr mt123 gvhgr mt"
92text e31 "testing123testing"
93text c32 "decode: decode / decode numbers"
94text s33 "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
95text e34 "thequickbrownfoxjumpsoverthelazydog"
96text c35 "decode: decode / decode all the letters"
97text s36 "vc vix r hn"
98text e37 "exercism"
99text c38 "decode: decode / decode with too many spaces"
100text s39 "zmlyhgzxovrhlugvmzhgvkkrmthglmv"
101text e40 "anobstacleisoftenasteppingstone"
102text c41 "decode: decode / decode with no spaces"
103note canonical case 2f47ebe1-eab9-4d6b-b3c6-627562a31c77
104fn tc0 to bool
105o = new uchar 1024 0
106n = encode s0 o
107ret tbeq part o 0 n e1
108end
109note canonical case b4ffe781-ea81-4b74-b268-cc58ba21c739
110fn tc1 to bool
111o = new uchar 1024 0
112n = encode s3 o
113ret tbeq part o 0 n e4
114end
115note canonical case 10e48927-24ab-4c4d-9d3f-3067724ace00
116fn tc2 to bool
117o = new uchar 1024 0
118n = encode s6 o
119ret tbeq part o 0 n e7
120end
121note canonical case d59b8bc3-509a-4a9a-834c-6f501b98750b
122fn tc3 to bool
123o = new uchar 1024 0
124n = encode s9 o
125ret tbeq part o 0 n e10
126end
127note canonical case 31d44b11-81b7-4a94-8b43-4af6a2449429
128fn tc4 to bool
129o = new uchar 1024 0
130n = encode s12 o
131ret tbeq part o 0 n e13
132end
133note canonical case d503361a-1433-48c0-aae0-d41b5baa33ff
134fn tc5 to bool
135o = new uchar 1024 0
136n = encode s15 o
137ret tbeq part o 0 n e16
138end
139note canonical case 79c8a2d5-0772-42d4-b41b-531d0b5da926
140fn tc6 to bool
141o = new uchar 1024 0
142n = encode s18 o
143ret tbeq part o 0 n e19
144end
145note canonical case 9ca13d23-d32a-4967-a1fd-6100b8742bab
146fn tc7 to bool
147o = new uchar 1024 0
148n = encode s21 o
149ret tbeq part o 0 n e22
150end
151note canonical case bb50e087-7fdf-48e7-9223-284fe7e69851
152fn tc8 to bool
153o = new uchar 1024 0
154n = decode s24 o
155ret tbeq part o 0 n e25
156end
157note canonical case ac021097-cd5d-4717-8907-b0814b9e292c
158fn tc9 to bool
159o = new uchar 1024 0
160n = decode s27 o
161ret tbeq part o 0 n e28
162end
163note canonical case 18729de3-de74-49b8-b68c-025eaf77f851
164fn tc10 to bool
165o = new uchar 1024 0
166n = decode s30 o
167ret tbeq part o 0 n e31
168end
169note canonical case 0f30325f-f53b-415d-ad3e-a7a4f63de034
170fn tc11 to bool
171o = new uchar 1024 0
172n = decode s33 o
173ret tbeq part o 0 n e34
174end
175note canonical case 39640287-30c6-4c8c-9bac-9d613d1a5674
176fn tc12 to bool
177o = new uchar 1024 0
178n = decode s36 o
179ret tbeq part o 0 n e37
180end
181note canonical case b34edf13-34c0-49b5-aa21-0768928000d5
182fn tc13 to bool
183o = new uchar 1024 0
184n = decode s39 o
185ret tbeq part o 0 n e40
186end
187fn main to int
188tcheck tc0 c2
189tcheck tc1 c5
190tcheck tc2 c8
191tcheck tc3 c11
192tcheck tc4 c14
193tcheck tc5 c17
194tcheck tc6 c20
195tcheck tc7 c23
196tcheck tc8 c26
197tcheck tc9 c29
198tcheck tc10 c32
199tcheck tc11 c35
200tcheck tc12 c38
201tcheck tc13 c41
202ret int get tfails 0
203end