interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / grains / test.om

64 lines · 1308 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 "square 1 is 1"
47text c1 "square 2 is 2"
48text c2 "square 3 is 4"
49text c3 "square 4 is 8"
50text c4 "square 16 is 32768"
51text c5 "square 32 is 2147483648"
52text c6 "square 64 is 9223372036854775808"
53text c7 "total is 18446744073709551615"
54fn main to int
55tcheck eq square 1 1 c0
56tcheck eq square 2 2 c1
57tcheck eq square 3 4 c2
58tcheck eq square 4 8 c3
59tcheck eq square 16 32768 c4
60tcheck eq square 32 2147483648 c5
61tcheck eq square 64 9223372036854775808 c6
62tcheck eq total 18446744073709551615 c7
63ret int get tfails 0
64end