| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 main() { | 7 main() { |
| 8 const f0 = 42; | 8 const f0 = 42; |
| 9 const f1; /// 01: compile-time error | 9 const f1; /// 01: compile-time error |
| 10 const int f2 = 87; | 10 const int f2 = 87; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 const cf1 = identical(const Point(1, 2), const Point(1, 2)); | 36 const cf1 = identical(const Point(1, 2), const Point(1, 2)); |
| 37 | 37 |
| 38 const cf2 = identical(const Point(1, 2), new Point(1, 2)); /// 11: compile-ti
me error | 38 const cf2 = identical(const Point(1, 2), new Point(1, 2)); /// 11: compile-ti
me error |
| 39 | 39 |
| 40 var f4 = B4; /// 12: compile-time error | 40 var f4 = B4; /// 12: compile-time error |
| 41 var f5 = B5; | 41 var f5 = B5; |
| 42 } | 42 } |
| 43 | 43 |
| 44 const F0 = 42; | 44 const F0 = 42; |
| 45 const F1; /// 03: continued | 45 const F1; // /// 03: continued |
| 46 const int F2 = 87; | 46 const int F2 = 87; |
| 47 const int F3; /// 04: continued | 47 const int F3; // /// 04: continued |
| 48 | 48 |
| 49 class Point { | 49 class Point { |
| 50 final x, y; | 50 final x, y; |
| 51 const Point(this.x, this.y); | 51 const Point(this.x, this.y); |
| 52 operator +(int other) => x; | 52 operator +(int other) => x; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Check that compile time expressions can include invocations of | 55 // Check that compile time expressions can include invocations of |
| 56 // user-defined const constructors. | 56 // user-defined const constructors. |
| 57 const P0 = const Point(0, 0); | 57 const P0 = const Point(0, 0); |
| 58 const P1 = const Point(0, 0) + 1; /// 05: continued | 58 const P1 = const Point(0, 0) + 1; /// 05: continued |
| 59 const P2 = new Point(0, 0); /// 06: continued | 59 const P2 = new Point(0, 0); // /// 06: continued |
| 60 const P3 = new Point(0, 0) + 1; /// 07: continued | 60 const P3 = new Point(0, 0) + 1; /// 07: continued |
| 61 | 61 |
| 62 // Check that we cannot have cyclic references in compile time | 62 // Check that we cannot have cyclic references in compile time |
| 63 // expressions. | 63 // expressions. |
| 64 const A0 = 42; | 64 const A0 = 42; |
| 65 const A1 = A0 + 1; | 65 const A1 = A0 + 1; |
| 66 const A2 = A3 + 1; /// 08: continued | 66 const A2 = A3 + 1; /// 08: continued |
| 67 const A3 = A2 + 1; /// 08: continued | 67 const A3 = A2 + 1; /// 08: continued |
| 68 | 68 |
| 69 class C0 { | 69 class C0 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 80 // Check that sub-expressions of binary + are numeric. | 80 // Check that sub-expressions of binary + are numeric. |
| 81 const B0 = 42; | 81 const B0 = 42; |
| 82 const B1 = "Hello"; | 82 const B1 = "Hello"; |
| 83 const B2 = "$B1 $B0"; | 83 const B2 = "$B1 $B0"; |
| 84 const B3 = B0 + B1; /// 10: continued | 84 const B3 = B0 + B1; /// 10: continued |
| 85 | 85 |
| 86 // Check identical. | 86 // Check identical. |
| 87 | 87 |
| 88 const B4 = identical(1, new Point(1,2)); /// 12: compile-time error | 88 const B4 = identical(1, new Point(1,2)); /// 12: compile-time error |
| 89 const B5 = identical(1, const Point(1,2)); | 89 const B5 = identical(1, const Point(1,2)); |
| OLD | NEW |