| Index: tests/language/const_syntax_test.dart
|
| diff --git a/tests/language/final_syntax_test.dart b/tests/language/const_syntax_test.dart
|
| similarity index 60%
|
| copy from tests/language/final_syntax_test.dart
|
| copy to tests/language/const_syntax_test.dart
|
| index c0189bd54be635c1cf713c9ac040699e3244a254..f2ea8ce5ba9068cf0a613bc4a549d406be1bc7cc 100644
|
| --- a/tests/language/final_syntax_test.dart
|
| +++ b/tests/language/const_syntax_test.dart
|
| @@ -3,13 +3,20 @@
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| main() {
|
| - final f0 = 42;
|
| - final f1; /// 01: compile-time error
|
| - final int f2 = 87;
|
| - final int f3; /// 02: compile-time error
|
| + const f1; /// 01: compile-time error
|
| + const int f3; /// 02: compile-time error
|
| +
|
| +
|
| + // TODO(floitsch): reenable the following lines when dart2js supports local
|
| + // const variables.
|
| + /*
|
| + const f0 = 42;
|
| + const int f2 = 87;
|
| Expect.equals(42, f0);
|
| Expect.equals(87, f2);
|
| + */
|
|
|
| + // It is ok not to raise a compile-time error for 03 and 04.
|
| Expect.equals(42, F0); /// 03: compile-time error
|
| Expect.equals(87, F2); /// 04: compile-time error
|
|
|
| @@ -30,10 +37,10 @@ main() {
|
| Expect.equals("42Hello", B3); /// 10: compile-time error
|
| }
|
|
|
| -final F0 = 42;
|
| -final F1; /// 03: continued
|
| -final int F2 = 87;
|
| -final int F3; /// 04: continued
|
| +const F0 = 42;
|
| +const F1; /// 03: continued
|
| +const int F2 = 87;
|
| +const int F3; /// 04: continued
|
|
|
| class Point {
|
| final x, y;
|
| @@ -43,31 +50,31 @@ class Point {
|
|
|
| // Check that compile time expressions can include invocations of
|
| // user-defined const constructors.
|
| -final P0 = const Point(0, 0);
|
| -final P1 = const Point(0, 0) + 1; /// 05: continued
|
| -final P2 = new Point(0, 0); /// 06: continued
|
| -final P3 = new Point(0, 0) + 1; /// 07: continued
|
| +const P0 = const Point(0, 0);
|
| +const P1 = const Point(0, 0) + 1; /// 05: continued
|
| +const P2 = new Point(0, 0); /// 06: continued
|
| +const P3 = new Point(0, 0) + 1; /// 07: continued
|
|
|
| // Check that we cannot have cyclic references in compile time
|
| // expressions.
|
| -final A0 = 42;
|
| -final A1 = A0 + 1;
|
| -final A2 = A3 + 1; /// 08: continued
|
| -final A3 = A2 + 1; /// 08: continued
|
| +const A0 = 42;
|
| +const A1 = A0 + 1;
|
| +const A2 = A3 + 1; /// 08: continued
|
| +const A3 = A2 + 1; /// 08: continued
|
|
|
| class C0 {
|
| - static final X = const C1();
|
| + static const X = const C1();
|
| }
|
|
|
| class C1 {
|
| const C1()
|
| : x = C0.X /// 09: continued
|
| ;
|
| - final x = null;
|
| + const x = null;
|
| }
|
|
|
| // Check that sub-expressions of binary + are numeric.
|
| -final B0 = 42;
|
| -final B1 = "Hello";
|
| -final B2 = "$B1 $B0";
|
| -final B3 = B0 + B1; /// 10: continued
|
| +const B0 = 42;
|
| +const B1 = "Hello";
|
| +const B2 = "$B1 $B0";
|
| +const B3 = B0 + B1; /// 10: continued
|
|
|