interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / leap / test.om

66 lines · 1216 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 "2015"
47text c1 "1970"
48text c2 "1996"
49text c3 "1960"
50text c4 "2100"
51text c5 "1900"
52text c6 "2000"
53text c7 "2400"
54text c8 "1800"
55fn main to int
56tcheck eq leap 2015 false c0
57tcheck eq leap 1970 false c1
58tcheck eq leap 1996 true c2
59tcheck eq leap 1960 true c3
60tcheck eq leap 2100 false c4
61tcheck eq leap 1900 false c5
62tcheck eq leap 2000 true c6
63tcheck eq leap 2400 true c7
64tcheck eq leap 1800 false c8
65ret int get tfails 0
66end