| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Check that malformed types in on-catch are handled correctly, that is, | 5 // Check that malformed types in on-catch are handled correctly, that is, |
| 6 // are treated as dynamic and thus catches all in bith production and checked | 6 // throws a type error in both production and checked mode. |
| 7 // mode. | 7 |
| 8 import 'package:expect/expect.dart'; |
| 8 | 9 |
| 9 catchUnresolvedBefore() { | 10 catchUnresolvedBefore() { |
| 10 try { | 11 try { |
| 11 throw "foo"; | 12 throw "foo"; |
| 12 Expect.fail("This code shouldn't be executed"); | 13 Expect.fail("This code shouldn't be executed"); |
| 13 } on String catch(oks) { | 14 } on String catch(oks) { |
| 14 // This is tested before the catch block below. | 15 // This is tested before the catch block below. |
| 15 } on Unavailable catch(ex) { | 16 } on Unavailable catch(ex) { |
| 16 Expect.fail("This code shouldn't be executed"); | 17 Expect.fail("This code shouldn't be executed"); |
| 17 } | 18 } |
| 18 } | 19 } |
| 19 | 20 |
| 20 catchUnresolvedAfter() { | 21 catchUnresolvedAfter() { |
| 21 try { | 22 Expect.throws(() { |
| 22 throw "foo"; | 23 try { |
| 23 Expect.fail("This code shouldn't be executed"); | 24 throw "foo"; |
| 24 } on Unavailable catch(ex) { | 25 Expect.fail("This code shouldn't be executed"); |
| 25 // This is tested before the catch block below. | 26 } on Unavailable catch(ex) { |
| 26 // In both production and checked mode the test is always true. | 27 // This is tested before the catch block below. |
| 27 } on String catch(oks) { | 28 // In both production and checked mode the test causes a type error. |
| 28 Expect.fail("This code shouldn't be executed"); | 29 } on String catch(oks) { |
| 29 } | 30 Expect.fail("This code shouldn't be executed"); |
| 31 } |
| 32 }, (e) => e is TypeError); |
| 30 } | 33 } |
| 31 | 34 |
| 32 main() { | 35 main() { |
| 33 catchUnresolvedBefore(); | 36 catchUnresolvedBefore(); |
| 34 catchUnresolvedAfter(); | 37 catchUnresolvedAfter(); |
| 35 } | 38 } |
| OLD | NEW |