Bug 979094 - Fix ending location of variable declaration. r=jimb

This commit is contained in:
Tom Tromey 2015-03-27 08:38:00 -04:00
parent bc8ad13bd6
commit 19e44cb300
5 changed files with 28 additions and 3 deletions

View File

@ -3925,6 +3925,8 @@ Parser<ParseHandler>::variables(ParseNodeKind kind, bool* psimple,
if (!data.binder(&data, name, this))
return null();
}
handler.setEndPosition(pn, pn2);
} while (false);
bool matched;

View File

@ -18,4 +18,4 @@ global.eval("function f(n){var w0,x1=3,y2=4,z3=9} debugger;");
global.f(3);
// Should have hit each variable declared.
assertEq(global.log, "18 21 26 31 33 ");
assertEq(global.log, "18 21 26 31 35 ");

View File

@ -17,4 +17,4 @@ global.log = '';
global.eval("function f(n){var o={a:1,b:2,c:3}} debugger;");
global.f(3);
// Should hit each property in the object.
assertEq(global.log, "18 21 25 29 19 ");
assertEq(global.log, "18 21 25 29 33 ");

View File

@ -17,4 +17,4 @@ global.log = '';
global.eval("function f(n){var a=[1,2,n]} debugger;");
global.f(3);
// Should hit each item in the array.
assertEq(global.log, "18 21 23 25 19 ");
assertEq(global.log, "18 21 23 25 27 ");

View File

@ -0,0 +1,23 @@
// Test Script.lineCount.
var g = newGlobal();
var dbg = Debugger(g);
function test(scriptText, expectedLineCount) {
let found = false;
dbg.onNewScript = function(script, global) {
assertEq(script.lineCount, expectedLineCount);
found = true;
};
g.evaluate(scriptText);
assertEq(found, true);
}
src = 'var a = (function(){\n' + // 0
'var b = 9;\n' + // 1
'console.log("x", b);\n'+ // 2
'return b;\n' + // 3
'})();\n'; // 4
test(src, 5);