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

Unified Diff: test/mjsunit/wasm/instantiate-module-basic.js

Issue 1770913002: [wasm] Use the JavaScript WasmModuleBuilder utility in JS tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « test/mjsunit/wasm/indirect-calls.js ('k') | test/mjsunit/wasm/instantiate-run-basic.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/instantiate-module-basic.js
diff --git a/test/mjsunit/wasm/instantiate-module-basic.js b/test/mjsunit/wasm/instantiate-module-basic.js
index 20ae4d43039900789a99fb78cd2506c9b8b8690f..7a756e9024bd33e9c14df475a0702fcd0c80a4ad 100644
--- a/test/mjsunit/wasm/instantiate-module-basic.js
+++ b/test/mjsunit/wasm/instantiate-module-basic.js
@@ -5,33 +5,20 @@
// Flags: --expose-wasm
load("test/mjsunit/wasm/wasm-constants.js");
+load("test/mjsunit/wasm/wasm-module-builder.js");
var kReturnValue = 117;
-var kBodySize = 2;
-var kNameOffset = kHeaderSize + 19 + kBodySize + 1;
-
-var data = bytesWithHeader(
- // -- memory
- kDeclMemory,
- 1, 1, 1,
- // -- signatures
- kDeclSignatures, 1,
- 0, kAstI32, // signature: void -> int
- // -- main function
- kDeclFunctions, 1,
- kDeclFunctionName | kDeclFunctionExport,
- 0, 0, // signature index
- kNameOffset, 0, 0, 0, // name offset
- kBodySize, 0, // body size
- // -- body
- kExprI8Const, // --
- kReturnValue, // --
- kDeclEnd,
- 'm', 'a', 'i', 'n', 0 // name
-);
-
-var module = _WASMEXP_.instantiateModule(data);
+var module = (function Build() {
+ var builder = new WasmModuleBuilder();
+
+ builder.addMemory(1, 1, true);
+ builder.addFunction("main", [kAstI32])
+ .addBody([kExprI8Const, kReturnValue])
+ .exportFunc();
+
+ return builder.instantiate();
+})();
// Check the module exists.
assertFalse(module === undefined);
@@ -54,9 +41,10 @@ for (var i = 0; i < 4; i++) {
assertEquals(65536, module.memory.byteLength);
// Check the properties of the main function.
-assertFalse(module.main === undefined);
-assertFalse(module.main === null);
-assertFalse(module.main === 0);
-assertEquals("function", typeof module.main);
+var main = module.exports.main;
+assertFalse(main === undefined);
+assertFalse(main === null);
+assertFalse(main === 0);
+assertEquals("function", typeof main);
-assertEquals(kReturnValue, module.main());
+assertEquals(kReturnValue, main());
« no previous file with comments | « test/mjsunit/wasm/indirect-calls.js ('k') | test/mjsunit/wasm/instantiate-run-basic.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698