interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / resistor-color / test.om

93 lines · 1980 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/resistor-color/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 4 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 "black"
62text c1 "colorCode: Color codes / Black"
63text s2 "white"
64text c3 "colorCode: Color codes / White"
65text s4 "orange"
66text c5 "colorCode: Color codes / Orange"
67text e6 "black,brown,red,orange,yellow,green,blue,violet,grey,white"
68text c7 "colors: Colors"
69note canonical case 49eb31c5-10a8-4180-9f7f-fea632ab87ef
70fn tc0 to bool
71ret eq colorcode s0 0
72end
73note canonical case 0a4df94b-92da-4579-a907-65040ce0b3fc
74fn tc1 to bool
75ret eq colorcode s2 9
76end
77note canonical case 5f81608d-f36f-4190-8084-f45116b6f380
78fn tc2 to bool
79ret eq colorcode s4 3
80end
81note canonical case 581d68fa-f968-4be2-9f9d-880f2fb73cf7
82fn tc3 to bool
83o = new uchar 1024 0
84n = colors o
85ret tbeq part o 0 n e6
86end
87fn main to int
88tcheck tc0 c1
89tcheck tc1 c3
90tcheck tc2 c5
91tcheck tc3 c7
92ret int get tfails 0
93end