omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / exercises / largest-series-product / 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/largest-series-product/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 15 cases kept, 0 skipped, 3 superseded (reimplemented) cases omitted |
| 50 | text s0 "29" |
| 51 | text c1 "largestProduct: finds the largest product if span equals length" |
| 52 | text s2 "0123456789" |
| 53 | text c3 "largestProduct: can find the largest product of 2 with numbers in order" |
| 54 | text s4 "576802143" |
| 55 | text c5 "largestProduct: can find the largest product of 2" |
| 56 | text s6 "0123456789" |
| 57 | text c7 "largestProduct: can find the largest product of 3 with numbers in order" |
| 58 | text s8 "1027839564" |
| 59 | text c9 "largestProduct: can find the largest product of 3" |
| 60 | text s10 "0123456789" |
| 61 | text c11 "largestProduct: can find the largest product of 5 with numbers in order" |
| 62 | text s12 "73167176531330624919225119674426574742355349194934" |
| 63 | text c13 "largestProduct: can get the largest product of a big number" |
| 64 | text s14 "0000" |
| 65 | text c15 "largestProduct: reports zero if the only digits are zero" |
| 66 | text s16 "99099" |
| 67 | text c17 "largestProduct: reports zero if all spans include zero" |
| 68 | text s18 "123" |
| 69 | text c19 "largestProduct: rejects span longer than string length" |
| 70 | text z20 "z" |
| 71 | text c21 "largestProduct: reports 1 for empty string and empty product (0 span)" |
| 72 | text s22 "123" |
| 73 | text c23 "largestProduct: reports 1 for nonempty string and empty product (0 span)" |
| 74 | text z24 "z" |
| 75 | text c25 "largestProduct: rejects empty string and nonzero span" |
| 76 | text s26 "1234a5" |
| 77 | text c27 "largestProduct: rejects invalid character in digits" |
| 78 | text s28 "12345" |
| 79 | text c29 "largestProduct: rejects negative span" |
| 80 | note canonical case 7c82f8b7-e347-48ee-8a22-f672323324d4 |
| 81 | fn tc0 to bool |
| 82 | ret eq largestproduct s0 2 18 |
| 83 | end |
| 84 | note canonical case 88523f65-21ba-4458-a76a-b4aaf6e4cb5e |
| 85 | fn tc1 to bool |
| 86 | ret eq largestproduct s2 2 72 |
| 87 | end |
| 88 | note canonical case f1376b48-1157-419d-92c2-1d7e36a70b8a |
| 89 | fn tc2 to bool |
| 90 | ret eq largestproduct s4 2 48 |
| 91 | end |
| 92 | note canonical case 46356a67-7e02-489e-8fea-321c2fa7b4a4 |
| 93 | fn tc3 to bool |
| 94 | ret eq largestproduct s6 3 504 |
| 95 | end |
| 96 | note canonical case a2dcb54b-2b8f-4993-92dd-5ce56dece64a |
| 97 | fn tc4 to bool |
| 98 | ret eq largestproduct s8 3 270 |
| 99 | end |
| 100 | note canonical case 673210a3-33cd-4708-940b-c482d7a88f9d |
| 101 | fn tc5 to bool |
| 102 | ret eq largestproduct s10 5 15120 |
| 103 | end |
| 104 | note canonical case 02acd5a6-3bbf-46df-8282-8b313a80a7c9 |
| 105 | fn tc6 to bool |
| 106 | ret eq largestproduct s12 6 23520 |
| 107 | end |
| 108 | note canonical case 76dcc407-21e9-424c-a98e-609f269622b5 |
| 109 | fn tc7 to bool |
| 110 | ret eq largestproduct s14 2 0 |
| 111 | end |
| 112 | note canonical case 6ef0df9f-52d4-4a5d-b210-f6fae5f20e19 |
| 113 | fn tc8 to bool |
| 114 | ret eq largestproduct s16 3 0 |
| 115 | end |
| 116 | note canonical case 0ae1ce53-d9ba-41bb-827f-2fceb64f058b |
| 117 | fn tc9 to bool |
| 118 | ret eq largestproduct s18 4 -2 |
| 119 | end |
| 120 | note canonical case 06bc8b90-0c51-4c54-ac22-3ec3893a079e |
| 121 | fn tc10 to bool |
| 122 | ret eq largestproduct part z20 0 0 0 1 |
| 123 | end |
| 124 | note canonical case 3ec0d92e-f2e2-4090-a380-70afee02f4c0 |
| 125 | fn tc11 to bool |
| 126 | ret eq largestproduct s22 0 1 |
| 127 | end |
| 128 | note canonical case 6cf66098-a6af-4223-aab1-26aeeefc7402 |
| 129 | fn tc12 to bool |
| 130 | ret eq largestproduct part z24 0 0 1 -2 |
| 131 | end |
| 132 | note canonical case 7a38f2d6-3c35-45f6-8d6f-12e6e32d4d74 |
| 133 | fn tc13 to bool |
| 134 | ret eq largestproduct s26 2 -3 |
| 135 | end |
| 136 | note canonical case c859f34a-9bfe-4897-9c2f-6d7f8598e7f0 |
| 137 | fn tc14 to bool |
| 138 | ret eq largestproduct s28 -1 -1 |
| 139 | end |
| 140 | fn main to int |
| 141 | tcheck tc0 c1 |
| 142 | tcheck tc1 c3 |
| 143 | tcheck tc2 c5 |
| 144 | tcheck tc3 c7 |
| 145 | tcheck tc4 c9 |
| 146 | tcheck tc5 c11 |
| 147 | tcheck tc6 c13 |
| 148 | tcheck tc7 c15 |
| 149 | tcheck tc8 c17 |
| 150 | tcheck tc9 c19 |
| 151 | tcheck tc10 c21 |
| 152 | tcheck tc11 c23 |
| 153 | tcheck tc12 c25 |
| 154 | tcheck tc13 c27 |
| 155 | tcheck tc14 c29 |
| 156 | ret int get tfails 0 |
| 157 | end |