| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 // Dart test program for testing throw statement | |
| 5 | |
| 6 class MyException { | |
| 7 const MyException(); | |
| 8 } | |
| 9 | |
| 10 class OtherException { | |
| 11 const OtherException(); | |
| 12 } | |
| 13 | |
| 14 class RethrowTest { | |
| 15 MyException currentException; | |
| 16 | |
| 17 void throwException() { | |
| 18 currentException = new MyException(); | |
| 19 throw currentException; | |
| 20 } | |
| 21 | |
| 22 void testRethrowPastUncaught() { | |
| 23 try { | |
| 24 try { | |
| 25 try { | |
| 26 throwException(); | |
| 27 Expect.fail("Should have thrown an exception"); | |
| 28 } catch (var e) { | |
| 29 Expect.equals(true, e === currentException); | |
| 30 throw; | |
| 31 Expect.fail("Should have thrown an exception"); | |
| 32 } | |
| 33 } catch (OtherException e) { | |
| 34 Expect.fail("Should not have caught OtherException"); | |
| 35 } | |
| 36 } catch (var e) { | |
| 37 Expect.equals(true, e === currentException); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 void testRethrow() { | |
| 42 try { | |
| 43 try { | |
| 44 throwException(); | |
| 45 Expect.fail("Should have thrown an exception"); | |
| 46 } catch (var e) { | |
| 47 Expect.equals(true, e === currentException); | |
| 48 throw; | |
| 49 Expect.fail("Should have thrown an exception"); | |
| 50 } | |
| 51 } catch (var e) { | |
| 52 Expect.equals(true, e === currentException); | |
| 53 } | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 main() { | |
| 58 RethrowTest t = new RethrowTest(); | |
| 59 t.testRethrow(); | |
| 60 t.testRethrowPastUncaught(); | |
| 61 } | |
| OLD | NEW |