1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Script-sourceStart-03.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +/* 1.5 + * For arrow functions, Script.prototype.sourceStart and 1.6 + * Script.prototype.sourceLength should comprise the entire function expression 1.7 + * (including arguments) 1.8 + */ 1.9 +let g = newGlobal(); 1.10 +let dbg = new Debugger(g); 1.11 + 1.12 +function test(string, ranges) { 1.13 + var index = 0; 1.14 + dbg.onNewScript = function (script) { 1.15 + function traverse(script) { 1.16 + script.getChildScripts().forEach(function (script) { 1.17 + assertEq(script.sourceStart, ranges[index][0]); 1.18 + assertEq(script.sourceLength, ranges[index][1]); 1.19 + ++index; 1.20 + traverse(script); 1.21 + }); 1.22 + } 1.23 + traverse(script); 1.24 + }; 1.25 + 1.26 + g.eval(string); 1.27 + 1.28 + /* 1.29 + * In some configurations certain child scripts are listed twice, so we 1.30 + * cannot rely on index always having the exact same value 1.31 + */ 1.32 + assertEq(0 < index && index <= ranges.length, true); 1.33 +}; 1.34 + 1.35 +test("() => {}", [[0, 8]]); 1.36 +test("(x, y) => { x * y }", [[0, 19]]); 1.37 +test("x => x * x", [[0, 10]]); 1.38 +test("x => x => x * x", [[0, 15], [5, 10], [5, 10]]);