| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 var exception = null; | |
| 7 var Debug = debug.Debug; | |
| 8 var break_count = 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 assertTrue(source.indexOf(`// B${break_count++}`) > 0); | |
| 16 if (source.indexOf("assertEquals") > 0) { | |
| 17 exec_state.prepareStep(Debug.StepAction.StepNext); | |
| 18 } else { | |
| 19 exec_state.prepareStep(Debug.StepAction.StepIn); | |
| 20 } | |
| 21 } catch (e) { | |
| 22 exception = e; | |
| 23 print(e); | |
| 24 } | |
| 25 }; | |
| 26 | |
| 27 Debug.setListener(listener); | |
| 28 | |
| 29 function f() { | |
| 30 var a, b, c, d; | |
| 31 debugger; // B0 | |
| 32 [ // B1 | |
| 33 a, // B2 | |
| 34 b, // B3 | |
| 35 c = 3 // B4 | |
| 36 ] = [1, 2]; | |
| 37 assertEquals({a:1,b:2,c:3}, {a, b, c}); // B5 | |
| 38 | |
| 39 [ // B6 | |
| 40 a, // B7 | |
| 41 [ | |
| 42 b, // B8 | |
| 43 c // B9 | |
| 44 ], | |
| 45 d // B10 | |
| 46 ] = [5, [6, 7], 8]; | |
| 47 assertEquals({a:5,b:6,c:7,d:8}, {a, b, c, d}); // B11 | |
| 48 | |
| 49 [ // B12 | |
| 50 a, // B13 | |
| 51 b, // B14 | |
| 52 ...c // B15 | |
| 53 ] = [1, 2, 3, 4]; | |
| 54 assertEquals({a:1,b:2,c:[3,4]}, {a, b, c}); // B16 | |
| 55 | |
| 56 ({ // B17 | |
| 57 a, // B18 | |
| 58 b, // B19 | |
| 59 c = 7 // B20 | |
| 60 } = {a: 5, b: 6}); | |
| 61 assertEquals({a:5,b:6,c:7}, {a, b, c}); // B21 | |
| 62 | |
| 63 ({ // B22 | |
| 64 a, // B23 | |
| 65 b = return1(), // B24 | |
| 66 c = return1() // B25 | |
| 67 } = {a: 5, b: 6}); | |
| 68 assertEquals({a:5,b:6,c:1}, {a, b, c}); // B28 | |
| 69 | |
| 70 ({ // B29 | |
| 71 x : a, // B30 | |
| 72 y : b, // B31 | |
| 73 z : c = 3 // B32 | |
| 74 } = {x: 1, y: 2}); | |
| 75 assertEquals({a:1,b:2,c:3}, {a, b, c}); // B33 | |
| 76 } // B34 | |
| 77 | |
| 78 function return1() { | |
| 79 return 1; // B26 | |
| 80 } // B27 | |
| 81 | |
| 82 f(); | |
| 83 Debug.setListener(null); // B35 | |
| 84 assertNull(exception); | |
| OLD | NEW |