interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / binary-search / test.om

199 lines · 4001 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/binary-search/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 11 cases kept, 0 skipped
50text c0 "find: finds a value in an array with one element"
51text c1 "find: finds a value in the middle of an array"
52text c2 "find: finds a value at the beginning of an array"
53text c3 "find: finds a value at the end of an array"
54text c4 "find: finds a value in an array of odd length"
55text c5 "find: finds a value in an array of even length"
56text c6 "find: identifies that a value is not included in the array"
57text c7 "find: a value smaller than the array's smallest value is not found"
58text c8 "find: a value larger than the array's largest value is not found"
59text c9 "find: nothing is found in an empty array"
60text c10 "find: nothing is found when the left and right bounds cross"
61note canonical case b55c24a9-a98d-4379-a08c-2adcf8ebeee8
62fn tc0 to bool
63a0 = new ulong 1 0
64put a0 0 6
65ret eq find a0 6 0
66end
67note canonical case 73469346-b0a0-4011-89bf-989e443d503d
68fn tc1 to bool
69a0 = new ulong 7 0
70put a0 0 1
71put a0 1 3
72put a0 2 4
73put a0 3 6
74put a0 4 8
75put a0 5 9
76put a0 6 11
77ret eq find a0 6 3
78end
79note canonical case 327bc482-ab85-424e-a724-fb4658e66ddb
80fn tc2 to bool
81a0 = new ulong 7 0
82put a0 0 1
83put a0 1 3
84put a0 2 4
85put a0 3 6
86put a0 4 8
87put a0 5 9
88put a0 6 11
89ret eq find a0 1 0
90end
91note canonical case f9f94b16-fe5e-472c-85ea-c513804c7d59
92fn tc3 to bool
93a0 = new ulong 7 0
94put a0 0 1
95put a0 1 3
96put a0 2 4
97put a0 3 6
98put a0 4 8
99put a0 5 9
100put a0 6 11
101ret eq find a0 11 6
102end
103note canonical case f0068905-26e3-4342-856d-ad153cadb338
104fn tc4 to bool
105a0 = new ulong 13 0
106put a0 0 1
107put a0 1 3
108put a0 2 5
109put a0 3 8
110put a0 4 13
111put a0 5 21
112put a0 6 34
113put a0 7 55
114put a0 8 89
115put a0 9 144
116put a0 10 233
117put a0 11 377
118put a0 12 634
119ret eq find a0 144 9
120end
121note canonical case fc316b12-c8b3-4f5e-9e89-532b3389de8c
122fn tc5 to bool
123a0 = new ulong 12 0
124put a0 0 1
125put a0 1 3
126put a0 2 5
127put a0 3 8
128put a0 4 13
129put a0 5 21
130put a0 6 34
131put a0 7 55
132put a0 8 89
133put a0 9 144
134put a0 10 233
135put a0 11 377
136ret eq find a0 21 5
137end
138note canonical case da7db20a-354f-49f7-a6a1-650a54998aa6
139fn tc6 to bool
140a0 = new ulong 7 0
141put a0 0 1
142put a0 1 3
143put a0 2 4
144put a0 3 6
145put a0 4 8
146put a0 5 9
147put a0 6 11
148ret eq find a0 7 -1
149end
150note canonical case 95d869ff-3daf-4c79-b622-6e805c675f97
151fn tc7 to bool
152a0 = new ulong 7 0
153put a0 0 1
154put a0 1 3
155put a0 2 4
156put a0 3 6
157put a0 4 8
158put a0 5 9
159put a0 6 11
160ret eq find a0 0 -1
161end
162note canonical case 8b24ef45-6e51-4a94-9eac-c2bf38fdb0ba
163fn tc8 to bool
164a0 = new ulong 7 0
165put a0 0 1
166put a0 1 3
167put a0 2 4
168put a0 3 6
169put a0 4 8
170put a0 5 9
171put a0 6 11
172ret eq find a0 13 -1
173end
174note canonical case f439a0fa-cf42-4262-8ad1-64bf41ce566a
175fn tc9 to bool
176a0 = new ulong 1 0
177ret eq find part a0 0 0 1 -1
178end
179note canonical case 2c353967-b56d-40b8-acff-ce43115eed64
180fn tc10 to bool
181a0 = new ulong 2 0
182put a0 0 1
183put a0 1 2
184ret eq find a0 0 -1
185end
186fn main to int
187tcheck tc0 c0
188tcheck tc1 c1
189tcheck tc2 c2
190tcheck tc3 c3
191tcheck tc4 c4
192tcheck tc5 c5
193tcheck tc6 c6
194tcheck tc7 c7
195tcheck tc8 c8
196tcheck tc9 c9
197tcheck tc10 c10
198ret int get tfails 0
199end