Skip to content

Commit

Permalink
chore(check): add test for Wasm memory and table (#26996)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored and bartlomieju committed Nov 28, 2024
1 parent 9236786 commit 1030cae
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
13 changes: 11 additions & 2 deletions tests/specs/run/wasm_module/table_global_memory/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"args": "run --check main.js",
"output": "main.out"
"tests": {
"run": {
"args": "run main.js",
"output": "main.out"
},
"check": {
"args": "check check.ts",
"output": "check.out",
"exitCode": 1
}
}
}
14 changes: 14 additions & 0 deletions tests/specs/run/wasm_module/table_global_memory/check.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Check file:///[WILDLINE]/check.ts
error: TS2322 [ERROR]: Type 'Function | null' is not assignable to type 'number'.
Type 'null' is not assignable to type 'number'.
const value1: number = table.get(0);
~~~~~~
at file:///[WILDLINE]/check.ts:2:7

TS2322 [ERROR]: Type 'ArrayBuffer | SharedArrayBuffer' is not assignable to type 'number'.
Type 'ArrayBuffer' is not assignable to type 'number'.
const value2: number = memory.buffer;
~~~~~~
at file:///[WILDLINE]/check.ts:3:7

Found 2 errors.
4 changes: 4 additions & 0 deletions tests/specs/run/wasm_module/table_global_memory/check.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { memory, table } from "./mod.wasm";
const value1: number = table.get(0);
const value2: number = memory.buffer;
console.log(value1, value2);
1 change: 0 additions & 1 deletion tests/specs/run/wasm_module/table_global_memory/main.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Check [WILDCARD]
[Module: null prototype] {
func: [Function: 0],
global: Global [WebAssembly.Global] {},
Expand Down

0 comments on commit 1030cae

Please sign in to comment.