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 // Dart test for a closure result type test that cannot be eliminated at compile | 4 // Dart test for a closure result type test that cannot be eliminated at compile |
5 // time. | 5 // time. |
6 | 6 |
| 7 #library('closure_type_test'); |
| 8 #import('dart:math', prefix: 'math'); |
| 9 |
| 10 class Math { |
| 11 static int sqrt(x) => math.sqrt(x); |
| 12 } |
| 13 |
7 isCheckedMode() { | 14 isCheckedMode() { |
8 try { | 15 try { |
9 var i = 1; | 16 var i = 1; |
10 String s = i; | 17 String s = i; |
11 return false; | 18 return false; |
12 } catch(var e) { | 19 } catch(var e) { |
13 return true; | 20 return true; |
14 } | 21 } |
15 } | 22 } |
16 | 23 |
(...skipping 11 matching lines...) Expand all Loading... |
28 Expect.equals(value, x * x); | 35 Expect.equals(value, x * x); |
29 } catch (TypeError error) { | 36 } catch (TypeError error) { |
30 got_type_error = true; | 37 got_type_error = true; |
31 } | 38 } |
32 // Type error expected in checked mode only. | 39 // Type error expected in checked mode only. |
33 Expect.isTrue(got_type_error == isCheckedMode()); | 40 Expect.isTrue(got_type_error == isCheckedMode()); |
34 } | 41 } |
35 | 42 |
36 root(x) => Math.sqrt(x); | 43 root(x) => Math.sqrt(x); |
37 | 44 |
38 main() => test(root, 4); | 45 main() => test(root, 4); |
OLD | NEW |