omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / queen-attack / test.om
| 1 | note ---- test harness (appended after the solution by exercise.sh) ---- |
| 2 | text tok "ok " |
| 3 | text tnok "not ok " |
| 4 | text tsep " - " |
| 5 | text tnl "\n" |
| 6 | global tfails ulong 1 |
| 7 | global tnum ulong 1 |
| 8 | fn temit a view uchar * to void |
| 9 | o = ulong 0 |
| 10 | while lt o len a bound 4096 |
| 11 | k = write 1 a o sub len a o |
| 12 | if le k 0 |
| 13 | exit 2 |
| 14 | end |
| 15 | o = add o ulong k |
| 16 | end |
| 17 | end |
| 18 | fn temitu n ulong to void |
| 19 | d = new uchar 20 0 |
| 20 | i = ulong 20 |
| 21 | v = n |
| 22 | while true bound 20 |
| 23 | i = sub i 1 |
| 24 | put d i uchar add rem v 10 48 |
| 25 | v = div v 10 |
| 26 | if eq v 0 |
| 27 | break |
| 28 | end |
| 29 | end |
| 30 | temit part d i sub 20 i |
| 31 | end |
| 32 | note one TAP-style line per case; main returns the number of failed cases |
| 33 | fn tcheck c bool what view uchar * to void |
| 34 | put tnum 0 add get tnum 0 1 |
| 35 | if c |
| 36 | temit tok |
| 37 | else |
| 38 | temit tnok |
| 39 | put tfails 0 add get tfails 0 1 |
| 40 | end |
| 41 | temitu get tnum 0 |
| 42 | temit tsep |
| 43 | temit what |
| 44 | temit tnl |
| 45 | end |
| 46 | note cases: exercism/problem-specifications exercises/queen-attack/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 13 cases kept, 0 skipped |
| 50 | text c0 "create: Test creation of Queens with valid and invalid positions / queen with a valid position" |
| 51 | text c1 "create: Test creation of Queens with valid and invalid positions / queen must have positive row" |
| 52 | text c2 "create: Test creation of Queens with valid and invalid positions / queen must have row on board" |
| 53 | text c3 "create: Test creation of Queens with valid and invalid positions / queen must have positive column" |
| 54 | text c4 "create: Test creation of Queens with valid and invalid positions / queen must have column on board" |
| 55 | text c5 "canAttack: Test the ability of one queen to attack another / cannot attack" |
| 56 | text c6 "canAttack: Test the ability of one queen to attack another / can attack on same row" |
| 57 | text c7 "canAttack: Test the ability of one queen to attack another / can attack on same column" |
| 58 | text c8 "canAttack: Test the ability of one queen to attack another / can attack on first diagonal" |
| 59 | text c9 "canAttack: Test the ability of one queen to attack another / can attack on second diagonal" |
| 60 | text c10 "canAttack: Test the ability of one queen to attack another / can attack on third diagonal" |
| 61 | text c11 "canAttack: Test the ability of one queen to attack another / can attack on fourth diagonal" |
| 62 | text 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" |
| 63 | note canonical case 3ac4f735-d36c-44c4-a3e2-316f79704203 |
| 64 | fn tc0 to bool |
| 65 | ret eq create 2 2 0 |
| 66 | end |
| 67 | note canonical case 4e812d5d-b974-4e38-9a6b-8e0492bfa7be |
| 68 | fn tc1 to bool |
| 69 | ret eq create -2 2 1 |
| 70 | end |
| 71 | note canonical case f07b7536-b66b-4f08-beb9-4d70d891d5c8 |
| 72 | fn tc2 to bool |
| 73 | ret eq create 8 4 2 |
| 74 | end |
| 75 | note canonical case 15a10794-36d9-4907-ae6b-e5a0d4c54ebe |
| 76 | fn tc3 to bool |
| 77 | ret eq create 2 -2 3 |
| 78 | end |
| 79 | note canonical case 6907762d-0e8a-4c38-87fb-12f2f65f0ce4 |
| 80 | fn tc4 to bool |
| 81 | ret eq create 4 8 4 |
| 82 | end |
| 83 | note canonical case 33ae4113-d237-42ee-bac1-e1e699c0c007 |
| 84 | fn tc5 to bool |
| 85 | ret eq canattack 2 4 6 6 false |
| 86 | end |
| 87 | note canonical case eaa65540-ea7c-4152-8c21-003c7a68c914 |
| 88 | fn tc6 to bool |
| 89 | ret eq canattack 2 4 2 6 true |
| 90 | end |
| 91 | note canonical case bae6f609-2c0e-4154-af71-af82b7c31cea |
| 92 | fn tc7 to bool |
| 93 | ret eq canattack 4 5 2 5 true |
| 94 | end |
| 95 | note canonical case 0e1b4139-b90d-4562-bd58-dfa04f1746c7 |
| 96 | fn tc8 to bool |
| 97 | ret eq canattack 2 2 0 4 true |
| 98 | end |
| 99 | note canonical case ff9b7ed4-e4b6-401b-8d16-bc894d6d3dcd |
| 100 | fn tc9 to bool |
| 101 | ret eq canattack 2 2 3 1 true |
| 102 | end |
| 103 | note canonical case 0a71e605-6e28-4cc2-aa47-d20a2e71037a |
| 104 | fn tc10 to bool |
| 105 | ret eq canattack 2 2 1 1 true |
| 106 | end |
| 107 | note canonical case 0790b588-ae73-4f1f-a968-dd0b34f45f86 |
| 108 | fn tc11 to bool |
| 109 | ret eq canattack 1 7 0 6 true |
| 110 | end |
| 111 | note canonical case 543f8fd4-2597-4aad-8d77-cbdab63619f8 |
| 112 | fn tc12 to bool |
| 113 | ret eq canattack 4 1 2 5 false |
| 114 | end |
| 115 | fn main to int |
| 116 | tcheck tc0 c0 |
| 117 | tcheck tc1 c1 |
| 118 | tcheck tc2 c2 |
| 119 | tcheck tc3 c3 |
| 120 | tcheck tc4 c4 |
| 121 | tcheck tc5 c5 |
| 122 | tcheck tc6 c6 |
| 123 | tcheck tc7 c7 |
| 124 | tcheck tc8 c8 |
| 125 | tcheck tc9 c9 |
| 126 | tcheck tc10 c10 |
| 127 | tcheck tc11 c11 |
| 128 | tcheck tc12 c12 |
| 129 | ret int get tfails 0 |
| 130 | end |