Skip to content

Commit 7f31fcf

Browse files
test(jco): impove fixed length list test
While fixed length list are under test in other areas of the codebase, the happy-path non-async usage test was underspecified. This commit improves the fixed length list test which was testing compilation but *not* functionality of the added fixed length list feature.
1 parent c87f1cd commit 7f31fcf

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
import { join } from "node:path";
22

3-
import { suite, test } from "vitest";
3+
import { suite, test, assert } from "vitest";
44

55
import { setupAsyncTest } from "../helpers.js";
66
import { LOCAL_TEST_COMPONENTS_DIR } from "../common.js";
77
import { WASIShim } from "@bytecodealliance/preview2-shim/instantiation";
88

99
suite("fixed length lists", () => {
1010
test("transpile", async () => {
11-
const { cleanup } = await setupAsyncTest({
11+
const { cleanup, instance } = await setupAsyncTest({
1212
component: {
1313
path: join(LOCAL_TEST_COMPONENTS_DIR, "fixed-length-lists.wasm"),
1414
imports: new WASIShim().getImportObject(),
1515
},
16-
jco: {
17-
transpile: {},
18-
},
16+
// jco: {
17+
// transpile: {
18+
// extraArgs: {
19+
// minify: false,
20+
// }
21+
// },
22+
// },
1923
});
2024

25+
const input = [...new Array(17)].map(() => Math.random() <= 0.5);
26+
const output = instance["jco:test-components/fixed-length-lists-fn"].takesReturnsFixed(input);
27+
assert.lengthOf(output, 32);
28+
assert.deepEqual(output, input.map(Number).concat([...new Array(32 - 17)].map(() => 0)));
29+
2130
await cleanup();
2231
});
2332
});

0 commit comments

Comments
 (0)