| 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 'package:test/test.dart'; |
| 6 |
| 7 import 'helper.dart' show check; |
| 8 |
| 9 main() { |
| 10 test('try catch', () { |
| 11 String code = ''' |
| 12 main() { |
| 13 try { |
| 14 print('hi'); |
| 15 } catch (e, s) { |
| 16 print(e); |
| 17 print(s); |
| 18 print('bye'); |
| 19 } |
| 20 }'''; |
| 21 return check(code); |
| 22 }); |
| 23 |
| 24 test('try omit catch', () { |
| 25 String code = ''' |
| 26 main() { |
| 27 try { |
| 28 print('hi'); |
| 29 } on ArgumentError { |
| 30 print('howdy'); |
| 31 } |
| 32 }'''; |
| 33 return check(code); |
| 34 }); |
| 35 |
| 36 test('try finally', () { |
| 37 String code = ''' |
| 38 main() { |
| 39 try { |
| 40 print('hi'); |
| 41 } finally { |
| 42 print('bye'); |
| 43 } |
| 44 }'''; |
| 45 return check(code); |
| 46 }); |
| 47 |
| 48 test('try catch finally', () { |
| 49 String code = ''' |
| 50 main() { |
| 51 try { |
| 52 print('hi'); |
| 53 } catch(e) { |
| 54 print('howdy'); |
| 55 } finally { |
| 56 print('bye'); |
| 57 } |
| 58 }'''; |
| 59 return check(code); |
| 60 }); |
| 61 |
| 62 test('try multi catch', () { |
| 63 String code = ''' |
| 64 main() { |
| 65 try { |
| 66 print('hi'); |
| 67 } on String catch(e) { |
| 68 print('hola'); |
| 69 } on int catch(e) { |
| 70 print('halo'); |
| 71 } catch (e) { |
| 72 print('howdy'); |
| 73 } |
| 74 }'''; |
| 75 return check(code); |
| 76 }); |
| 77 |
| 78 test('try multi-catch finally', () { |
| 79 String code = ''' |
| 80 main() { |
| 81 try { |
| 82 print('hi'); |
| 83 } on String catch(e) { |
| 84 print('hola'); |
| 85 } on int catch(e) { |
| 86 print('halo'); |
| 87 } catch (e) { |
| 88 print('howdy'); |
| 89 } finally { |
| 90 print('bye'); |
| 91 } |
| 92 }'''; |
| 93 return check(code); |
| 94 }); |
| 95 } |
| 96 |
| OLD | NEW |