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 / armstrong-numbers / test.om

66 lines · 1252 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 "0"
47text c1 "5"
48text c2 "10"
49text c3 "153"
50text c4 "100"
51text c5 "9474"
52text c6 "9475"
53text c7 "9926315"
54text c8 "9926314"
55fn main to int
56tcheck eq armstrong 0 true c0
57tcheck eq armstrong 5 true c1
58tcheck eq armstrong 10 false c2
59tcheck eq armstrong 153 true c3
60tcheck eq armstrong 100 false c4
61tcheck eq armstrong 9474 true c5
62tcheck eq armstrong 9475 false c6
63tcheck eq armstrong 9926315 true c7
64tcheck eq armstrong 9926314 false c8
65ret int get tfails 0
66end