summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/wasm/stack.js
blob: ed05517ae5070bb1361c5f23ef3c3618beed7114 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2016 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.

// Flags: --expose-wasm

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

var expected = "Error\n" +
    // The line numbers below will change as this test gains / loses lines..
    "    at STACK (stack.js:24:11)\n" +     // --
    "    at <WASM> (<anonymous>)\n" +       // TODO(jfb): wasm stack here.
    "    at testStack (stack.js:38:18)\n" + // --
    "    at stack.js:40:3";                 // --

// The stack trace contains file path, only keep "stack.js".
function stripPath(s) {
  return s.replace(/[^ (]*stack\.js/g, "stack.js");
}

var stack;
function STACK() {
  var e = new Error();
  stack = e.stack;
}

(function testStack() {
  var builder = new WasmModuleBuilder();

  builder.addImport("func", [kAstStmt]);

  builder.addFunction(undefined, [kAstStmt])
    .addBody([kExprCallImport, 0])
    .exportAs("main");

  var module = builder.instantiate({func: STACK});
  module.exports.main();
  assertEquals(expected, stripPath(stack));
})();