| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Dart test for a closure result type test that cannot be eliminated at compile | 5 // Dart test for a closure result type test that cannot be eliminated at compile |
| 6 // time. | 6 // time. |
| 7 | 7 |
| 8 library closure_type_test; | 8 library closure_type_test; |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
| 11 | 11 |
| 12 class Math { | 12 class Math { |
| 13 static | 13 static |
| 14 int /// 01: static type warning | 14 int //# 01: static type warning |
| 15 sqrt(x) => math.sqrt(x); | 15 sqrt(x) => math.sqrt(x); |
| 16 } | 16 } |
| 17 | 17 |
| 18 isCheckedMode() { | 18 isCheckedMode() { |
| 19 try { | 19 try { |
| 20 var i = 1; | 20 var i = 1; |
| 21 String s = i; | 21 String s = i; |
| 22 return false; | 22 return false; |
| 23 } catch (e) { | 23 } catch (e) { |
| 24 return true; | 24 return true; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 40 } on TypeError catch (error) { | 40 } on TypeError catch (error) { |
| 41 got_type_error = true; | 41 got_type_error = true; |
| 42 } | 42 } |
| 43 // Type error expected in checked mode only. | 43 // Type error expected in checked mode only. |
| 44 Expect.isTrue(got_type_error == isCheckedMode()); | 44 Expect.isTrue(got_type_error == isCheckedMode()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 root(x) => Math.sqrt(x); | 47 root(x) => Math.sqrt(x); |
| 48 | 48 |
| 49 main() => test(root, 4); | 49 main() => test(root, 4); |
| OLD | NEW |