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

Unified Diff: test/mjsunit/wasm/unreachable.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/start-function.js ('k') | test/mjsunit/wasm/wasm-constants.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/unreachable.js
diff --git a/test/mjsunit/wasm/unreachable.js b/test/mjsunit/wasm/unreachable.js
index ff8759b84c4df40178ed130693f94da2f5ff3f03..3e2dffb4e91f25fa04d7e4b129404b240d063430 100644
--- a/test/mjsunit/wasm/unreachable.js
+++ b/test/mjsunit/wasm/unreachable.js
@@ -5,42 +5,20 @@
// Flags: --expose-wasm
load("test/mjsunit/wasm/wasm-constants.js");
+load("test/mjsunit/wasm/wasm-module-builder.js");
-var module = (function () {
- var kFuncWithBody = 9;
- var kFuncImported = 7;
- var kBodySize1 = 1;
- var kMainOffset = kHeaderSize + 6 + kFuncWithBody + kBodySize1 + 1;
+var main = (function () {
+ var builder = new WasmModuleBuilder();
+ builder.addFunction("main", [kAstStmt])
+ .addBody([kExprUnreachable])
+ .exportAs("main");
- var ffi = new Object();
- ffi.add = (function(a, b) { return a + b | 0; });
-
- return _WASMEXP_.instantiateModule(bytesWithHeader(
- // -- signatures
- kDeclSignatures, 1,
- 0, kAstStmt, // void -> void
- // -- function #0 (unreachable)
- kDeclFunctions, 1,
- kDeclFunctionName | kDeclFunctionExport,
- 0, 0, // signature offset
- kMainOffset, 0, 0, 0, // name offset
- kBodySize1, 0, // body size
- kExprUnreachable,
- kDeclEnd,
- 'm', 'a', 'i', 'n', 0 // name
- ), ffi);
+ return builder.instantiate().exports.main;
})();
-// Check the module exists.
-assertFalse(module === undefined);
-assertFalse(module === null);
-assertFalse(module === 0);
-assertEquals("object", typeof module);
-assertEquals("function", typeof module.main);
-
var exception = "";
try {
- assertEquals(0, module.main());
+ assertEquals(0, main());
} catch(e) {
print("correctly caught: " + e);
exception = e;
« no previous file with comments | « test/mjsunit/wasm/start-function.js ('k') | test/mjsunit/wasm/wasm-constants.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698