blob: 3e2dffb4e91f25fa04d7e4b129404b240d063430 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --expose-wasm
6
7load("test/mjsunit/wasm/wasm-constants.js");
Ben Murdochda12d292016-06-02 14:46:10 +01008load("test/mjsunit/wasm/wasm-module-builder.js");
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00009
Ben Murdochda12d292016-06-02 14:46:10 +010010var main = (function () {
11 var builder = new WasmModuleBuilder();
12 builder.addFunction("main", [kAstStmt])
13 .addBody([kExprUnreachable])
14 .exportAs("main");
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000015
Ben Murdochda12d292016-06-02 14:46:10 +010016 return builder.instantiate().exports.main;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000017})();
18
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000019var exception = "";
20try {
Ben Murdochda12d292016-06-02 14:46:10 +010021 assertEquals(0, main());
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000022} catch(e) {
23 print("correctly caught: " + e);
24 exception = e;
25}
26assertEquals("unreachable", exception);