Debian Codegraph @

js/src/tests/non262/template-strings/debugLineNumber.js

raw
1 // This Source Code Form is subject to the terms of the Mozilla Public
2 // License, v. 2.0. If a copy of the MPL was not distributed with this
3 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 // TEST BEGIN
6
7 // verify debugger line numbers are accurate
8 try {
9 `
10 a
11 b
12 c
13 `;
14 throw Error("error");
15 } catch (e) {
16 assertEq(e.lineNumber, 14);
17 }
18
19 try {
20 function tagThatThrows(...args) { throw new Error(); }
21
22 tagThatThrows`
23 multi-line
24 template
25 string`;
26 } catch (e) {
27 var stackLines = e.stack.split('\n');
28 var firstLine = stackLines[0].split(':');
29 var secondLine = stackLines[1].split(':');
30 var firstLineSize = firstLine.length;
31 var secondLineSize = secondLine.length;
32 assertEq(firstLine[firstLineSize - 2], "20");
33 assertEq(firstLine[firstLineSize - 1], "45");
34 assertEq(secondLine[secondLineSize - 2], "22");
35 assertEq(secondLine[secondLineSize - 1], "18");
36 }
37
38 try {
39 ` multi-line
40 template
41 with
42 ${substitutionThatThrows()}`
43
44 } catch (e) {
45 assertEq(e.lineNumber, 42);
46 }
47
48
49
50 reportCompare(0, 0, "ok");