omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / rotational-cipher / 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/rotational-cipher/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 10 cases kept, 0 skipped |
| 50 | fn tbeq a view uchar * b view uchar * to bool |
| 51 | if ne len a len b |
| 52 | ret false |
| 53 | end |
| 54 | for i ulong len a |
| 55 | if ne get a i get b i |
| 56 | ret false |
| 57 | end |
| 58 | end |
| 59 | ret true |
| 60 | end |
| 61 | text s0 "a" |
| 62 | text e1 "a" |
| 63 | text c2 "rotate: rotate a by 0, same output as input" |
| 64 | text s3 "a" |
| 65 | text e4 "b" |
| 66 | text c5 "rotate: rotate a by 1" |
| 67 | text s6 "a" |
| 68 | text e7 "a" |
| 69 | text c8 "rotate: rotate a by 26, same output as input" |
| 70 | text s9 "m" |
| 71 | text e10 "z" |
| 72 | text c11 "rotate: rotate m by 13" |
| 73 | text s12 "n" |
| 74 | text e13 "a" |
| 75 | text c14 "rotate: rotate n by 13 with wrap around alphabet" |
| 76 | text s15 "OMG" |
| 77 | text e16 "TRL" |
| 78 | text c17 "rotate: rotate capital letters" |
| 79 | text s18 "O M G" |
| 80 | text e19 "T R L" |
| 81 | text c20 "rotate: rotate spaces" |
| 82 | text s21 "Testing 1 2 3 testing" |
| 83 | text e22 "Xiwxmrk 1 2 3 xiwxmrk" |
| 84 | text c23 "rotate: rotate numbers" |
| 85 | text s24 "Let's eat, Grandma!" |
| 86 | text e25 "Gzo'n zvo, Bmviyhv!" |
| 87 | text c26 "rotate: rotate punctuation" |
| 88 | text s27 "The quick brown fox jumps over the lazy dog." |
| 89 | text e28 "Gur dhvpx oebja sbk whzcf bire gur ynml qbt." |
| 90 | text c29 "rotate: rotate all letters" |
| 91 | note canonical case 74e58a38-e484-43f1-9466-877a7515e10f |
| 92 | fn tc0 to bool |
| 93 | o = new uchar 1024 0 |
| 94 | n = rotate s0 0 o |
| 95 | ret tbeq part o 0 n e1 |
| 96 | end |
| 97 | note canonical case 7ee352c6-e6b0-4930-b903-d09943ecb8f5 |
| 98 | fn tc1 to bool |
| 99 | o = new uchar 1024 0 |
| 100 | n = rotate s3 1 o |
| 101 | ret tbeq part o 0 n e4 |
| 102 | end |
| 103 | note canonical case edf0a733-4231-4594-a5ee-46a4009ad764 |
| 104 | fn tc2 to bool |
| 105 | o = new uchar 1024 0 |
| 106 | n = rotate s6 26 o |
| 107 | ret tbeq part o 0 n e7 |
| 108 | end |
| 109 | note canonical case e3e82cb9-2a5b-403f-9931-e43213879300 |
| 110 | fn tc3 to bool |
| 111 | o = new uchar 1024 0 |
| 112 | n = rotate s9 13 o |
| 113 | ret tbeq part o 0 n e10 |
| 114 | end |
| 115 | note canonical case 19f9eb78-e2ad-4da4-8fe3-9291d47c1709 |
| 116 | fn tc4 to bool |
| 117 | o = new uchar 1024 0 |
| 118 | n = rotate s12 13 o |
| 119 | ret tbeq part o 0 n e13 |
| 120 | end |
| 121 | note canonical case a116aef4-225b-4da9-884f-e8023ca6408a |
| 122 | fn tc5 to bool |
| 123 | o = new uchar 1024 0 |
| 124 | n = rotate s15 5 o |
| 125 | ret tbeq part o 0 n e16 |
| 126 | end |
| 127 | note canonical case 71b541bb-819c-4dc6-a9c3-132ef9bb737b |
| 128 | fn tc6 to bool |
| 129 | o = new uchar 1024 0 |
| 130 | n = rotate s18 5 o |
| 131 | ret tbeq part o 0 n e19 |
| 132 | end |
| 133 | note canonical case ef32601d-e9ef-4b29-b2b5-8971392282e6 |
| 134 | fn tc7 to bool |
| 135 | o = new uchar 1024 0 |
| 136 | n = rotate s21 4 o |
| 137 | ret tbeq part o 0 n e22 |
| 138 | end |
| 139 | note canonical case 32dd74f6-db2b-41a6-b02c-82eb4f93e549 |
| 140 | fn tc8 to bool |
| 141 | o = new uchar 1024 0 |
| 142 | n = rotate s24 21 o |
| 143 | ret tbeq part o 0 n e25 |
| 144 | end |
| 145 | note canonical case 9fb93fe6-42b0-46e6-9ec1-0bf0a062d8c9 |
| 146 | fn tc9 to bool |
| 147 | o = new uchar 1024 0 |
| 148 | n = rotate s27 13 o |
| 149 | ret tbeq part o 0 n e28 |
| 150 | end |
| 151 | fn main to int |
| 152 | tcheck tc0 c2 |
| 153 | tcheck tc1 c5 |
| 154 | tcheck tc2 c8 |
| 155 | tcheck tc3 c11 |
| 156 | tcheck tc4 c14 |
| 157 | tcheck tc5 c17 |
| 158 | tcheck tc6 c20 |
| 159 | tcheck tc7 c23 |
| 160 | tcheck tc8 c26 |
| 161 | tcheck tc9 c29 |
| 162 | ret int get tfails 0 |
| 163 | end |