2019-10-12 05:57:13 +08:00
|
|
|
// Flags: --experimental-wasm-modules
|
2019-04-30 00:27:20 +08:00
|
|
|
import '../common/index.mjs';
|
2019-11-24 12:40:40 +08:00
|
|
|
import { path } from '../common/fixtures.mjs';
|
2019-04-30 00:27:20 +08:00
|
|
|
import { add, addImported } from '../fixtures/es-modules/simple.wasm';
|
|
|
|
import { state } from '../fixtures/es-modules/wasm-dep.mjs';
|
2019-11-24 12:40:40 +08:00
|
|
|
import { strictEqual, ok } from 'assert';
|
|
|
|
import { spawn } from 'child_process';
|
2019-04-30 00:27:20 +08:00
|
|
|
|
|
|
|
strictEqual(state, 'WASM Start Executed');
|
|
|
|
|
|
|
|
strictEqual(add(10, 20), 30);
|
|
|
|
|
|
|
|
strictEqual(addImported(0), 42);
|
|
|
|
|
|
|
|
strictEqual(state, 'WASM JS Function Executed');
|
|
|
|
|
|
|
|
strictEqual(addImported(1), 43);
|
2019-11-24 12:40:40 +08:00
|
|
|
|
|
|
|
// Test warning message
|
|
|
|
const child = spawn(process.execPath, [
|
|
|
|
'--experimental-wasm-modules',
|
2021-03-26 23:51:08 +08:00
|
|
|
path('/es-modules/wasm-modules.mjs'),
|
2019-11-24 12:40:40 +08:00
|
|
|
]);
|
|
|
|
|
|
|
|
let stderr = '';
|
|
|
|
child.stderr.setEncoding('utf8');
|
|
|
|
child.stderr.on('data', (data) => {
|
|
|
|
stderr += data;
|
|
|
|
});
|
|
|
|
child.on('close', (code, signal) => {
|
|
|
|
strictEqual(code, 0);
|
|
|
|
strictEqual(signal, null);
|
|
|
|
ok(stderr.toString().includes(
|
2021-11-10 12:39:29 +08:00
|
|
|
'ExperimentalWarning: Importing WebAssembly modules is ' +
|
2019-11-24 12:40:40 +08:00
|
|
|
'an experimental feature. This feature could change at any time'
|
|
|
|
));
|
|
|
|
});
|