interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / si / rosetta / exercises / isbn-verifier / test.om

199 lines · 5163 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/isbn-verifier/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 21 cases kept, 0 skipped
50text s0 "3-598-21508-8"
51text c1 "isValid: valid isbn"
52text s2 "3-598-21508-9"
53text c3 "isValid: invalid isbn check digit"
54text s4 "3-598-21507-X"
55text c5 "isValid: valid isbn with a check digit of 10"
56text s6 "3-598-21507-A"
57text c7 "isValid: check digit is a character other than X"
58text s8 "4-598-21507-B"
59text c9 "isValid: invalid check digit in isbn is not treated as zero"
60text s10 "3-598-P1581-X"
61text c11 "isValid: invalid character in isbn is not treated as zero"
62text s12 "3-598-2X507-9"
63text c13 "isValid: X is only valid as a check digit"
64text s14 "3-598-21508-96"
65text c15 "isValid: only one check digit is allowed"
66text s16 "3-598-2X507-5"
67text c17 "isValid: X is not substituted by the value 10"
68text s18 "3598215088"
69text c19 "isValid: valid isbn without separating dashes"
70text s20 "359821507X"
71text c21 "isValid: isbn without separating dashes and X as check digit"
72text s22 "359821507"
73text c23 "isValid: isbn without check digit and dashes"
74text s24 "3598215078X"
75text c25 "isValid: too long isbn and no dashes"
76text s26 "00"
77text c27 "isValid: too short isbn"
78text s28 "3-598-21507"
79text c29 "isValid: isbn without check digit"
80text s30 "3-598-21515-X"
81text c31 "isValid: check digit of X should not be used for 0"
82text z32 "z"
83text c33 "isValid: empty isbn"
84text s34 "134456729"
85text c35 "isValid: input is 9 characters"
86text s36 "3132P34035"
87text c37 "isValid: invalid characters are not ignored after checking length"
88text s38 "3598P215088"
89text c39 "isValid: invalid characters are not ignored before checking length"
90text s40 "98245726788"
91text c41 "isValid: input is too long but contains a valid isbn"
92note canonical case 0caa3eac-d2e3-4c29-8df8-b188bc8c9292
93fn tc0 to bool
94ret eq isvalid s0 true
95end
96note canonical case 19f76b53-7c24-45f8-87b8-4604d0ccd248
97fn tc1 to bool
98ret eq isvalid s2 false
99end
100note canonical case 4164bfee-fb0a-4a1c-9f70-64c6a1903dcd
101fn tc2 to bool
102ret eq isvalid s4 true
103end
104note canonical case 3ed50db1-8982-4423-a993-93174a20825c
105fn tc3 to bool
106ret eq isvalid s6 false
107end
108note canonical case 9416f4a5-fe01-4b61-a07b-eb75892ef562
109fn tc4 to bool
110ret eq isvalid s8 false
111end
112note canonical case c19ba0c4-014f-4dc3-a63f-ff9aefc9b5ec
113fn tc5 to bool
114ret eq isvalid s10 false
115end
116note canonical case 28025280-2c39-4092-9719-f3234b89c627
117fn tc6 to bool
118ret eq isvalid s12 false
119end
120note canonical case 8005b57f-f194-44ee-88d2-a77ac4142591
121fn tc7 to bool
122ret eq isvalid s14 false
123end
124note canonical case fdb14c99-4cf8-43c5-b06d-eb1638eff343
125fn tc8 to bool
126ret eq isvalid s16 false
127end
128note canonical case f6294e61-7e79-46b3-977b-f48789a4945b
129fn tc9 to bool
130ret eq isvalid s18 true
131end
132note canonical case 185ab99b-3a1b-45f3-aeec-b80d80b07f0b
133fn tc10 to bool
134ret eq isvalid s20 true
135end
136note canonical case 7725a837-ec8e-4528-a92a-d981dd8cf3e2
137fn tc11 to bool
138ret eq isvalid s22 false
139end
140note canonical case 47e4dfba-9c20-46ed-9958-4d3190630bdf
141fn tc12 to bool
142ret eq isvalid s24 false
143end
144note canonical case 737f4e91-cbba-4175-95bf-ae630b41fb60
145fn tc13 to bool
146ret eq isvalid s26 false
147end
148note canonical case 5458a128-a9b6-4ff8-8afb-674e74567cef
149fn tc14 to bool
150ret eq isvalid s28 false
151end
152note canonical case 70b6ad83-d0a2-4ca7-a4d5-a9ab731800f7
153fn tc15 to bool
154ret eq isvalid s30 false
155end
156note canonical case 94610459-55ab-4c35-9b93-ff6ea1a8e562
157fn tc16 to bool
158ret eq isvalid part z32 0 0 false
159end
160note canonical case 7bff28d4-d770-48cc-80d6-b20b3a0fb46c
161fn tc17 to bool
162ret eq isvalid s34 false
163end
164note canonical case ed6e8d1b-382c-4081-8326-8b772c581fec
165fn tc18 to bool
166ret eq isvalid s36 false
167end
168note canonical case daad3e58-ce00-4395-8a8e-e3eded1cdc86
169fn tc19 to bool
170ret eq isvalid s38 false
171end
172note canonical case fb5e48d8-7c03-4bfb-a088-b101df16fdc3
173fn tc20 to bool
174ret eq isvalid s40 false
175end
176fn main to int
177tcheck tc0 c1
178tcheck tc1 c3
179tcheck tc2 c5
180tcheck tc3 c7
181tcheck tc4 c9
182tcheck tc5 c11
183tcheck tc6 c13
184tcheck tc7 c15
185tcheck tc8 c17
186tcheck tc9 c19
187tcheck tc10 c21
188tcheck tc11 c23
189tcheck tc12 c25
190tcheck tc13 c27
191tcheck tc14 c29
192tcheck tc15 c31
193tcheck tc16 c33
194tcheck tc17 c35
195tcheck tc18 c37
196tcheck tc19 c39
197tcheck tc20 c41
198ret int get tfails 0
199end