nish 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/AI.md +29 -18
- package/package.json +5 -5
- package/runtime/nish.h +1 -0
- package/runtime/runtime-bytes.c +167 -7
- package/runtime/runtime-net.c +69 -25
- package/runtime/runtime-uring.c +111 -62
- package/runtime/sqlite/nish-sqlite.c +166 -39
- package/std/README.md +2 -2
- package/std/base64.ts +28 -30
- package/std/crypto/aes.ts +81 -45
- package/std/crypto/bcrypt-batch.ts +23 -4
- package/std/crypto/bcrypt.ts +36 -11
- package/std/crypto/chacha20poly1305.ts +93 -52
- package/std/crypto/x25519.ts +7 -4
- package/std/host/game.ts +52 -20
- package/std/host/ring.ts +115 -31
- package/std/host/text.ts +9 -3
- package/std/json.ts +83 -0
- package/std/math.ts +161 -131
- package/std/net/http1-server.ts +36 -11
- package/std/net/prefork.ts +1 -2
- package/std/net/static.ts +7 -2
- package/std/random.ts +34 -51
- package/std/raster.ts +360 -110
- package/std/regex.ts +46 -15
- package/std/release.ts +19 -13
- package/std/sqlite.ts +380 -16
- package/std/synth.ts +11 -2
- package/std/temporal.ts +740 -363
- package/std/term-io.ts +81 -33
- package/std/term-pixels.ts +287 -112
- package/std/term-probe.ts +7 -3
- package/std/term-rate.ts +142 -66
- package/std/term.ts +782 -406
- package/std/testing.ts +14 -7
package/std/testing.ts
CHANGED
|
@@ -125,6 +125,12 @@ const testingFirstDifferentLine = (actual: string[], expected: string[]): i32 =>
|
|
|
125
125
|
return actualLength === expectedLength ? -1 : shorter
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
/** The largest `i32`, where a tally stops rather than wraps. */
|
|
129
|
+
const TESTING_I32_MAX: i32 = 2147483647
|
|
130
|
+
|
|
131
|
+
/** `n` plus one, or `n` when it is already the largest `i32`. */
|
|
132
|
+
const testingCount = (n: i32): i32 => (n < TESTING_I32_MAX ? n + 1 : n)
|
|
133
|
+
|
|
128
134
|
/**
|
|
129
135
|
* One run of checks, and the tally it reports.
|
|
130
136
|
*
|
|
@@ -137,7 +143,8 @@ export class Suite {
|
|
|
137
143
|
private name: string
|
|
138
144
|
// These three have initializers because the constructor does not assign them,
|
|
139
145
|
// and every field holds a value once it returns. `name` does not, and an
|
|
140
|
-
// initializer there would only be a store the constructor overwrites.
|
|
146
|
+
// initializer there would only be a store the constructor overwrites. Each
|
|
147
|
+
// stops at the largest `i32` (`testingCount`).
|
|
141
148
|
private passed: i32 = 0
|
|
142
149
|
private failed: i32 = 0
|
|
143
150
|
private skipped: i32 = 0
|
|
@@ -167,7 +174,7 @@ export class Suite {
|
|
|
167
174
|
* @returns `true`, so a check of its own shape can answer what this answers.
|
|
168
175
|
*/
|
|
169
176
|
pass(name: string): boolean {
|
|
170
|
-
this.passed
|
|
177
|
+
this.passed = testingCount(this.passed)
|
|
171
178
|
console.log(`PASS ${name}`)
|
|
172
179
|
return true
|
|
173
180
|
}
|
|
@@ -182,7 +189,7 @@ export class Suite {
|
|
|
182
189
|
* @returns `false`, so a check of its own shape can answer what this answers.
|
|
183
190
|
*/
|
|
184
191
|
fail(name: string, detail: string): boolean {
|
|
185
|
-
this.failed
|
|
192
|
+
this.failed = testingCount(this.failed)
|
|
186
193
|
this.failures.push(name)
|
|
187
194
|
console.log(`FAIL ${name}`)
|
|
188
195
|
if (toI32(detail.length) > 0) {
|
|
@@ -200,7 +207,7 @@ export class Suite {
|
|
|
200
207
|
* @param reason why it did not run, printed in parentheses after the name.
|
|
201
208
|
*/
|
|
202
209
|
skip(name: string, reason: string): void {
|
|
203
|
-
this.skipped
|
|
210
|
+
this.skipped = testingCount(this.skipped)
|
|
204
211
|
console.log(`SKIP ${name} (${reason})`)
|
|
205
212
|
}
|
|
206
213
|
|
|
@@ -378,9 +385,9 @@ export class Suite {
|
|
|
378
385
|
if (toI32(needle.length) === 0) {
|
|
379
386
|
continue
|
|
380
387
|
}
|
|
381
|
-
looked
|
|
388
|
+
looked = testingCount(looked)
|
|
382
389
|
if (toI32(haystack.indexOf(needle)) < 0) {
|
|
383
|
-
missing
|
|
390
|
+
missing = testingCount(missing)
|
|
384
391
|
if (toI32(first.length) === 0) {
|
|
385
392
|
first = needle
|
|
386
393
|
}
|
|
@@ -421,7 +428,7 @@ export class Suite {
|
|
|
421
428
|
}
|
|
422
429
|
const wanted = at < toI32(expected.length) ? `"${expected[at]}"` : "<end of input>"
|
|
423
430
|
const saw = at < toI32(actual.length) ? `"${actual[at]}"` : "<end of input>"
|
|
424
|
-
return this.fail(name, `line ${at + 1}: expected ${wanted}, got ${saw}`)
|
|
431
|
+
return this.fail(name, `line ${toI64(at) + 1}: expected ${wanted}, got ${saw}`)
|
|
425
432
|
}
|
|
426
433
|
|
|
427
434
|
/**
|