unreachable.js 679 Bytes
Newer Older
1 2 3 4
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
// Flags: --expose-wasm

7
load("test/mjsunit/wasm/wasm-constants.js");
8
load("test/mjsunit/wasm/wasm-module-builder.js");
9

10 11
var main = (function () {
  var builder = new WasmModuleBuilder();
12
  builder.addFunction("main", kSig_v_v)
13 14
    .addBody([kExprUnreachable])
    .exportAs("main");
15

16
  return builder.instantiate().exports.main;
17 18 19 20
})();

var exception = "";
try {
21
    assertEquals(0, main());
22 23 24 25
} catch(e) {
    print("correctly caught: " + e);
    exception = e;
}
26
assertEquals("unreachable", exception.message);