forked from EmNudge/watlings
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path007_conditionals.test.js
More file actions
37 lines (32 loc) · 1 KB
/
007_conditionals.test.js
File metadata and controls
37 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { instantiate } from "./utils/instantiate.mjs";
import {
assert,
matchObjectShape,
setSuccess,
test,
} from "./utils/test-runner.mjs";
import { getWasm } from "./utils/getWasm.mjs";
const wasmBytes = await getWasm(import.meta.url);
setSuccess("Congrats! Continue onto 008_loops.wat");
test("exports isEven and getNum", async () => {
const exports = await instantiate(wasmBytes);
assert(
matchObjectShape(exports, {
isEven: Function,
getNum: Function,
}),
"does not export all of: isEven and getNum"
);
});
test("isEven works", async () => {
const exports = await instantiate(wasmBytes);
const { isEven } = exports;
assert(isEven(42) === 1, "isEven is not returning 1");
assert(isEven(43) === 0, "isEven is not returning 0");
});
test("getNum works", async () => {
const exports = await instantiate(wasmBytes);
const { getNum } = exports;
assert(getNum(42) === 42, "getNum is not returning 42");
assert(getNum(43) === 100, "getNum is not returning 100");
});