interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

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

163 lines · 3626 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/rotational-cipher/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 10 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 "a"
62text e1 "a"
63text c2 "rotate: rotate a by 0, same output as input"
64text s3 "a"
65text e4 "b"
66text c5 "rotate: rotate a by 1"
67text s6 "a"
68text e7 "a"
69text c8 "rotate: rotate a by 26, same output as input"
70text s9 "m"
71text e10 "z"
72text c11 "rotate: rotate m by 13"
73text s12 "n"
74text e13 "a"
75text c14 "rotate: rotate n by 13 with wrap around alphabet"
76text s15 "OMG"
77text e16 "TRL"
78text c17 "rotate: rotate capital letters"
79text s18 "O M G"
80text e19 "T R L"
81text c20 "rotate: rotate spaces"
82text s21 "Testing 1 2 3 testing"
83text e22 "Xiwxmrk 1 2 3 xiwxmrk"
84text c23 "rotate: rotate numbers"
85text s24 "Let's eat, Grandma!"
86text e25 "Gzo'n zvo, Bmviyhv!"
87text c26 "rotate: rotate punctuation"
88text s27 "The quick brown fox jumps over the lazy dog."
89text e28 "Gur dhvpx oebja sbk whzcf bire gur ynml qbt."
90text c29 "rotate: rotate all letters"
91note canonical case 74e58a38-e484-43f1-9466-877a7515e10f
92fn tc0 to bool
93o = new uchar 1024 0
94n = rotate s0 0 o
95ret tbeq part o 0 n e1
96end
97note canonical case 7ee352c6-e6b0-4930-b903-d09943ecb8f5
98fn tc1 to bool
99o = new uchar 1024 0
100n = rotate s3 1 o
101ret tbeq part o 0 n e4
102end
103note canonical case edf0a733-4231-4594-a5ee-46a4009ad764
104fn tc2 to bool
105o = new uchar 1024 0
106n = rotate s6 26 o
107ret tbeq part o 0 n e7
108end
109note canonical case e3e82cb9-2a5b-403f-9931-e43213879300
110fn tc3 to bool
111o = new uchar 1024 0
112n = rotate s9 13 o
113ret tbeq part o 0 n e10
114end
115note canonical case 19f9eb78-e2ad-4da4-8fe3-9291d47c1709
116fn tc4 to bool
117o = new uchar 1024 0
118n = rotate s12 13 o
119ret tbeq part o 0 n e13
120end
121note canonical case a116aef4-225b-4da9-884f-e8023ca6408a
122fn tc5 to bool
123o = new uchar 1024 0
124n = rotate s15 5 o
125ret tbeq part o 0 n e16
126end
127note canonical case 71b541bb-819c-4dc6-a9c3-132ef9bb737b
128fn tc6 to bool
129o = new uchar 1024 0
130n = rotate s18 5 o
131ret tbeq part o 0 n e19
132end
133note canonical case ef32601d-e9ef-4b29-b2b5-8971392282e6
134fn tc7 to bool
135o = new uchar 1024 0
136n = rotate s21 4 o
137ret tbeq part o 0 n e22
138end
139note canonical case 32dd74f6-db2b-41a6-b02c-82eb4f93e549
140fn tc8 to bool
141o = new uchar 1024 0
142n = rotate s24 21 o
143ret tbeq part o 0 n e25
144end
145note canonical case 9fb93fe6-42b0-46e6-9ec1-0bf0a062d8c9
146fn tc9 to bool
147o = new uchar 1024 0
148n = rotate s27 13 o
149ret tbeq part o 0 n e28
150end
151fn main to int
152tcheck tc0 c2
153tcheck tc1 c5
154tcheck tc2 c8
155tcheck tc3 c11
156tcheck tc4 c14
157tcheck tc5 c17
158tcheck tc6 c20
159tcheck tc7 c23
160tcheck tc8 c26
161tcheck tc9 c29
162ret int get tfails 0
163end