blob: ed05517ae5070bb1361c5f23ef3c3618beed7114 [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001// Copyright 2016 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 Murdoch097c5b22016-05-18 11:27:45 +01009
Ben Murdochda12d292016-06-02 14:46:10 +010010var expected = "Error\n" +
11 // The line numbers below will change as this test gains / loses lines..
12 " at STACK (stack.js:24:11)\n" + // --
13 " at <WASM> (<anonymous>)\n" + // TODO(jfb): wasm stack here.
14 " at testStack (stack.js:38:18)\n" + // --
15 " at stack.js:40:3"; // --
Ben Murdoch097c5b22016-05-18 11:27:45 +010016
17// The stack trace contains file path, only keep "stack.js".
18function stripPath(s) {
19 return s.replace(/[^ (]*stack\.js/g, "stack.js");
20}
21
22var stack;
23function STACK() {
24 var e = new Error();
25 stack = e.stack;
26}
27
Ben Murdochda12d292016-06-02 14:46:10 +010028(function testStack() {
29 var builder = new WasmModuleBuilder();
30
31 builder.addImport("func", [kAstStmt]);
32
33 builder.addFunction(undefined, [kAstStmt])
34 .addBody([kExprCallImport, 0])
35 .exportAs("main");
36
37 var module = builder.instantiate({func: STACK});
38 module.exports.main();
Ben Murdoch097c5b22016-05-18 11:27:45 +010039 assertEquals(expected, stripPath(stack));
Ben Murdochda12d292016-06-02 14:46:10 +010040})();