interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / pascals-triangle / test.om

245 lines · 4039 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/pascals-triangle/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 8 cases kept, 0 skipped
50fn tueq a view ulong * b view ulong * 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 c0 "rows: zero rows"
62text c1 "rows: single row"
63text c2 "rows: two rows"
64text c3 "rows: three rows"
65text c4 "rows: four rows"
66text c5 "rows: five rows"
67text c6 "rows: six rows"
68text c7 "rows: ten rows"
69note canonical case 9920ce55-9629-46d5-85d6-4201f4a4234d
70fn tc0 to bool
71o = new ulong 256 0
72n = rows 0 o
73ret eq n 0
74end
75note canonical case 70d643ce-a46d-4e93-af58-12d88dd01f21
76fn tc1 to bool
77o = new ulong 256 0
78n = rows 1 o
79a0 = new ulong 1 0
80put a0 0 1
81ret tueq part o 0 n a0
82end
83note canonical case a6e5a2a2-fc9a-4b47-9f4f-ed9ad9fbe4bd
84fn tc2 to bool
85o = new ulong 256 0
86n = rows 2 o
87a0 = new ulong 3 0
88put a0 0 1
89put a0 1 1
90put a0 2 1
91ret tueq part o 0 n a0
92end
93note canonical case 97206a99-79ba-4b04-b1c5-3c0fa1e16925
94fn tc3 to bool
95o = new ulong 256 0
96n = rows 3 o
97a0 = new ulong 6 0
98put a0 0 1
99put a0 1 1
100put a0 2 1
101put a0 3 1
102put a0 4 2
103put a0 5 1
104ret tueq part o 0 n a0
105end
106note canonical case 565a0431-c797-417c-a2c8-2935e01ce306
107fn tc4 to bool
108o = new ulong 256 0
109n = rows 4 o
110a0 = new ulong 10 0
111put a0 0 1
112put a0 1 1
113put a0 2 1
114put a0 3 1
115put a0 4 2
116put a0 5 1
117put a0 6 1
118put a0 7 3
119put a0 8 3
120put a0 9 1
121ret tueq part o 0 n a0
122end
123note canonical case 06f9ea50-9f51-4eb2-b9a9-c00975686c27
124fn tc5 to bool
125o = new ulong 256 0
126n = rows 5 o
127a0 = new ulong 15 0
128put a0 0 1
129put a0 1 1
130put a0 2 1
131put a0 3 1
132put a0 4 2
133put a0 5 1
134put a0 6 1
135put a0 7 3
136put a0 8 3
137put a0 9 1
138put a0 10 1
139put a0 11 4
140put a0 12 6
141put a0 13 4
142put a0 14 1
143ret tueq part o 0 n a0
144end
145note canonical case c3912965-ddb4-46a9-848e-3363e6b00b13
146fn tc6 to bool
147o = new ulong 256 0
148n = rows 6 o
149a0 = new ulong 21 0
150put a0 0 1
151put a0 1 1
152put a0 2 1
153put a0 3 1
154put a0 4 2
155put a0 5 1
156put a0 6 1
157put a0 7 3
158put a0 8 3
159put a0 9 1
160put a0 10 1
161put a0 11 4
162put a0 12 6
163put a0 13 4
164put a0 14 1
165put a0 15 1
166put a0 16 5
167put a0 17 10
168put a0 18 10
169put a0 19 5
170put a0 20 1
171ret tueq part o 0 n a0
172end
173note canonical case 6cb26c66-7b57-4161-962c-81ec8c99f16b
174fn tc7 to bool
175o = new ulong 256 0
176n = rows 10 o
177a0 = new ulong 55 0
178put a0 0 1
179put a0 1 1
180put a0 2 1
181put a0 3 1
182put a0 4 2
183put a0 5 1
184put a0 6 1
185put a0 7 3
186put a0 8 3
187put a0 9 1
188put a0 10 1
189put a0 11 4
190put a0 12 6
191put a0 13 4
192put a0 14 1
193put a0 15 1
194put a0 16 5
195put a0 17 10
196put a0 18 10
197put a0 19 5
198put a0 20 1
199put a0 21 1
200put a0 22 6
201put a0 23 15
202put a0 24 20
203put a0 25 15
204put a0 26 6
205put a0 27 1
206put a0 28 1
207put a0 29 7
208put a0 30 21
209put a0 31 35
210put a0 32 35
211put a0 33 21
212put a0 34 7
213put a0 35 1
214put a0 36 1
215put a0 37 8
216put a0 38 28
217put a0 39 56
218put a0 40 70
219put a0 41 56
220put a0 42 28
221put a0 43 8
222put a0 44 1
223put a0 45 1
224put a0 46 9
225put a0 47 36
226put a0 48 84
227put a0 49 126
228put a0 50 126
229put a0 51 84
230put a0 52 36
231put a0 53 9
232put a0 54 1
233ret tueq part o 0 n a0
234end
235fn main to int
236tcheck tc0 c0
237tcheck tc1 c1
238tcheck tc2 c2
239tcheck tc3 c3
240tcheck tc4 c4
241tcheck tc5 c5
242tcheck tc6 c6
243tcheck tc7 c7
244ret int get tfails 0
245end