@fraczak/k 7.1.0 → 7.2.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/CHANGELOG.md +33 -0
- package/DOCS/CODECS.md +37 -2
- package/DOCS/CODEC_ARCHITECTURE.md +12 -5
- package/DOCS/REPL.md +11 -3
- package/DOCS/WEB_REPL_REQUIREMENTS.md +1 -1
- package/README.md +2 -1
- package/Value.mjs +28 -3
- package/backend-api.mjs +5 -1
- package/browser/tree-view.mjs +47 -8
- package/browser/vfs-data.mjs +6 -5
- package/codecs/README.md +1 -0
- package/codecs/djson.mjs +270 -0
- package/codecs/int.mjs +2 -1
- package/codecs/json.mjs +7 -2
- package/codecs/k-parse.mjs +7 -1
- package/codecs/k-print.mjs +4 -0
- package/codecs/runtime/codec-sdk.mjs +16 -2
- package/codecs/runtime/pattern-json.mjs +80 -1
- package/codecs/runtime/prefix-codec.mjs +629 -67
- package/codecs/runtime/show-value.mjs +93 -51
- package/codecs/runtime/unicode-string.mjs +29 -6
- package/codecs/show.mjs +4 -0
- package/codecs/utf16.mjs +2 -1
- package/package.json +2 -1
- package/repl.mjs +57 -6
- package/scripts/build-repl-html.mjs +8 -1
- package/tests/test-codecs.mjs +168 -0
- package/tests/test-repl-html.mjs +1 -0
- package/tests/test-repl.mjs +33 -0
package/tests/test-repl.mjs
CHANGED
|
@@ -226,6 +226,18 @@ output = await evaluateInput(':input json.mjs {"left":true,"right":false}', json
|
|
|
226
226
|
assert.match(output[0], /json\.mjs: \{"left":true,"right":false\}/);
|
|
227
227
|
assert.equal(promptForState(jsonState), "> ");
|
|
228
228
|
|
|
229
|
+
// Test djson.mjs in repl
|
|
230
|
+
const djsonState = createState();
|
|
231
|
+
output = await evaluateInput(":codec load ./codecs/djson.mjs", djsonState);
|
|
232
|
+
assert.match(output[0], /^loaded codec djson\.mjs/);
|
|
233
|
+
completions = completeInput(":input dj", djsonState)[0];
|
|
234
|
+
assert(completions.includes(":input djson.mjs"));
|
|
235
|
+
output = await evaluateInput(
|
|
236
|
+
':input djson.mjs {"msg":"hello","values":[1,2]}',
|
|
237
|
+
djsonState
|
|
238
|
+
);
|
|
239
|
+
assert.match(output[0], /djson\.mjs: \{"msg":"hello","values":\[1,2\]\}/);
|
|
240
|
+
|
|
229
241
|
const replPath = fileURLToPath(new URL("../repl.mjs", import.meta.url));
|
|
230
242
|
try {
|
|
231
243
|
fs.rmSync(symlinkPath, { force: true });
|
|
@@ -548,6 +560,27 @@ output = await evaluateInput("len", wasmListState);
|
|
|
548
560
|
assert.match(output[0], /int\.mjs:\s*3/);
|
|
549
561
|
assert.match(output[1], /\(wasm\)/);
|
|
550
562
|
|
|
563
|
+
// Verify :limit command and bounded printing
|
|
564
|
+
const limitState = createState({ engine: "wasm" });
|
|
565
|
+
output = await evaluateInput(":limit", limitState);
|
|
566
|
+
assert.equal(output[0], "Current output limit: none");
|
|
567
|
+
|
|
568
|
+
output = await evaluateInput(":limit 40", limitState);
|
|
569
|
+
assert.equal(output[0], "output limit set to 40");
|
|
570
|
+
|
|
571
|
+
output = await evaluateInput(":limit", limitState);
|
|
572
|
+
assert.equal(output[0], "Current output limit: 40");
|
|
573
|
+
|
|
574
|
+
output = await evaluateInput(":load Examples/arithmetics.k", limitState);
|
|
575
|
+
output = await evaluateInput("{ 10 int x, 5 int y } plus", limitState);
|
|
576
|
+
assert(output[0].includes("..."));
|
|
577
|
+
assert(output[0].length <= 80);
|
|
578
|
+
|
|
579
|
+
output = await evaluateInput(":limit none", limitState);
|
|
580
|
+
assert.equal(output[0], "output limit disabled");
|
|
581
|
+
output = await evaluateInput(":limit", limitState);
|
|
582
|
+
assert.equal(output[0], "Current output limit: none");
|
|
583
|
+
|
|
551
584
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
552
585
|
fs.rmSync(symlinkPath, { force: true });
|
|
553
586
|
console.log("OK");
|