interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / square-root / test.om

88 lines · 1961 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/square-root/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 6 cases kept, 0 skipped
50text c0 "squareRoot: root of 1"
51text c1 "squareRoot: root of 4"
52text c2 "squareRoot: root of 25"
53text c3 "squareRoot: root of 81"
54text c4 "squareRoot: root of 196"
55text c5 "squareRoot: root of 65025"
56note canonical case 9b748478-7b0a-490c-b87a-609dacf631fd
57fn tc0 to bool
58ret eq squareroot 1 1
59end
60note canonical case 7d3aa9ba-9ac6-4e93-a18b-2e8b477139bb
61fn tc1 to bool
62ret eq squareroot 4 2
63end
64note canonical case 6624aabf-3659-4ae0-a1c8-25ae7f33c6ef
65fn tc2 to bool
66ret eq squareroot 25 5
67end
68note canonical case 93beac69-265e-4429-abb1-94506b431f81
69fn tc3 to bool
70ret eq squareroot 81 9
71end
72note canonical case fbddfeda-8c4f-4bc4-87ca-6991af35360e
73fn tc4 to bool
74ret eq squareroot 196 14
75end
76note canonical case c03d0532-8368-4734-a8e0-f96a9eb7fc1d
77fn tc5 to bool
78ret eq squareroot 65025 255
79end
80fn main to int
81tcheck tc0 c0
82tcheck tc1 c1
83tcheck tc2 c2
84tcheck tc3 c3
85tcheck tc4 c4
86tcheck tc5 c5
87ret int get tfails 0
88end