Chromium Code Reviews| 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 |
|
karlklose
2014/02/13 14:01:42
Could you add an empty line here, please?
Johnni Winther
2014/02/14 09:46:47
Done.
| |
| 5 // time. | 5 // time. |
| 6 | 6 |
| 7 library closure_type_test; | 7 library closure_type_test; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import 'dart:math' as math; | 9 import 'dart:math' as math; |
| 10 | 10 |
| 11 class Math { | 11 class Math { |
| 12 static int sqrt(x) => math.sqrt(x); | 12 static |
| 13 int /// 01: static type warning | |
| 14 sqrt(x) => math.sqrt(x); | |
| 13 } | 15 } |
| 14 | 16 |
| 15 isCheckedMode() { | 17 isCheckedMode() { |
| 16 try { | 18 try { |
| 17 var i = 1; | 19 var i = 1; |
| 18 String s = i; | 20 String s = i; |
| 19 return false; | 21 return false; |
| 20 } catch (e) { | 22 } catch (e) { |
| 21 return true; | 23 return true; |
| 22 } | 24 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 37 } on TypeError catch (error) { | 39 } on TypeError catch (error) { |
| 38 got_type_error = true; | 40 got_type_error = true; |
| 39 } | 41 } |
| 40 // Type error expected in checked mode only. | 42 // Type error expected in checked mode only. |
| 41 Expect.isTrue(got_type_error == isCheckedMode()); | 43 Expect.isTrue(got_type_error == isCheckedMode()); |
| 42 } | 44 } |
| 43 | 45 |
| 44 root(x) => Math.sqrt(x); | 46 root(x) => Math.sqrt(x); |
| 45 | 47 |
| 46 main() => test(root, 4); | 48 main() => test(root, 4); |
| OLD | NEW |