mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test: clean up wasm fixtures
PR-URL: https://github.com/nodejs/node/pull/25360 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
9987f1abb9
commit
0c8dedd103
BIN
test/fixtures/shared-memory.wasm
vendored
Normal file
BIN
test/fixtures/shared-memory.wasm
vendored
Normal file
Binary file not shown.
8
test/fixtures/shared-memory.wat
vendored
Normal file
8
test/fixtures/shared-memory.wat
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
;; Compiled using the WebAssembly Tootkit (https://github.com/WebAssembly/wabt)
|
||||
;; $ wat2wasm --enable-threads shared-memory.wat -o shared-memory.wasm
|
||||
|
||||
(module
|
||||
;; Create shared memory with initial 1 page (64KiB) and max 1 page
|
||||
(memory $mem 1 1 shared)
|
||||
(export "memory" (memory $mem))
|
||||
)
|
BIN
test/fixtures/simple.wasm
vendored
Normal file
BIN
test/fixtures/simple.wasm
vendored
Normal file
Binary file not shown.
11
test/fixtures/simple.wat
vendored
Normal file
11
test/fixtures/simple.wat
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
;; Compiled using the WebAssembly Tootkit (https://github.com/WebAssembly/wabt)
|
||||
;; $ wat2wasm simple.wat -o simple.wasm
|
||||
|
||||
(module
|
||||
(func $add (param $a i32) (param $b i32) (result i32)
|
||||
;; return $a + $b
|
||||
(i32.add (get_local $a) (get_local $b))
|
||||
)
|
||||
|
||||
(export "add" (func $add))
|
||||
)
|
BIN
test/fixtures/test.wasm
vendored
BIN
test/fixtures/test.wasm
vendored
Binary file not shown.
10
test/fixtures/test.wat
vendored
10
test/fixtures/test.wat
vendored
@ -1,10 +0,0 @@
|
||||
;; Compiled using the WebAssembly Tootkit (https://github.com/WebAssembly/wabt)
|
||||
;; $ wat2wasm test.wat -o test.wasm
|
||||
(module
|
||||
(func $add (export "add") (param $first i32) (param $second i32) (result i32)
|
||||
get_local $first
|
||||
get_local $second
|
||||
(i32.add)
|
||||
)
|
||||
(export "addTwo" (func $add))
|
||||
)
|
BIN
test/fixtures/wasm-threads-shared-memory.wasm
vendored
BIN
test/fixtures/wasm-threads-shared-memory.wasm
vendored
Binary file not shown.
4
test/fixtures/wasm-threads-shared-memory.wat
vendored
4
test/fixtures/wasm-threads-shared-memory.wat
vendored
@ -1,4 +0,0 @@
|
||||
(module
|
||||
(memory $mem 1 2 shared)
|
||||
(export "memory" (memory $mem))
|
||||
)
|
@ -9,7 +9,7 @@ const { internalBinding } = require('internal/test/binding');
|
||||
const { JSStream } = internalBinding('js_stream');
|
||||
|
||||
const external = (new JSStream())._externalStream;
|
||||
const wasmBuffer = fixtures.readSync('test.wasm');
|
||||
const wasmBuffer = fixtures.readSync('simple.wasm');
|
||||
|
||||
for (const [ value, _method ] of [
|
||||
[ external, 'isExternal' ],
|
||||
|
@ -12,7 +12,7 @@ const os = require('os');
|
||||
const circular = {};
|
||||
circular.circular = circular;
|
||||
|
||||
const wasmModule = new WebAssembly.Module(fixtures.readSync('test.wasm'));
|
||||
const wasmModule = new WebAssembly.Module(fixtures.readSync('simple.wasm'));
|
||||
|
||||
const objects = [
|
||||
{ foo: 'bar' },
|
||||
@ -238,5 +238,5 @@ const deserializerTypeError =
|
||||
{
|
||||
const deserializedWasmModule = v8.deserialize(v8.serialize(wasmModule));
|
||||
const instance = new WebAssembly.Instance(deserializedWasmModule);
|
||||
assert.strictEqual(instance.exports.addTwo(10, 20), 30);
|
||||
assert.strictEqual(instance.exports.add(10, 20), 30);
|
||||
}
|
||||
|
@ -4,14 +4,14 @@ require('../common');
|
||||
const assert = require('assert');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const buffer = fixtures.readSync('test.wasm');
|
||||
const buffer = fixtures.readSync('simple.wasm');
|
||||
|
||||
assert.ok(WebAssembly.validate(buffer), 'Buffer should be valid WebAssembly');
|
||||
|
||||
WebAssembly.instantiate(buffer, {}).then((results) => {
|
||||
// Exported function should add two numbers.
|
||||
assert.strictEqual(
|
||||
results.instance.exports.addTwo(10, 20),
|
||||
results.instance.exports.add(10, 20),
|
||||
30
|
||||
);
|
||||
});
|
||||
|
@ -5,13 +5,13 @@ const assert = require('assert');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const { Worker } = require('worker_threads');
|
||||
const wasmModule = new WebAssembly.Module(fixtures.readSync('test.wasm'));
|
||||
const wasmModule = new WebAssembly.Module(fixtures.readSync('simple.wasm'));
|
||||
|
||||
const worker = new Worker(`
|
||||
const { parentPort } = require('worker_threads');
|
||||
parentPort.once('message', ({ wasmModule }) => {
|
||||
const instance = new WebAssembly.Instance(wasmModule);
|
||||
parentPort.postMessage(instance.exports.addTwo(10, 20));
|
||||
parentPort.postMessage(instance.exports.add(10, 20));
|
||||
});
|
||||
`, { eval: true });
|
||||
|
||||
|
@ -8,7 +8,7 @@ const { MessageChannel, Worker } = require('worker_threads');
|
||||
// through MessageChannels (without crashing).
|
||||
|
||||
const fixtures = require('../common/fixtures');
|
||||
const wasmSource = fixtures.readSync('wasm-threads-shared-memory.wasm');
|
||||
const wasmSource = fixtures.readSync('shared-memory.wasm');
|
||||
const wasmModule = new WebAssembly.Module(wasmSource);
|
||||
const instance = new WebAssembly.Instance(wasmModule);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user