blob: d77b53ea53d8a3445c9fa49b8259bb171c53fbe9 [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();
Ben Murdochc5610432016-08-08 18:44:38 +010012 builder.addFunction("main", kSig_v_v)
Ben Murdochda12d292016-06-02 14:46:10 +010013 .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}
Ben Murdochc5610432016-08-08 18:44:38 +010026assertEquals("unreachable", exception.message);