@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.
@@ -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");