interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / two-fer / test.om

93 lines · 1931 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/two-fer/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 3 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 e1 "One for you, one for me."
63text c2 "twoFer: no name given"
64text s3 "Alice"
65text e4 "One for Alice, one for me."
66text c5 "twoFer: a name given"
67text s6 "Bob"
68text e7 "One for Bob, one for me."
69text c8 "twoFer: another name given"
70note canonical case 1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce
71fn tc0 to bool
72o = new uchar 1024 0
73n = twofer part z0 0 0 o
74ret tbeq part o 0 n e1
75end
76note canonical case b4c6dbb8-b4fb-42c2-bafd-10785abe7709
77fn tc1 to bool
78o = new uchar 1024 0
79n = twofer s3 o
80ret tbeq part o 0 n e4
81end
82note canonical case 3549048d-1a6e-4653-9a79-b0bda163e8d5
83fn tc2 to bool
84o = new uchar 1024 0
85n = twofer s6 o
86ret tbeq part o 0 n e7
87end
88fn main to int
89tcheck tc0 c2
90tcheck tc1 c5
91tcheck tc2 c8
92ret int get tfails 0
93end