interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / space-age / test.om

123 lines · 2781 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/space-age/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 9 cases kept, 0 skipped
50text s0 "Earth"
51text c1 "age: age on Earth"
52text s2 "Mercury"
53text c3 "age: age on Mercury"
54text s4 "Venus"
55text c5 "age: age on Venus"
56text s6 "Mars"
57text c7 "age: age on Mars"
58text s8 "Jupiter"
59text c9 "age: age on Jupiter"
60text s10 "Saturn"
61text c11 "age: age on Saturn"
62text s12 "Uranus"
63text c13 "age: age on Uranus"
64text s14 "Neptune"
65text c15 "age: age on Neptune"
66text s16 "Sun"
67text c17 "age: invalid planet causes error"
68note canonical case 84f609af-5a91-4d68-90a3-9e32d8a5cd34
69fn tc0 to bool
70v = age s0 1000000000.0
71ret lt fabs sub v 31.69 0.005
72end
73note canonical case ca20c4e9-6054-458c-9312-79679ffab40b
74fn tc1 to bool
75v = age s2 2134835688.0
76ret lt fabs sub v 280.88 0.005
77end
78note canonical case 502c6529-fd1b-41d3-8fab-65e03082b024
79fn tc2 to bool
80v = age s4 189839836.0
81ret lt fabs sub v 9.78 0.005
82end
83note canonical case 9ceadf5e-a0d5-4388-9d40-2c459227ceb8
84fn tc3 to bool
85v = age s6 2129871239.0
86ret lt fabs sub v 35.88 0.005
87end
88note canonical case 42927dc3-fe5e-4f76-a5b5-f737fc19bcde
89fn tc4 to bool
90v = age s8 901876382.0
91ret lt fabs sub v 2.41 0.005
92end
93note canonical case 8469b332-7837-4ada-b27c-00ee043ebcad
94fn tc5 to bool
95v = age s10 2000000000.0
96ret lt fabs sub v 2.15 0.005
97end
98note canonical case 999354c1-76f8-4bb5-a672-f317b6436743
99fn tc6 to bool
100v = age s12 1210123456.0
101ret lt fabs sub v 0.46 0.005
102end
103note canonical case 80096d30-a0d4-4449-903e-a381178355d8
104fn tc7 to bool
105v = age s14 1821023456.0
106ret lt fabs sub v 0.35 0.005
107end
108note canonical case 57b96e2a-1178-40b7-b34d-f3c9c34e4bf4
109fn tc8 to bool
110ret lt age s16 680804807.0 0.0
111end
112fn main to int
113tcheck tc0 c1
114tcheck tc1 c3
115tcheck tc2 c5
116tcheck tc3 c7
117tcheck tc4 c9
118tcheck tc5 c11
119tcheck tc6 c13
120tcheck tc7 c15
121tcheck tc8 c17
122ret int get tfails 0
123end