|
1 // Test the corner case of accessing an unaliased variable of a block |
|
2 // while the block is not live. |
|
3 |
|
4 var g = newGlobal(); |
|
5 g.eval("function h() { debugger }"); |
|
6 g.eval("function f() { let (x = 1, y) { (function() { y = 0 })(); h() } }"); |
|
7 g.eval("var surprise = null"); |
|
8 |
|
9 var dbg = new Debugger(g); |
|
10 dbg.onDebuggerStatement = function(hFrame) { |
|
11 var fFrame = hFrame.older; |
|
12 assertEq(fFrame.environment.getVariable('x'), 1); |
|
13 assertEq(fFrame.environment.getVariable('y'), 0); |
|
14 fFrame.eval("surprise = function() { return ++x }"); |
|
15 assertEq(g.surprise(), 2); |
|
16 } |
|
17 g.f(); |
|
18 assertEq(g.surprise !== null, true); |
|
19 |
|
20 // Either succeed or throw an error about 'x' not being live |
|
21 try { |
|
22 assertEq(g.surprise(), 3); |
|
23 } catch (e) { |
|
24 assertEq(e+'', 'Error: x is not live'); |
|
25 } |