@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.
- package/CHANGELOG.md +14 -0
- package/backend-api.mjs +9 -1
- package/backends/llvm/scripts/run-tests.mjs +5 -0
- package/backends/llvm/src/kvm2llvm.mjs +2 -1
- package/backends/llvm/src/llvm.mjs +18 -25
- package/backends/llvm/tests/integration.sh +2 -2
- package/backends/llvm/tests/test-llvm.mjs +3 -3
- package/backends/llvm/tests/test-open-product-misalignment.mjs +140 -0
- package/backends/wasm/demo_ieee.mjs +2 -3
- package/backends/wasm/runtime.wat +157 -5
- package/backends/wasm/src/kvm2wasm.mjs +57 -34
- package/backends/wasm/src/wasm.mjs +38 -17
- package/backends/wasm/tests/perf-support.mjs +4 -4
- package/backends/wasm/tests/test-wasm.mjs +13 -14
- package/browser/vfs-data.mjs +1 -1
- package/kir.mjs +213 -17
- package/package.json +1 -1
- package/tests/test-repl-html.mjs +15 -0
- package/tests/test-repl.mjs +10 -0
package/tests/test-repl-html.mjs
CHANGED
|
@@ -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 {
|
package/tests/test-repl.mjs
CHANGED
|
@@ -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");
|