Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Unified Diff: tests/language/src/CompileTimeConstantETest.dart

Issue 9703105: Re-land r5529. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/language/language-leg.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/src/CompileTimeConstantETest.dart
diff --git a/tests/language/src/CompileTimeConstantETest.dart b/tests/language/src/CompileTimeConstantETest.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a5f824e0d608b50237e42280e0d330c1c1a4a207
--- /dev/null
+++ b/tests/language/src/CompileTimeConstantETest.dart
@@ -0,0 +1,70 @@
+// 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.
+
+class A {
+ final x = 3;
+ final y;
+ final z;
+ final t;
+
+ const A([this.z = 99, tt = 100]) : y = 499, t = tt;
+ const A.named([z, this.t]) : y = 400 + z, this.z = z;
+ const A.named2([t, z, y, x]) : x = t, y = z, z = y, t = x;
+
+ toString() => "A $x $y $z $t";
+}
+
+final a1 = const A(99, 100);
+final a2 = const A.named(99, 100);
+final a3 = const A.named2(1, 2, 3, 4);
+final a4 = const A();
+final a5 = const A(tt: 100, z: 99);
+final a6 = const A(1, tt: 2);
+final a7 = const A.named(z: 7);
+final a8 = const A.named2();
+final a9 = const A.named2(x: 4, y: 3, z: 2, t: 1);
+final a10 = const A.named2(x: 1, y: 2, z: 3, t: 4);
+
+main() {
+ Expect.equals(3, a1.x);
+ Expect.equals(499, a1.y);
+ Expect.equals(99, a1.z);
+ Expect.equals(100, a1.t);
+ Expect.equals("A 3 499 99 100", a1.toString());
+ Expect.isTrue(a1 === a2);
+ Expect.isTrue(a1 === a4);
+ Expect.isTrue(a1 === a5);
+
+ Expect.equals(1, a3.x);
+ Expect.equals(2, a3.y);
+ Expect.equals(3, a3.z);
+ Expect.equals(4, a3.t);
+ Expect.equals("A 1 2 3 4", a3.toString());
+
+ Expect.equals(3, a6.x);
+ Expect.equals(499, a6.y);
+ Expect.equals(1, a6.z);
+ Expect.equals(2, a6.t);
+ Expect.equals("A 3 499 1 2", a6.toString());
+
+ Expect.equals(3, a7.x);
+ Expect.equals(407, a7.y);
+ Expect.equals(7, a7.z);
+ Expect.equals(null, a7.t);
+ Expect.equals("A 3 407 7 null", a7.toString());
+
+ Expect.equals(null, a8.x);
+ Expect.equals(null, a8.y);
+ Expect.equals(null, a8.y);
+ Expect.equals(null, a8.t);
+ Expect.equals("A null null null null", a8.toString());
+
+ Expect.isTrue(a3 === a9);
+
+ Expect.equals(4, a10.x);
+ Expect.equals(3, a10.y);
+ Expect.equals(2, a10.z);
+ Expect.equals(1, a10.t);
+ Expect.equals("A 4 3 2 1", a10.toString());
+}
« no previous file with comments | « tests/language/language-leg.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698