From 1030cae45574aba50cfebe44bfa3c4fd17330f3f Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 22 Nov 2024 10:59:19 -0500 Subject: [PATCH] chore(check): add test for Wasm memory and table (#26996) --- .../wasm_module/table_global_memory/__test__.jsonc | 13 +++++++++++-- .../run/wasm_module/table_global_memory/check.out | 14 ++++++++++++++ .../run/wasm_module/table_global_memory/check.ts | 4 ++++ .../run/wasm_module/table_global_memory/main.out | 1 - 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 tests/specs/run/wasm_module/table_global_memory/check.out create mode 100644 tests/specs/run/wasm_module/table_global_memory/check.ts diff --git a/tests/specs/run/wasm_module/table_global_memory/__test__.jsonc b/tests/specs/run/wasm_module/table_global_memory/__test__.jsonc index 1dbb89a020..55f16ed0c2 100644 --- a/tests/specs/run/wasm_module/table_global_memory/__test__.jsonc +++ b/tests/specs/run/wasm_module/table_global_memory/__test__.jsonc @@ -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 + } + } } diff --git a/tests/specs/run/wasm_module/table_global_memory/check.out b/tests/specs/run/wasm_module/table_global_memory/check.out new file mode 100644 index 0000000000..e335a7c907 --- /dev/null +++ b/tests/specs/run/wasm_module/table_global_memory/check.out @@ -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. diff --git a/tests/specs/run/wasm_module/table_global_memory/check.ts b/tests/specs/run/wasm_module/table_global_memory/check.ts new file mode 100644 index 0000000000..c0e43ed2aa --- /dev/null +++ b/tests/specs/run/wasm_module/table_global_memory/check.ts @@ -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); diff --git a/tests/specs/run/wasm_module/table_global_memory/main.out b/tests/specs/run/wasm_module/table_global_memory/main.out index 81a5b4b47c..c095b0dd92 100644 --- a/tests/specs/run/wasm_module/table_global_memory/main.out +++ b/tests/specs/run/wasm_module/table_global_memory/main.out @@ -1,4 +1,3 @@ -Check [WILDCARD] [Module: null prototype] { func: [Function: 0], global: Global [WebAssembly.Global] {},