Chromium Code Reviews| Index: tests/compiler/dart2js/kernel/try_catch_test.dart |
| diff --git a/tests/compiler/dart2js/kernel/try_catch_test.dart b/tests/compiler/dart2js/kernel/try_catch_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fc4834a07824c4f8348cf4ca0cdaff185861aa1d |
| --- /dev/null |
| +++ b/tests/compiler/dart2js/kernel/try_catch_test.dart |
| @@ -0,0 +1,99 @@ |
| +// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import 'package:test/test.dart'; |
| + |
| +import 'helper.dart' show check; |
| + |
| +main() { |
| + test('try catch', () { |
| + String code = ''' |
| +main() { |
| + try { |
| + print('hi'); |
| + } catch (e, s) { |
| + print(e); |
| + print(s); |
| + print('bye'); |
| + } |
| +}'''; |
| + return check(code); |
| + }); |
| + |
| + test('try omit catch', () { |
| + String code = ''' |
| +main() { |
| + try { |
| + print('hi'); |
| + } on ArgumentError { |
| + print('howdy'); |
| + } |
| +}'''; |
| + return check(code); |
| + }); |
| + |
| + test('try finally', () { |
| + String code = ''' |
| +main() { |
| + try { |
| + print('hi'); |
| + } finally { |
| + print('bye'); |
| + } |
| +}'''; |
| + return check(code); |
| + }); |
| + |
| + test('try catch finally', () { |
| + String code = ''' |
| +main() { |
| + try { |
| + print('hi'); |
| + } catch(e) { |
| + print('howdy'); |
| + } finally { |
| + print('bye'); |
| + } |
| +}'''; |
| + return check(code); |
| + }); |
| + |
| + test('try multi catch', () { |
| + String code = ''' |
| +main() { |
| + try { |
| + print('hi'); |
| + } on String catch(e) { |
| + print('hola'); |
| + } on int catch(e) { |
| + print('halo'); |
| + } catch (e) { |
| + print('howdy'); |
| + } |
| +}'''; |
| + // This is the same test as above, but by enabling type inference |
|
Siggi Cherem (dart-lang)
2016/12/15 00:59:45
delete comment? (maybe unrelated from before?)_
Emily Fortuna
2016/12/15 01:25:43
oh yeah. oops. I've been found-out for copying tes
|
| + // we allow the compiler to detect that it can iterate over the |
| + // array using indexing. |
| + return check(code, disableTypeInference: false); |
|
Siggi Cherem (dart-lang)
2016/12/15 00:59:45
remove the disabling flag too? (below as well?)
Emily Fortuna
2016/12/15 01:25:43
Done.
|
| + }); |
| + |
| + test('try multi-catch finally', () { |
| + String code = ''' |
| +main() { |
| + try { |
| + print('hi'); |
| + } on String catch(e) { |
| + print('hola'); |
| + } on int catch(e) { |
| + print('halo'); |
| + } catch (e) { |
| + print('howdy'); |
| + } finally { |
| + print('bye'); |
| + } |
| +}'''; |
| + return check(code, disableTypeInference: false); |
| + }); |
| +} |
| + |