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

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

Issue 2620203005: [wasm] Implement the WebAssembly.Module.imports function. (Closed)
Patch Set: 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-module.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 259754018b828ed00d81cd73df1e2188510eed9d..7f5bab25a876d6514b5422da6650671c3eb6724e 100644
--- a/test/mjsunit/wasm/js-api.js
+++ b/test/mjsunit/wasm/js-api.js
@@ -153,7 +153,6 @@ assertEq(typeof emptyModule, "object");
//TODO assertEq(String(emptyModule), "[object WebAssembly.Module]");
assertEq(Object.getPrototypeOf(emptyModule), moduleProto);
-if (false) { // TODO: Module.imports support
// 'WebAssembly.Module.imports' data property
let moduleImportsDesc = Object.getOwnPropertyDescriptor(Module, 'imports');
assertEq(typeof moduleImportsDesc.value, "function");
@@ -167,10 +166,19 @@ assertEq(moduleImports.length, 1);
assertErrorMessage(() => moduleImports(), TypeError, /requires more than 0 arguments/);
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(wasmTextToBinary('(module)')));
+var arr = moduleImports(new Module(emptyModuleBinary));
assertEq(arr instanceof Array, true);
assertEq(arr.length, 0);
-var arr = moduleImports(new Module(wasmTextToBinary('(module (func (import "a" "b")) (memory (import "c" "d") 1) (table (import "e" "f") 1 anyfunc) (global (import "g" "⚡") i32))')));
+let importingModuleBinary2 = (() => {
+ var text = '(module (func (import "a" "b")) (memory (import "c" "d") 1) (table (import "e" "f") 1 anyfunc) (global (import "g" "⚡") i32))'
+ let builder = new WasmModuleBuilder();
+ builder.addImport("a", "b", kSig_i_i);
+ builder.addImportedMemory("c", "d");
+ builder.addImportedTable("e", "f");
+ builder.addImportedGlobal("g", "x", kWasmI32);
+ return new Int8Array(builder.toBuffer());
+})();
+var arr = moduleImports(new Module(importingModuleBinary2));
assertEq(arr instanceof Array, true);
assertEq(arr.length, 4);
assertEq(arr[0].kind, "function");
@@ -184,8 +192,7 @@ assertEq(arr[2].module, "e");
assertEq(arr[2].name, "f");
assertEq(arr[3].kind, "global");
assertEq(arr[3].module, "g");
-assertEq(arr[3].name, "⚡");
-}
+assertEq(arr[3].name, "x");
if (false) { // TODO: Module.exports property
// 'WebAssembly.Module.exports' data property
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698