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; |