| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 | |
| 6 Debug = debug.Debug | |
| 7 var exception = null; | |
| 8 var yields = 0; | |
| 9 | |
| 10 function listener(event, exec_state, event_data, data) { | |
| 11 if (event != Debug.DebugEvent.Break) return; | |
| 12 try { | |
| 13 var source = exec_state.frame(0).sourceLineText(); | |
| 14 print(source); | |
| 15 if (/stop stepping/.test(source)) return; | |
| 16 if (/yield/.test(source)) yields++; | |
| 17 exec_state.prepareStep(Debug.StepAction.StepIn); | |
| 18 } catch (e) { | |
| 19 print(e, e.stack); | |
| 20 exception = e; | |
| 21 } | |
| 22 }; | |
| 23 | |
| 24 Debug.setListener(listener); | |
| 25 | |
| 26 function* g() { | |
| 27 for (var i = 0; i < 3; ++i) { | |
| 28 yield i; | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 var i = g(); | |
| 33 debugger; | |
| 34 for (var num of g()) {} | |
| 35 i.next(); | |
| 36 | |
| 37 print(); // stop stepping | |
| 38 | |
| 39 // Not stepped into. | |
| 40 i.next(); | |
| 41 i.next(); | |
| 42 | |
| 43 assertNull(exception); | |
| 44 assertEquals(4, yields); | |
| OLD | NEW |