omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / darts / 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/darts/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 "score: Missed target" |
| 51 | text c1 "score: On the outer circle" |
| 52 | text c2 "score: On the middle circle" |
| 53 | text c3 "score: On the inner circle" |
| 54 | text c4 "score: Exactly on center" |
| 55 | text c5 "score: Near the center" |
| 56 | text c6 "score: Just within the inner circle" |
| 57 | text c7 "score: Just outside the inner circle" |
| 58 | text c8 "score: Just within the middle circle" |
| 59 | text c9 "score: Just outside the middle circle" |
| 60 | text c10 "score: Just within the outer circle" |
| 61 | text c11 "score: Just outside the outer circle" |
| 62 | text c12 "score: Asymmetric position between the inner and middle circles" |
| 63 | note canonical case 9033f731-0a3a-4d9c-b1c0-34a1c8362afb |
| 64 | fn tc0 to bool |
| 65 | ret eq score -9.0 9.0 0 |
| 66 | end |
| 67 | note canonical case 4c9f6ff4-c489-45fd-be8a-1fcb08b4d0ba |
| 68 | fn tc1 to bool |
| 69 | ret eq score 0.0 10.0 1 |
| 70 | end |
| 71 | note canonical case 14378687-ee58-4c9b-a323-b089d5274be8 |
| 72 | fn tc2 to bool |
| 73 | ret eq score -5.0 0.0 5 |
| 74 | end |
| 75 | note canonical case 849e2e63-85bd-4fed-bc3b-781ae962e2c9 |
| 76 | fn tc3 to bool |
| 77 | ret eq score 0.0 -1.0 10 |
| 78 | end |
| 79 | note canonical case 1c5ffd9f-ea66-462f-9f06-a1303de5a226 |
| 80 | fn tc4 to bool |
| 81 | ret eq score 0.0 0.0 10 |
| 82 | end |
| 83 | note canonical case b65abce3-a679-4550-8115-4b74bda06088 |
| 84 | fn tc5 to bool |
| 85 | ret eq score -0.1 -0.1 10 |
| 86 | end |
| 87 | note canonical case 66c29c1d-44f5-40cf-9927-e09a1305b399 |
| 88 | fn tc6 to bool |
| 89 | ret eq score 0.7 0.7 10 |
| 90 | end |
| 91 | note canonical case d1012f63-c97c-4394-b944-7beb3d0b141a |
| 92 | fn tc7 to bool |
| 93 | ret eq score 0.8 -0.8 5 |
| 94 | end |
| 95 | note canonical case ab2b5666-b0b4-49c3-9b27-205e790ed945 |
| 96 | fn tc8 to bool |
| 97 | ret eq score -3.5 3.5 5 |
| 98 | end |
| 99 | note canonical case 70f1424e-d690-4860-8caf-9740a52c0161 |
| 100 | fn tc9 to bool |
| 101 | ret eq score -3.6 -3.6 1 |
| 102 | end |
| 103 | note canonical case a7dbf8db-419c-4712-8a7f-67602b69b293 |
| 104 | fn tc10 to bool |
| 105 | ret eq score -7.0 7.0 1 |
| 106 | end |
| 107 | note canonical case e0f39315-9f9a-4546-96e4-a9475b885aa7 |
| 108 | fn tc11 to bool |
| 109 | ret eq score 7.1 -7.1 0 |
| 110 | end |
| 111 | note canonical case 045d7d18-d863-4229-818e-b50828c75d19 |
| 112 | fn tc12 to bool |
| 113 | ret eq score 0.5 -4.0 5 |
| 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 |