Skip to content
Permalink
Browse files

test: clean up wasm fixtures

PR-URL: #25360
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
devsnek authored and addaleax committed Jan 6, 2019
1 parent c1aa5f0 commit c826af781f635baa70d58ae5fa58b806f8661b99
Binary file not shown.
@@ -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))
)
Binary file not shown.
@@ -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 -50 Bytes test/fixtures/test.wasm
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

@@ -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);

0 comments on commit c826af7

Please sign in to comment.
You can’t perform that action at this time.