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-trio / test.om

163 lines · 3692 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-trio/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 "orange,orange,black"
62text e1 "33 ohms"
63text c2 "label: Orange and orange and black"
64text s3 "blue,grey,brown"
65text e4 "680 ohms"
66text c5 "label: Blue and grey and brown"
67text s6 "red,black,red"
68text e7 "2 kiloohms"
69text c8 "label: Red and black and red"
70text s9 "green,brown,orange"
71text e10 "51 kiloohms"
72text c11 "label: Green and brown and orange"
73text s12 "yellow,violet,yellow"
74text e13 "470 kiloohms"
75text c14 "label: Yellow and violet and yellow"
76text s15 "blue,violet,blue"
77text e16 "67 megaohms"
78text c17 "label: Blue and violet and blue"
79text s18 "black,black,black"
80text e19 "0 ohms"
81text c20 "label: Minimum possible value"
82text s21 "white,white,white"
83text e22 "99 gigaohms"
84text c23 "label: Maximum possible value"
85text s24 "black,grey,black"
86text e25 "8 ohms"
87text c26 "label: First two colors make an invalid octal number"
88text s27 "blue,green,yellow,orange"
89text e28 "650 kiloohms"
90text c29 "label: Ignore extra colors"
91note canonical case d6863355-15b7-40bb-abe0-bfb1a25512ed
92fn tc0 to bool
93o = new uchar 1024 0
94n = label s0 o
95ret tbeq part o 0 n e1
96end
97note canonical case 1224a3a9-8c8e-4032-843a-5224e04647d6
98fn tc1 to bool
99o = new uchar 1024 0
100n = label s3 o
101ret tbeq part o 0 n e4
102end
103note canonical case b8bda7dc-6b95-4539-abb2-2ad51d66a207
104fn tc2 to bool
105o = new uchar 1024 0
106n = label s6 o
107ret tbeq part o 0 n e7
108end
109note canonical case 5b1e74bc-d838-4eda-bbb3-eaba988e733b
110fn tc3 to bool
111o = new uchar 1024 0
112n = label s9 o
113ret tbeq part o 0 n e10
114end
115note canonical case f5d37ef9-1919-4719-a90d-a33c5a6934c9
116fn tc4 to bool
117o = new uchar 1024 0
118n = label s12 o
119ret tbeq part o 0 n e13
120end
121note canonical case 5f6404a7-5bb3-4283-877d-3d39bcc33854
122fn tc5 to bool
123o = new uchar 1024 0
124n = label s15 o
125ret tbeq part o 0 n e16
126end
127note canonical case 7d3a6ab8-e40e-46c3-98b1-91639fff2344
128fn tc6 to bool
129o = new uchar 1024 0
130n = label s18 o
131ret tbeq part o 0 n e19
132end
133note canonical case ca0aa0ac-3825-42de-9f07-dac68cc580fd
134fn tc7 to bool
135o = new uchar 1024 0
136n = label s21 o
137ret tbeq part o 0 n e22
138end
139note canonical case 0061a76c-903a-4714-8ce2-f26ce23b0e09
140fn tc8 to bool
141o = new uchar 1024 0
142n = label s24 o
143ret tbeq part o 0 n e25
144end
145note canonical case 30872c92-f567-4b69-a105-8455611c10c4
146fn tc9 to bool
147o = new uchar 1024 0
148n = label s27 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