@fraczak/k 7.0.0 → 7.0.1

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.
@@ -714,6 +714,21 @@ if (chromiumBin) {
714
714
  "Explicit :codec load of uploaded file must succeed"
715
715
  );
716
716
 
717
+ // Test Wasm engine with polymorphic/open list len
718
+ const wasmLenCheck = await evaluateAsync(`(async () => {
719
+ await window.kRepl.executeCommand(":engine wasm");
720
+ await window.kRepl.executeCommand(":codec load int.mjs");
721
+ await window.kRepl.executeCommand("len = {()list,0 int len} len_; len_ = ?X <{.list/nil if, .len then} .then, {.list/cons.cdr list, .len inc len} ?X len_ >;");
722
+ await window.kRepl.executeCommand(":input int.mjs [1,2,3]");
723
+ await window.kRepl.executeCommand("len");
724
+ const lines = Array.from(document.querySelectorAll(".entry-line")).map(el => el.textContent);
725
+ return lines[lines.length - 1];
726
+ })()`);
727
+ assert(
728
+ wasmLenCheck.includes("int.mjs: 3"),
729
+ `Expected 'int.mjs: 3' from wasm execution, got: ${wasmLenCheck}`
730
+ );
731
+
717
732
  ws.close();
718
733
  console.log(" Browser execution verified successfully!");
719
734
  } finally {
@@ -509,6 +509,16 @@ output = await evaluateInput("{ 10 int x, 5 int y } plus", jsState);
509
509
  assert.match(output[0], /^\{\}\|_\|1\|1\|1\|1\|\+/);
510
510
  assert.match(output[1], /\(js\)/);
511
511
 
512
+ // Verify open product projection in wasm engine
513
+ const wasmListState = createState({ engine: "wasm" });
514
+ await evaluateInput(":load Examples/arithmetics.k", wasmListState);
515
+ await evaluateInput(":codec load codecs/int.mjs", wasmListState);
516
+ await evaluateInput("len = {()list,0 int len} len_; len_ = ?X <{.list/nil if, .len then} .then, {.list/cons.cdr list, .len inc len} ?X len_ >;", wasmListState);
517
+ await evaluateInput(":input int.mjs [3,3,3]", wasmListState);
518
+ output = await evaluateInput("len", wasmListState);
519
+ assert.match(output[0], /int\.mjs:\s*3/);
520
+ assert.match(output[1], /\(wasm\)/);
521
+
512
522
  fs.rmSync(tmpDir, { recursive: true, force: true });
513
523
  fs.rmSync(symlinkPath, { force: true });
514
524
  console.log("OK");