interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / difference-of-squares / test.om

66 lines · 1304 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
46text c0 "sqsum 1 is 1"
47text c1 "sumsq 1 is 1"
48text c2 "diffsq 1 is 0"
49text c3 "sqsum 5 is 225"
50text c4 "sumsq 5 is 55"
51text c5 "diffsq 5 is 170"
52text c6 "sqsum 100 is 25502500"
53text c7 "sumsq 100 is 338350"
54text c8 "diffsq 100 is 25164150"
55fn main to int
56tcheck eq sqsum 1 1 c0
57tcheck eq sumsq 1 1 c1
58tcheck eq diffsq 1 0 c2
59tcheck eq sqsum 5 225 c3
60tcheck eq sumsq 5 55 c4
61tcheck eq diffsq 5 170 c5
62tcheck eq sqsum 100 25502500 c6
63tcheck eq sumsq 100 338350 c7
64tcheck eq diffsq 100 25164150 c8
65ret int get tfails 0
66end