interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / queen-attack / test.om

130 lines · 3994 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/queen-attack/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 13 cases kept, 0 skipped
50text c0 "create: Test creation of Queens with valid and invalid positions / queen with a valid position"
51text c1 "create: Test creation of Queens with valid and invalid positions / queen must have positive row"
52text c2 "create: Test creation of Queens with valid and invalid positions / queen must have row on board"
53text c3 "create: Test creation of Queens with valid and invalid positions / queen must have positive column"
54text c4 "create: Test creation of Queens with valid and invalid positions / queen must have column on board"
55text c5 "canAttack: Test the ability of one queen to attack another / cannot attack"
56text c6 "canAttack: Test the ability of one queen to attack another / can attack on same row"
57text c7 "canAttack: Test the ability of one queen to attack another / can attack on same column"
58text c8 "canAttack: Test the ability of one queen to attack another / can attack on first diagonal"
59text c9 "canAttack: Test the ability of one queen to attack another / can attack on second diagonal"
60text c10 "canAttack: Test the ability of one queen to attack another / can attack on third diagonal"
61text c11 "canAttack: Test the ability of one queen to attack another / can attack on fourth diagonal"
62text c12 "canAttack: Test the ability of one queen to attack another / cannot attack if falling diagonals are only the same when reflected across the longest falling diagonal"
63note canonical case 3ac4f735-d36c-44c4-a3e2-316f79704203
64fn tc0 to bool
65ret eq create 2 2 0
66end
67note canonical case 4e812d5d-b974-4e38-9a6b-8e0492bfa7be
68fn tc1 to bool
69ret eq create -2 2 1
70end
71note canonical case f07b7536-b66b-4f08-beb9-4d70d891d5c8
72fn tc2 to bool
73ret eq create 8 4 2
74end
75note canonical case 15a10794-36d9-4907-ae6b-e5a0d4c54ebe
76fn tc3 to bool
77ret eq create 2 -2 3
78end
79note canonical case 6907762d-0e8a-4c38-87fb-12f2f65f0ce4
80fn tc4 to bool
81ret eq create 4 8 4
82end
83note canonical case 33ae4113-d237-42ee-bac1-e1e699c0c007
84fn tc5 to bool
85ret eq canattack 2 4 6 6 false
86end
87note canonical case eaa65540-ea7c-4152-8c21-003c7a68c914
88fn tc6 to bool
89ret eq canattack 2 4 2 6 true
90end
91note canonical case bae6f609-2c0e-4154-af71-af82b7c31cea
92fn tc7 to bool
93ret eq canattack 4 5 2 5 true
94end
95note canonical case 0e1b4139-b90d-4562-bd58-dfa04f1746c7
96fn tc8 to bool
97ret eq canattack 2 2 0 4 true
98end
99note canonical case ff9b7ed4-e4b6-401b-8d16-bc894d6d3dcd
100fn tc9 to bool
101ret eq canattack 2 2 3 1 true
102end
103note canonical case 0a71e605-6e28-4cc2-aa47-d20a2e71037a
104fn tc10 to bool
105ret eq canattack 2 2 1 1 true
106end
107note canonical case 0790b588-ae73-4f1f-a968-dd0b34f45f86
108fn tc11 to bool
109ret eq canattack 1 7 0 6 true
110end
111note canonical case 543f8fd4-2597-4aad-8d77-cbdab63619f8
112fn tc12 to bool
113ret eq canattack 4 1 2 5 false
114end
115fn main to int
116tcheck tc0 c0
117tcheck tc1 c1
118tcheck tc2 c2
119tcheck tc3 c3
120tcheck tc4 c4
121tcheck tc5 c5
122tcheck tc6 c6
123tcheck tc7 c7
124tcheck tc8 c8
125tcheck tc9 c9
126tcheck tc10 c10
127tcheck tc11 c11
128tcheck tc12 c12
129ret int get tfails 0
130end