OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 function* serialize() { |
| 6 debugger; |
| 7 switch (0) { |
| 8 case 0: |
| 9 let x = 1; |
| 10 return x; // Check scopes |
| 11 } |
| 12 } |
| 13 |
| 14 let exception = null; |
| 15 let step_count = 0; |
| 16 let scopes_checked = false; |
| 17 |
| 18 function listener(event, exec_state, event_data, data) { |
| 19 if (event != Debug.DebugEvent.Break) return; |
| 20 try { |
| 21 if (exec_state.frame().sourceLineText().includes("Check scopes")) { |
| 22 let expected = [ debug.ScopeType.Block, |
| 23 debug.ScopeType.Local, |
| 24 debug.ScopeType.Script, |
| 25 debug.ScopeType.Global ]; |
| 26 for (let i = 0; i < exec_state.frame().scopeCount(); i++) { |
| 27 assertEquals(expected[i], exec_state.frame().scope(i).scopeType()); |
| 28 } |
| 29 scopes_checked = true; |
| 30 } |
| 31 if (step_count++ < 3) exec_state.prepareStep(Debug.StepAction.StepNext); |
| 32 } catch (e) { |
| 33 exception = e; |
| 34 print(e, e.stack); |
| 35 } |
| 36 } |
| 37 |
| 38 |
| 39 |
| 40 let Debug = debug.Debug; |
| 41 Debug.setListener(listener); |
| 42 |
| 43 let gen = serialize(); |
| 44 gen.next(); |
| 45 |
| 46 Debug.setListener(null); |
| 47 assertNull(exception); |
| 48 assertEquals(4, step_count); |
| 49 assertTrue(scopes_checked); |
OLD | NEW |