OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
7 | 7 |
8 isCheckedMode() { | 8 isCheckedMode() { |
9 try { | 9 try { |
10 var i = 1; | 10 var i = 1; |
11 String s = i; | 11 String s = i; |
12 return false; | 12 return false; |
13 } on TypeError { | 13 } on TypeError { |
14 return true; | 14 return true; |
15 } | 15 } |
16 } | 16 } |
17 | 17 |
18 var x = 'a'; | 18 var x = 'a'; |
19 | 19 |
20 Future<int> foo() async { | 20 Future<int> foo() async { |
21 return x; | 21 return x; |
22 } | 22 } |
23 | 23 |
24 main() { | 24 main() { |
25 foo().then( | 25 foo().then((_) { |
26 (_) { | 26 Expect.isFalse(isCheckedMode()); |
27 Expect.isFalse(isCheckedMode()); | 27 }, onError: (e) { |
28 }, | 28 Expect.isTrue(isCheckedMode() && (e is TypeError)); |
29 onError: (e) { | 29 }); |
30 Expect.isTrue(isCheckedMode() && (e is TypeError)); | |
31 } | |
32 ); | |
33 } | 30 } |
34 | |
OLD | NEW |