OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, 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 |
| 5 import 'expect.dart'; |
| 6 |
| 7 testNormalRethrow() { |
| 8 var x = 0; |
| 9 try { |
| 10 try { |
| 11 throw x++; |
| 12 } catch (e) { |
| 13 Expect.isTrue(e == 0); |
| 14 x++; |
| 15 rethrow; |
| 16 } |
| 17 } catch (e) { |
| 18 Expect.isTrue(e == 0); |
| 19 x++; |
| 20 } |
| 21 Expect.isTrue(x == 3); |
| 22 } |
| 23 |
| 24 testNormalRethrow2() { |
| 25 var x = 0; |
| 26 try { |
| 27 try { |
| 28 throw x++; |
| 29 } on int catch (e) { |
| 30 Expect.isTrue(e == 0); |
| 31 x++; |
| 32 rethrow; |
| 33 } |
| 34 } catch (e) { |
| 35 Expect.isTrue(e == 0); |
| 36 x++; |
| 37 } |
| 38 Expect.isTrue(x == 3); |
| 39 } |
| 40 |
| 41 testRethrowWithinTryRethrow() { |
| 42 var x = 0; |
| 43 try { |
| 44 try { |
| 45 throw x++; |
| 46 } on int catch (e) { |
| 47 Expect.isTrue(e == 0); |
| 48 x++; |
| 49 try { |
| 50 x++; |
| 51 rethrow; |
| 52 } finally { |
| 53 x++; |
| 54 } |
| 55 } |
| 56 } catch (e) { |
| 57 Expect.isTrue(e == 0); |
| 58 x++; |
| 59 } |
| 60 Expect.isTrue(x == 5); |
| 61 } |
| 62 |
| 63 main() { |
| 64 testNormalRethrow(); |
| 65 testNormalRethrow2(); |
| 66 testRethrowWithinTryRethrow(); |
| 67 } |
OLD | NEW |