Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1068)

Unified Diff: test/mjsunit/wasm/js-api.js

Issue 2644993002: [wasm] WebAssembly.instantiate has a pair-returning overload (Closed)
Patch Set: feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-js.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/js-api.js
diff --git a/test/mjsunit/wasm/js-api.js b/test/mjsunit/wasm/js-api.js
index 403bfb4370a0631893f05d5578aaf8ae9137f913..9279234761767f576de59fb0fa21c09acdbb7c23 100644
--- a/test/mjsunit/wasm/js-api.js
+++ b/test/mjsunit/wasm/js-api.js
@@ -64,9 +64,9 @@ let moduleBinaryWithMemSectionAndMemImport = (() => {
// 'WebAssembly' data property on global object
let wasmDesc = Object.getOwnPropertyDescriptor(this, 'WebAssembly');
assertEq(typeof wasmDesc.value, "object");
-assertEq(wasmDesc.writable, true);
-assertEq(wasmDesc.enumerable, false);
-assertEq(wasmDesc.configurable, true);
+assertTrue(wasmDesc.writable);
+assertFalse(wasmDesc.enumerable);
+assertTrue(wasmDesc.configurable);
// 'WebAssembly' object
assertEq(WebAssembly, wasmDesc.value);
@@ -75,60 +75,60 @@ assertEq(String(WebAssembly), "[object WebAssembly]");
// 'WebAssembly.CompileError'
let compileErrorDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'CompileError');
assertEq(typeof compileErrorDesc.value, "function");
-assertEq(compileErrorDesc.writable, true);
-assertEq(compileErrorDesc.enumerable, false);
-assertEq(compileErrorDesc.configurable, true);
+assertTrue(compileErrorDesc.writable);
+assertFalse(compileErrorDesc.enumerable);
+assertTrue(compileErrorDesc.configurable);
let CompileError = WebAssembly.CompileError;
assertEq(CompileError, compileErrorDesc.value);
assertEq(CompileError.length, 1);
assertEq(CompileError.name, "CompileError");
let compileError = new CompileError;
-assertEq(compileError instanceof CompileError, true);
-assertEq(compileError instanceof Error, true);
-assertEq(compileError instanceof TypeError, false);
+assertTrue(compileError instanceof CompileError);
+assertTrue(compileError instanceof Error);
+assertFalse(compileError instanceof TypeError);
assertEq(compileError.message, "");
assertEq(new CompileError("hi").message, "hi");
// 'WebAssembly.RuntimeError'
let runtimeErrorDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'RuntimeError');
assertEq(typeof runtimeErrorDesc.value, "function");
-assertEq(runtimeErrorDesc.writable, true);
-assertEq(runtimeErrorDesc.enumerable, false);
-assertEq(runtimeErrorDesc.configurable, true);
+assertTrue(runtimeErrorDesc.writable);
+assertFalse(runtimeErrorDesc.enumerable);
+assertTrue(runtimeErrorDesc.configurable);
let RuntimeError = WebAssembly.RuntimeError;
assertEq(RuntimeError, runtimeErrorDesc.value);
assertEq(RuntimeError.length, 1);
assertEq(RuntimeError.name, "RuntimeError");
let runtimeError = new RuntimeError;
-assertEq(runtimeError instanceof RuntimeError, true);
-assertEq(runtimeError instanceof Error, true);
-assertEq(runtimeError instanceof TypeError, false);
+assertTrue(runtimeError instanceof RuntimeError);
+assertTrue(runtimeError instanceof Error);
+assertFalse(runtimeError instanceof TypeError);
assertEq(runtimeError.message, "");
assertEq(new RuntimeError("hi").message, "hi");
// 'WebAssembly.LinkError'
let linkErrorDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'LinkError');
assertEq(typeof linkErrorDesc.value, "function");
-assertEq(linkErrorDesc.writable, true);
-assertEq(linkErrorDesc.enumerable, false);
-assertEq(linkErrorDesc.configurable, true);
+assertTrue(linkErrorDesc.writable);
+assertFalse(linkErrorDesc.enumerable);
+assertTrue(linkErrorDesc.configurable);
let LinkError = WebAssembly.LinkError;
assertEq(LinkError, linkErrorDesc.value);
assertEq(LinkError.length, 1);
assertEq(LinkError.name, "LinkError");
let linkError = new LinkError;
-assertEq(linkError instanceof LinkError, true);
-assertEq(linkError instanceof Error, true);
-assertEq(linkError instanceof TypeError, false);
+assertTrue(linkError instanceof LinkError);
+assertTrue(linkError instanceof Error);
+assertFalse(linkError instanceof TypeError);
assertEq(linkError.message, "");
assertEq(new LinkError("hi").message, "hi");
// 'WebAssembly.Module' data property
let moduleDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Module');
assertEq(typeof moduleDesc.value, "function");
-assertEq(moduleDesc.writable, true);
-assertEq(moduleDesc.enumerable, false);
-assertEq(moduleDesc.configurable, true);
+assertTrue(moduleDesc.writable);
+assertFalse(moduleDesc.enumerable);
+assertTrue(moduleDesc.configurable);
// 'WebAssembly.Module' constructor function
let Module = WebAssembly.Module;
@@ -142,15 +142,15 @@ assertErrorMessage(() => new Module(1), TypeError, "first argument must be an Ar
assertErrorMessage(() => new Module({}), TypeError, "first argument must be an ArrayBuffer or typed array object");
assertErrorMessage(() => new Module(new Uint8Array()), CompileError, /failed to match magic number/);
assertErrorMessage(() => new Module(new ArrayBuffer()), CompileError, /failed to match magic number/);
-assertEq(new Module(emptyModuleBinary) instanceof Module, true);
-assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true);
+assertTrue(new Module(emptyModuleBinary) instanceof Module);
+assertTrue(new Module(emptyModuleBinary.buffer) instanceof Module);
// 'WebAssembly.Module.prototype' data property
let moduleProtoDesc = Object.getOwnPropertyDescriptor(Module, 'prototype');
assertEq(typeof moduleProtoDesc.value, "object");
-assertEq(moduleProtoDesc.writable, false);
-assertEq(moduleProtoDesc.enumerable, false);
-assertEq(moduleProtoDesc.configurable, false);
+assertFalse(moduleProtoDesc.writable);
+assertFalse(moduleProtoDesc.enumerable);
+assertFalse(moduleProtoDesc.configurable);
// 'WebAssembly.Module.prototype' object
let moduleProto = Module.prototype;
@@ -169,9 +169,9 @@ assertEq(Object.getPrototypeOf(emptyModule), moduleProto);
// 'WebAssembly.Module.imports' data property
let moduleImportsDesc = Object.getOwnPropertyDescriptor(Module, 'imports');
assertEq(typeof moduleImportsDesc.value, "function");
-assertEq(moduleImportsDesc.writable, true);
-assertEq(moduleImportsDesc.enumerable, false);
-assertEq(moduleImportsDesc.configurable, true);
+assertTrue(moduleImportsDesc.writable);
+assertFalse(moduleImportsDesc.enumerable);
+assertTrue(moduleImportsDesc.configurable);
// 'WebAssembly.Module.imports' method
let moduleImports = moduleImportsDesc.value;
@@ -180,7 +180,7 @@ assertErrorMessage(() => moduleImports(), TypeError, /requires more than 0 argum
assertErrorMessage(() => moduleImports(undefined), TypeError, /first argument must be a WebAssembly.Module/);
assertErrorMessage(() => moduleImports({}), TypeError, /first argument must be a WebAssembly.Module/);
var arr = moduleImports(new Module(emptyModuleBinary));
-assertEq(arr instanceof Array, true);
+assertTrue(arr instanceof Array);
assertEq(arr.length, 0);
let importingModuleBinary2 = (() => {
var text = '(module (func (import "a" "b")) (memory (import "c" "d") 1) (table (import "e" "f") 1 anyfunc) (global (import "g" "⚡") i32))'
@@ -192,7 +192,7 @@ let importingModuleBinary2 = (() => {
return new Int8Array(builder.toBuffer());
})();
var arr = moduleImports(new Module(importingModuleBinary2));
-assertEq(arr instanceof Array, true);
+assertTrue(arr instanceof Array);
assertEq(arr.length, 4);
assertEq(arr[0].kind, "function");
assertEq(arr[0].module, "a");
@@ -210,9 +210,9 @@ assertEq(arr[3].name, "x");
// 'WebAssembly.Module.exports' data property
let moduleExportsDesc = Object.getOwnPropertyDescriptor(Module, 'exports');
assertEq(typeof moduleExportsDesc.value, "function");
-assertEq(moduleExportsDesc.writable, true);
-assertEq(moduleExportsDesc.enumerable, false);
-assertEq(moduleExportsDesc.configurable, true);
+assertTrue(moduleExportsDesc.writable);
+assertFalse(moduleExportsDesc.enumerable);
+assertTrue(moduleExportsDesc.configurable);
// 'WebAssembly.Module.exports' method
let moduleExports = moduleExportsDesc.value;
@@ -221,7 +221,7 @@ assertErrorMessage(() => moduleExports(), TypeError, /requires more than 0 argum
assertErrorMessage(() => moduleExports(undefined), TypeError, /first argument must be a WebAssembly.Module/);
assertErrorMessage(() => moduleExports({}), TypeError, /first argument must be a WebAssembly.Module/);
var arr = moduleExports(emptyModule);
-assertEq(arr instanceof Array, true);
+assertTrue(arr instanceof Array);
assertEq(arr.length, 0);
let exportingModuleBinary2 = (() => {
var text =
@@ -239,7 +239,7 @@ let exportingModuleBinary2 = (() => {
return new Int8Array(builder.toBuffer());
})();
var arr = moduleExports(new Module(exportingModuleBinary2));
-assertEq(arr instanceof Array, true);
+assertTrue(arr instanceof Array);
assertEq(arr.length, 4);
assertEq(arr[0].kind, "function");
assertEq(arr[0].name, "a");
@@ -253,9 +253,9 @@ assertEq(arr[3].name, "x");
// 'WebAssembly.Instance' data property
let instanceDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Instance');
assertEq(typeof instanceDesc.value, "function");
-assertEq(instanceDesc.writable, true);
-assertEq(instanceDesc.enumerable, false);
-assertEq(instanceDesc.configurable, true);
+assertTrue(instanceDesc.writable);
+assertFalse(instanceDesc.enumerable);
+assertTrue(instanceDesc.configurable);
// 'WebAssembly.Instance' constructor function
let Instance = WebAssembly.Instance;
@@ -272,15 +272,15 @@ assertErrorMessage(() => new Instance(importingModule, undefined), TypeError, ""
assertErrorMessage(() => new Instance(importingModule, {"":{g:()=>{}}}), LinkError, "");
assertErrorMessage(() => new Instance(importingModule, {t:{f:()=>{}}}), LinkError, "");
-assertEq(new Instance(emptyModule) instanceof Instance, true);
-assertEq(new Instance(emptyModule, {}) instanceof Instance, true);
+assertTrue(new Instance(emptyModule) instanceof Instance);
+assertTrue(new Instance(emptyModule, {}) instanceof Instance);
// 'WebAssembly.Instance.prototype' data property
let instanceProtoDesc = Object.getOwnPropertyDescriptor(Instance, 'prototype');
assertEq(typeof instanceProtoDesc.value, "object");
-assertEq(instanceProtoDesc.writable, false);
-assertEq(instanceProtoDesc.enumerable, false);
-assertEq(instanceProtoDesc.configurable, false);
+assertFalse(instanceProtoDesc.writable);
+assertFalse(instanceProtoDesc.enumerable);
+assertFalse(instanceProtoDesc.configurable);
// 'WebAssembly.Instance.prototype' object
let instanceProto = Instance.prototype;
@@ -297,24 +297,24 @@ assertEq(Object.getPrototypeOf(exportingInstance), instanceProto);
// 'WebAssembly.Instance' 'exports' data property
let instanceExportsDesc = Object.getOwnPropertyDescriptor(exportingInstance, 'exports');
assertEq(typeof instanceExportsDesc.value, "object");
-assertEq(instanceExportsDesc.writable, true);
-assertEq(instanceExportsDesc.enumerable, true);
-assertEq(instanceExportsDesc.configurable, true);
+assertTrue(instanceExportsDesc.writable);
+assertTrue(instanceExportsDesc.enumerable);
+assertTrue(instanceExportsDesc.configurable);
// Exported WebAssembly functions
let f = exportingInstance.exports.f;
-assertEq(f instanceof Function, true);
+assertTrue(f instanceof Function);
assertEq(f.length, 0);
-assertEq('name' in f, true);
+assertTrue('name' in f);
assertEq(Function.prototype.call.call(f), 42);
assertErrorMessage(() => new f(), TypeError, /is not a constructor/);
// 'WebAssembly.Memory' data property
let memoryDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Memory');
assertEq(typeof memoryDesc.value, "function");
-assertEq(memoryDesc.writable, true);
-assertEq(memoryDesc.enumerable, false);
-assertEq(memoryDesc.configurable, true);
+assertTrue(memoryDesc.writable);
+assertFalse(memoryDesc.enumerable);
+assertTrue(memoryDesc.configurable);
// 'WebAssembly.Memory' constructor function
let Memory = WebAssembly.Memory;
@@ -329,15 +329,15 @@ assertErrorMessage(() => new Memory({initial:Math.pow(2,32)}), RangeError, /bad
assertErrorMessage(() => new Memory({initial:1, maximum: Math.pow(2,32)/Math.pow(2,14) }), RangeError, /bad Memory maximum size/);
assertErrorMessage(() => new Memory({initial:2, maximum:1 }), RangeError, /bad Memory maximum size/);
assertErrorMessage(() => new Memory({maximum: -1 }), RangeError, /bad Memory maximum size/);
-assertEq(new Memory({initial:1}) instanceof Memory, true);
+assertTrue(new Memory({initial: 1}) instanceof Memory);
assertEq(new Memory({initial:1.5}).buffer.byteLength, kPageSize);
// 'WebAssembly.Memory.prototype' data property
let memoryProtoDesc = Object.getOwnPropertyDescriptor(Memory, 'prototype');
assertEq(typeof memoryProtoDesc.value, "object");
-assertEq(memoryProtoDesc.writable, false);
-assertEq(memoryProtoDesc.enumerable, false);
-assertEq(memoryProtoDesc.configurable, false);
+assertFalse(memoryProtoDesc.writable);
+assertFalse(memoryProtoDesc.enumerable);
+assertFalse(memoryProtoDesc.configurable);
// 'WebAssembly.Memory.prototype' object
let memoryProto = Memory.prototype;
@@ -355,21 +355,21 @@ assertEq(Object.getPrototypeOf(mem1), memoryProto);
let bufferDesc = Object.getOwnPropertyDescriptor(memoryProto, 'buffer');
assertEq(typeof bufferDesc.get, "function");
assertEq(bufferDesc.set, undefined);
-assertEq(bufferDesc.enumerable, false);
-assertEq(bufferDesc.configurable, true);
+assertFalse(bufferDesc.enumerable);
+assertTrue(bufferDesc.configurable);
// 'WebAssembly.Memory.prototype.buffer' getter
let bufferGetter = bufferDesc.get;
assertErrorMessage(() => bufferGetter.call(), TypeError, /called on incompatible undefined/);
assertErrorMessage(() => bufferGetter.call({}), TypeError, /called on incompatible Object/);
-assertEq(bufferGetter.call(mem1) instanceof ArrayBuffer, true);
+assertTrue(bufferGetter.call(mem1) instanceof ArrayBuffer);
assertEq(bufferGetter.call(mem1).byteLength, kPageSize);
// 'WebAssembly.Memory.prototype.grow' data property
let memGrowDesc = Object.getOwnPropertyDescriptor(memoryProto, 'grow');
assertEq(typeof memGrowDesc.value, "function");
-assertEq(memGrowDesc.enumerable, false);
-assertEq(memGrowDesc.configurable, true);
+assertFalse(memGrowDesc.enumerable);
+assertTrue(memGrowDesc.configurable);
// 'WebAssembly.Memory.prototype.grow' method
@@ -388,12 +388,12 @@ var buf = mem.buffer;
assertEq(buf.byteLength, kPageSize);
assertEq(mem.grow(0), 1);
// TODO(gdeepti): Pending spec clarification
-// assertEq(buf !== mem.buffer, true);
+// assertTrue(buf !== mem.buffer);
// assertEq(buf.byteLength, 0);
buf = mem.buffer;
assertEq(buf.byteLength, kPageSize);
assertEq(mem.grow(1), 1);
-// TODO(gdeepti): assertEq(buf !== mem.buffer, true);
+// TODO(gdeepti): assertTrue(buf !== mem.buffer);
// TODO(gdeepti): assertEq(buf.byteLength, 0);
buf = mem.buffer;
assertEq(buf.byteLength, 2 * kPageSize);
@@ -403,9 +403,9 @@ assertEq(buf, mem.buffer);
// 'WebAssembly.Table' data property
let tableDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Table');
assertEq(typeof tableDesc.value, "function");
-assertEq(tableDesc.writable, true);
-assertEq(tableDesc.enumerable, false);
-assertEq(tableDesc.configurable, true);
+assertTrue(tableDesc.writable);
+assertFalse(tableDesc.enumerable);
+assertTrue(tableDesc.configurable);
// 'WebAssembly.Table' constructor function
let Table = WebAssembly.Table;
@@ -422,17 +422,19 @@ assertErrorMessage(() => new Table({initial:-1, element:"anyfunc"}), RangeError,
assertErrorMessage(() => new Table({initial:Math.pow(2,32), element:"anyfunc"}), RangeError, /bad Table initial size/);
assertErrorMessage(() => new Table({initial:2, maximum:1, element:"anyfunc"}), RangeError, /bad Table maximum size/);
assertErrorMessage(() => new Table({initial:2, maximum:Math.pow(2,32), element:"anyfunc"}), RangeError, /bad Table maximum size/);
-assertEq(new Table({initial:1, element:"anyfunc"}) instanceof Table, true);
-assertEq(new Table({initial:1.5, element:"anyfunc"}) instanceof Table, true);
-assertEq(new Table({initial:1, maximum:1.5, element:"anyfunc"}) instanceof Table, true);
-//TODO:maximum assertEq(new Table({initial:1, maximum:Math.pow(2,32)-1, element:"anyfunc"}) instanceof Table, true);
+assertTrue(new Table({initial: 1, element: 'anyfunc'}) instanceof Table);
+assertTrue(new Table({initial: 1.5, element: 'anyfunc'}) instanceof Table);
+assertTrue(
+ new Table({initial: 1, maximum: 1.5, element: 'anyfunc'}) instanceof Table);
+// TODO:maximum assertTrue(new Table({initial:1, maximum:Math.pow(2,32)-1,
+// element:"anyfunc"}) instanceof Table);
// 'WebAssembly.Table.prototype' data property
let tableProtoDesc = Object.getOwnPropertyDescriptor(Table, 'prototype');
assertEq(typeof tableProtoDesc.value, "object");
-assertEq(tableProtoDesc.writable, false);
-assertEq(tableProtoDesc.enumerable, false);
-assertEq(tableProtoDesc.configurable, false);
+assertFalse(tableProtoDesc.writable);
+assertFalse(tableProtoDesc.enumerable);
+assertFalse(tableProtoDesc.configurable);
// 'WebAssembly.Table.prototype' object
let tableProto = Table.prototype;
@@ -450,8 +452,8 @@ assertEq(Object.getPrototypeOf(tbl1), tableProto);
let lengthDesc = Object.getOwnPropertyDescriptor(tableProto, 'length');
assertEq(typeof lengthDesc.get, "function");
assertEq(lengthDesc.set, undefined);
-assertEq(lengthDesc.enumerable, false);
-assertEq(lengthDesc.configurable, true);
+assertFalse(lengthDesc.enumerable);
+assertTrue(lengthDesc.configurable);
// 'WebAssembly.Table.prototype.length' getter
let lengthGetter = lengthDesc.get;
@@ -464,8 +466,8 @@ assertEq(lengthGetter.call(tbl1), 2);
// 'WebAssembly.Table.prototype.get' data property
let getDesc = Object.getOwnPropertyDescriptor(tableProto, 'get');
assertEq(typeof getDesc.value, "function");
-assertEq(getDesc.enumerable, false);
-assertEq(getDesc.configurable, true);
+assertFalse(getDesc.enumerable);
+assertTrue(getDesc.configurable);
// 'WebAssembly.Table.prototype.get' method
let get = getDesc.value;
@@ -484,8 +486,8 @@ assertErrorMessage(() => get.call(tbl1, {valueOf() { throw new Error("hi") }}),
// 'WebAssembly.Table.prototype.set' data property
let setDesc = Object.getOwnPropertyDescriptor(tableProto, 'set');
assertEq(typeof setDesc.value, "function");
-assertEq(setDesc.enumerable, false);
-assertEq(setDesc.configurable, true);
+assertFalse(setDesc.enumerable);
+assertTrue(setDesc.configurable);
// 'WebAssembly.Table.prototype.set' method
let set = setDesc.value;
@@ -507,8 +509,8 @@ assertEq(set.call(tbl1, 1, null), undefined);
// 'WebAssembly.Table.prototype.grow' data property
let tblGrowDesc = Object.getOwnPropertyDescriptor(tableProto, 'grow');
assertEq(typeof tblGrowDesc.value, "function");
-assertEq(tblGrowDesc.enumerable, false);
-assertEq(tblGrowDesc.configurable, true);
+assertFalse(tblGrowDesc.enumerable);
+assertTrue(tblGrowDesc.configurable);
// 'WebAssembly.Table.prototype.grow' method
let tblGrow = tblGrowDesc.value;
@@ -528,17 +530,17 @@ assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/);
// 'WebAssembly.validate' function
assertErrorMessage(() => WebAssembly.validate(), TypeError);
assertErrorMessage(() => WebAssembly.validate("hi"), TypeError);
-assertEq(WebAssembly.validate(emptyModuleBinary), true);
+assertTrue(WebAssembly.validate(emptyModuleBinary));
// TODO: other ways for validate to return false.
-assertEq(WebAssembly.validate(moduleBinaryImporting2Memories), false);
-assertEq(WebAssembly.validate(moduleBinaryWithMemSectionAndMemImport), false);
+assertFalse(WebAssembly.validate(moduleBinaryImporting2Memories));
+assertFalse(WebAssembly.validate(moduleBinaryWithMemSectionAndMemImport));
// 'WebAssembly.compile' data property
let compileDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'compile');
assertEq(typeof compileDesc.value, "function");
-assertEq(compileDesc.writable, true);
-assertEq(compileDesc.enumerable, false);
-assertEq(compileDesc.configurable, true);
+assertTrue(compileDesc.writable);
+assertFalse(compileDesc.enumerable);
+assertTrue(compileDesc.configurable);
// 'WebAssembly.compile' function
let compile = WebAssembly.compile;
@@ -549,9 +551,9 @@ function assertCompileError(args, err, msg) {
var error = null;
compile(...args).catch(e => error = e);
drainJobQueue();
- assertEq(error instanceof err, true);
- assertEq(Boolean(error.stack.match("js-api.js")), true);
-//TODO assertEq(Boolean(error.message.match(msg)), true);
+ assertTrue(error instanceof err);
+ assertTrue(Boolean(error.stack.match('js-api.js')));
+ // TODO assertTrue(Boolean(error.message.match(msg)));
}
assertCompileError([], TypeError, /requires more than 0 arguments/);
assertCompileError([undefined], TypeError, /first argument must be an ArrayBuffer or typed array object/);
@@ -566,7 +568,7 @@ function assertCompileSuccess(bytes) {
var module = null;
compile(bytes).then(m => module = m);
drainJobQueue();
- assertEq(module instanceof Module, true);
+ assertTrue(module instanceof Module);
}
assertCompileSuccess(emptyModuleBinary);
assertCompileSuccess(emptyModuleBinary.buffer);
@@ -574,9 +576,9 @@ assertCompileSuccess(emptyModuleBinary.buffer);
// 'WebAssembly.instantiate' data property
let instantiateDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'instantiate');
assertEq(typeof instantiateDesc.value, "function");
-assertEq(instantiateDesc.writable, true);
-assertEq(instantiateDesc.enumerable, false);
-assertEq(instantiateDesc.configurable, true);
+assertTrue(instantiateDesc.writable);
+assertFalse(instantiateDesc.enumerable);
+assertTrue(instantiateDesc.configurable);
// 'WebAssembly.instantiate' function
let instantiate = WebAssembly.instantiate;
@@ -587,9 +589,9 @@ function assertInstantiateError(args, err, msg) {
var error = null;
instantiate(...args).catch(e => error = e);
drainJobQueue();
- assertEq(error instanceof err, true);
- assertEq(Boolean(error.stack.match("js-api.js")), true);
- //TODO assertEq(Boolean(error.message.match(msg)), true);
+ assertTrue(error instanceof err);
+ assertTrue(Boolean(error.stack.match('js-api.js')));
+ // TODO assertTrue(Boolean(error.message.match(msg)));
}
var scratch_memory = new WebAssembly.Memory(new ArrayBuffer(10));
assertInstantiateError([], TypeError, /requires more than 0 arguments/);
@@ -604,7 +606,6 @@ assertInstantiateError([importingModule], TypeError, /second argument must be an
assertInstantiateError([importingModule, null], TypeError, /second argument must be an object/);
assertInstantiateError([importingModuleBinary, null], TypeError, /second argument must be an object/);
assertInstantiateError([emptyModule, null], TypeError, /first argument must be a BufferSource/);
-assertInstantiateError([importingModule, {"":{f:()=>{}}}], TypeError, /first argument must be a BufferSource/);
assertInstantiateError([importingModuleBinary, null], TypeError, /TODO: error messages?/);
assertInstantiateError([importingModuleBinary, undefined], TypeError, /TODO: error messages?/);
assertInstantiateError([importingModuleBinary, {}], LinkError, /TODO: error messages?/);
@@ -616,14 +617,23 @@ assertInstantiateError([memoryImportingModuleBinary, {}], LinkError, /TODO: erro
assertInstantiateError([memoryImportingModuleBinary, {"mod": {"my_memory": scratch_memory}}], LinkError, /TODO: error messages?/);
assertInstantiateError([memoryImportingModuleBinary, {"": {"memory": scratch_memory}}], LinkError, /TODO: error messages?/);
-function assertInstantiateSuccess(module_bytes, imports) {
+function assertInstantiateSuccess(module_or_bytes, imports) {
var result = null;
- instantiate(module_bytes, imports).then(r => result = r).catch(e => print(e));
+ instantiate(module_or_bytes, imports)
+ .then(r => result = r)
+ .catch(e => print(e));
drainJobQueue();
- assertEq(result instanceof Instance, true);
+ if (module_or_bytes instanceof Module) {
+ assertTrue(result instanceof Instance);
+ } else {
+ assertTrue(result.module instanceof Module);
+ assertTrue(result.instance instanceof Instance);
+ }
}
+assertInstantiateSuccess(emptyModule);
assertInstantiateSuccess(emptyModuleBinary);
assertInstantiateSuccess(emptyModuleBinary.buffer);
+assertInstantiateSuccess(importingModule, {'': {f: () => {}}});
assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}});
assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}});
assertInstantiateSuccess(memoryImportingModuleBinary, {"": {"my_memory": scratch_memory}});
« no previous file with comments | « src/wasm/wasm-js.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698