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

Unified Diff: tests/language/lazy_final_test.dart

Issue 10855174: Lazy implementation of final variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove lazy bailout initializers. Created 8 years, 3 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
Index: tests/language/lazy_final_test.dart
diff --git a/tests/language/lazy_final_test.dart b/tests/language/lazy_final_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c685e38e54f15b63e31a4fc2bde8e642ed68ecdb
--- /dev/null
+++ b/tests/language/lazy_final_test.dart
@@ -0,0 +1,48 @@
+// 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.
+
+final x = foo();
+final y = y2(y3);
+final y2 = incrementCreator();
+final y3 = fib(5);
+
+foo() => 499;
+
+incrementCreator() => (x) => x + 1;
+fib(x) {
+ if (x < 2) return x;
+ return fib(x - 1) + fib(x - 2);
+}
+
+var count = 0;
+side_effect() => count++;
kasperl 2012/09/05 08:54:54 sideEffect
floitsch 2012/09/05 09:31:07 Done.
+
+final t = side_effect();
+final t2 = side_effect();
+
+class A {
+ static final a = toto();
+ static final b = b2(b3);
+ static final b2 = decrementCreator();
+ static final b3 = fact(5);
+
+ static toto() => 666;
+
+ static decrementCreator() => (x) => x - 1;
+ static fact(x) {
+ if (x <= 1) return x;
+ return x * fact(x - 1);
+ }
+}
+
+main() {
+ Expect.equals(499, x);
+ Expect.equals(6, y);
+ Expect.equals(666, A.a);
+ Expect.equals(119, A.b);
+ Expect.equals(0, t);
+ t2 = 499;
+ Expect.equals(499, t2);
+ Expect.equals(1, count);
+}
« tests/language/lazy_final3_test.dart ('K') | « tests/language/lazy_final3_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698