OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 // Flags: --expose-debug-as debug |
| 6 |
| 7 |
| 8 Debug = debug.Debug |
| 9 |
| 10 let error = false; |
| 11 let uncaught; |
| 12 |
| 13 function listener(event, exec_state, event_data, data) { |
| 14 if (event != Debug.DebugEvent.Exception) return; |
| 15 try { |
| 16 uncaught = event_data.uncaught(); |
| 17 } catch (e) { |
| 18 error = true; |
| 19 } |
| 20 } |
| 21 |
| 22 Debug.setBreakOnException(); |
| 23 Debug.setListener(listener); |
| 24 |
| 25 |
| 26 function assertCaught(f) { |
| 27 try {f()} finally { |
| 28 assertFalse(uncaught); |
| 29 return; |
| 30 } |
| 31 } |
| 32 |
| 33 function assertUncaught(f) { |
| 34 try {f()} finally { |
| 35 assertTrue(uncaught); |
| 36 return; |
| 37 } |
| 38 } |
| 39 |
| 40 |
| 41 assertUncaught(() => { |
| 42 for (var a of [1, 2, 3]) { |
| 43 throw a |
| 44 } |
| 45 }); |
| 46 |
| 47 assertUncaught(() => { |
| 48 for (var a of [1, 2, 3]) { |
| 49 try {throw a} finally {} |
| 50 } |
| 51 }); |
| 52 |
| 53 assertCaught(() => { |
| 54 for (var a of [1, 2, 3]) { |
| 55 try { |
| 56 try {throw a} finally {} |
| 57 } catch(_) {} |
| 58 } |
| 59 }); |
| 60 |
| 61 assertCaught(() => { |
| 62 try { |
| 63 for (var a of [1, 2, 3]) { |
| 64 try {throw a} finally {} |
| 65 } |
| 66 } catch(_) {} |
| 67 }); |
| 68 |
| 69 |
| 70 assertFalse(error); |
OLD | NEW |