omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / resistor-color-duo / 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/resistor-color-duo/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 7 cases kept, 0 skipped |
| 50 | text s0 "brown,black" |
| 51 | text c1 "value: Brown and black" |
| 52 | text s2 "blue,grey" |
| 53 | text c3 "value: Blue and grey" |
| 54 | text s4 "yellow,violet" |
| 55 | text c5 "value: Yellow and violet" |
| 56 | text s6 "white,red" |
| 57 | text c7 "value: White and red" |
| 58 | text s8 "orange,orange" |
| 59 | text c9 "value: Orange and orange" |
| 60 | text s10 "green,brown,orange" |
| 61 | text c11 "value: Ignore additional colors" |
| 62 | text s12 "black,brown" |
| 63 | text c13 "value: Black and brown, one-digit" |
| 64 | note canonical case ce11995a-5b93-4950-a5e9-93423693b2fc |
| 65 | fn tc0 to bool |
| 66 | ret eq value s0 10 |
| 67 | end |
| 68 | note canonical case 7bf82f7a-af23-48ba-a97d-38d59406a920 |
| 69 | fn tc1 to bool |
| 70 | ret eq value s2 68 |
| 71 | end |
| 72 | note canonical case f1886361-fdfd-4693-acf8-46726fe24e0c |
| 73 | fn tc2 to bool |
| 74 | ret eq value s4 47 |
| 75 | end |
| 76 | note canonical case b7a6cbd2-ae3c-470a-93eb-56670b305640 |
| 77 | fn tc3 to bool |
| 78 | ret eq value s6 92 |
| 79 | end |
| 80 | note canonical case 77a8293d-2a83-4016-b1af-991acc12b9fe |
| 81 | fn tc4 to bool |
| 82 | ret eq value s8 33 |
| 83 | end |
| 84 | note canonical case 0c4fb44f-db7c-4d03-afa8-054350f156a8 |
| 85 | fn tc5 to bool |
| 86 | ret eq value s10 51 |
| 87 | end |
| 88 | note canonical case 4a8ceec5-0ab4-4904-88a4-daf953a5e818 |
| 89 | fn tc6 to bool |
| 90 | ret eq value s12 1 |
| 91 | end |
| 92 | fn main to int |
| 93 | tcheck tc0 c1 |
| 94 | tcheck tc1 c3 |
| 95 | tcheck tc2 c5 |
| 96 | tcheck tc3 c7 |
| 97 | tcheck tc4 c9 |
| 98 | tcheck tc5 c11 |
| 99 | tcheck tc6 c13 |
| 100 | ret int get tfails 0 |
| 101 | end |