v8/test/mjsunit/regress/regress-crbug-109362.js
Peter Marshall 5577c69d27 [debug] Report line numbers for Function constructor functions correctly
The spec says we have to insert some wrapper code with extra line breaks
in it, but this confuses users when they see stack traces as the line
numbers come from the code with the wrapper, instead of the original.

This CL sets line_offset on the script to indicate that line numbers
should be offset by the 2 extra line breaks when reading them out e.g.
for the purpose of stack traces.

Bug: chromium:109362
Change-Id: Ib608e1043c38b595b1466766f7592e993ee3b996
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1741660
Reviewed-by: Simon Zünd <szuend@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63127}
2019-08-08 13:49:17 +00:00

61 lines
1.1 KiB
JavaScript

// 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.
function test(expectation, f) {
var stack;
try {
f();
} catch (e) {
stack = e.stack;
}
assertTrue(stack.indexOf("at eval (evaltest:" + expectation + ")") > 0);
}
/*
(function(
) {
1 + reference_error //@ sourceURL=evaltest
})
*/
test("1:5", new Function(
'1 + reference_error //@ sourceURL=evaltest'));
/*
(function(x
) {
1 + reference_error //@ sourceURL=evaltest
})
*/
test("2:6", new Function(
'x', '\n 1 + reference_error //@ sourceURL=evaltest'));
/*
(function(x
,z//
,y
) {
1 + reference_error //@ sourceURL=evaltest
})
*/
test("5:6", new Function(
'x\n\n', "z//\n", "y", '\n 1 + reference_error //@ sourceURL=evaltest'));
/*
(function(x/\*,z//
,y*\/
) {
1 + reference_error //@ sourceURL=evaltest
})
*/
test("2:5", new Function(
'x/*', "z//\n", "y*/", '1 + reference_error //@ sourceURL=evaltest'));
/*
(function () {
1 + reference_error //@ sourceURL=evaltest5
})
*/
test("2:6", eval(
'(function () {\n 1 + reference_error //@ sourceURL=evaltest\n})'));