Skip to content

Commit

Permalink
Set initial line number to -1 and fix StackTraceTests
Browse files Browse the repository at this point in the history
This fixes #477
  • Loading branch information
camnwalter authored and gbrail committed Sep 5, 2024
1 parent 1fb4321 commit 3577b83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CodeGenerator extends Icode {
private ScriptNode scriptOrFn;
private int iCodeTop;
private int stackDepth;
private int lineNumber;
private int lineNumber = -1;
private int doubleTableTop;

private final HashMap<String, Integer> strings = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void failureStackTraceRhino() {
final String source2 = "function f2() { 'H'.toLowerCase(); throw 'hello'; }; f2();";
final String source3 =
"function f2() { new java.lang.String('H').toLowerCase(); throw 'hello'; }; f2();";
final String result = "\tat test.js (f2)" + LS + "\tat test.js" + LS;
final String result = "\tat test.js:0 (f2)" + LS + "\tat test.js:0" + LS;

runWithExpectedStackTrace(source1, result);
runWithExpectedStackTrace(source2, result);
Expand All @@ -56,7 +56,7 @@ public void failureStackTraceMozilla() {
final String source2 = "function f2() { 'H'.toLowerCase(); throw 'hello'; }; f2();";
final String source3 =
"function f2() { new java.lang.String('H').toLowerCase(); throw 'hello'; }; f2();";
final String result = "f2()@test.js" + LS + "@test.js" + LS;
final String result = "f2()@test.js:0" + LS + "@test.js:0" + LS;

runWithExpectedStackTrace(source1, result);
runWithExpectedStackTrace(source2, result);
Expand All @@ -80,7 +80,7 @@ public void failureStackTraceMozillaLf() {
final String source2 = "function f2() { 'H'.toLowerCase(); throw 'hello'; }; f2();";
final String source3 =
"function f2() { new java.lang.String('H').toLowerCase(); throw 'hello'; }; f2();";
final String result = "f2()@test.js\n@test.js\n";
final String result = "f2()@test.js:0\n@test.js:0\n";

runWithExpectedStackTrace(source1, result);
runWithExpectedStackTrace(source2, result);
Expand Down

0 comments on commit 3577b83

Please sign in to comment.