Chromium Code Reviews| Index: tests/language/src/CompileTimeConstantITest.dart |
| diff --git a/tests/language/src/CompileTimeConstantITest.dart b/tests/language/src/CompileTimeConstantITest.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1393c1e5adbd93dcbece2f2446e2483d3fa9b6f2 |
| --- /dev/null |
| +++ b/tests/language/src/CompileTimeConstantITest.dart |
| @@ -0,0 +1,95 @@ |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
|
ngeoffray
2012/03/26 07:38:31
Great test!
|
| + |
| +class A { |
| + final x = 4; |
| + const A(this.x); |
| + const A.redirect(x) : this(x + 1); |
| + const A.optional([this.x = 5]); |
| +} |
| + |
| +class B extends A { |
| + const B(x, this.y) : super(x); |
| + const B.redirect(x, y) : this(x + 22, y + 22); |
| + const B.redirect2(x, y) : this.redirect3(x + 122, y + 122); |
| + const B.redirect3(x, y) : this.y = y, super.redirect(x); |
| + const B.optional(x, [this.y]) : super(x); |
| + const B.optional2([x, this.y]) : super(x); |
| + final y; |
| +} |
| + |
| +class C extends B { |
| + const C(x, y, this.z) : super(x, y); |
| + const C.redirect(x, y, z) : this(x + 33, y + 33, z + 33); |
| + const C.redirect2(x, y, z) : this.redirect3(x + 333, y + 333, z + 333); |
| + const C.redirect3(x, y, z) : this.z = z, super.redirect2(x, y); |
| + const C.optional(x, [y, this.z]) : super(x, y); |
| + const C.optional2([x, y, z]): this.z = z, super(x, y); |
| + const C.optional3([this.z]) : super.optional2(); |
| + final z; |
| +} |
| + |
| +final a1 = const A(499); |
|
ahe
2012/03/24 07:30:42
How about adding tests like this:
Expect.identica
floitsch
2012/03/27 00:52:50
I added some, but the identical-tests are mostly d
|
| +final a2 = const A.redirect(10499); |
| +final a3 = const A.optional(); |
| + |
| +final b1 = const B(99499, -99499); |
| +final b2 = const B.redirect(1234, 5678); |
| +final b3 = const B.redirect2(112233, 556677); |
| +final b4 = const B.redirect3(332211, 776655); |
| +final b5 = const B.optional(43526); |
| +final b6 = const B.optional2(y: 9753, x:8642); |
| + |
| +final c1 = const C(121, 232, 343); |
| +final c2 = const C.redirect(12321, 23432, 34543); |
| +final c3 = const C.redirect2(32123, 43234, 54345); |
| +final c4 = const C.redirect3(313, 424, 535); |
| +final c5 = const C.optional(191, 181, 171); |
| +final c6 = const C.optional(-191); |
| +final c7 = const C.optional2(); |
| +final c8 = const C.optional3(9911); |
| + |
| +main() { |
| + Expect.equals(499, a1.x); |
| + Expect.equals(10500, a2.x); |
| + Expect.equals(5, a3.x); |
| + |
| + Expect.equals(99499, b1.x); |
| + Expect.equals(-99499, b1.y); |
| + Expect.equals(1256, b2.x); |
| + Expect.equals(5700, b2.y); |
| + Expect.equals(112233 + 122 + 1, b3.x); |
| + Expect.equals(556677 + 122, b3.y); |
| + Expect.equals(332211 + 1, b4.x); |
| + Expect.equals(776655, b4.y); |
| + Expect.equals(43526, b5.x); |
| + Expect.equals(null, b5.y); |
| + Expect.equals(8642, b6.x); |
| + Expect.equals(9753, b6.y); |
| + |
| + Expect.equals(121, c1.x); |
| + Expect.equals(232, c1.y); |
| + Expect.equals(343, c1.z); |
| + Expect.equals(12321 + 33, c2.x); |
| + Expect.equals(23432 + 33, c2.y); |
| + Expect.equals(34543 + 33, c2.z); |
| + Expect.equals(32123 + 333 + 122 + 1, c3.x); |
| + Expect.equals(43234 + 333 + 122, c3.y); |
| + Expect.equals(54345 + 333, c3.z); |
| + Expect.equals(313 + 122 + 1, c4.x); |
| + Expect.equals(424 + 122, c4.y); |
| + Expect.equals(535, c4.z); |
| + Expect.equals(191, c5.x); |
| + Expect.equals(181, c5.y); |
| + Expect.equals(171, c5.z); |
| + Expect.equals(-191, c6.x); |
| + Expect.equals(null, c6.y); |
| + Expect.equals(null, c6.z); |
| + Expect.equals(null, c7.x); |
| + Expect.equals(null, c7.y); |
| + Expect.equals(null, c7.z); |
| + Expect.equals(null, c8.x); |
| + Expect.equals(null, c8.y); |
| + Expect.equals(9911, c8.z); |
| +} |