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

Unified Diff: tests/language/lazy_final3_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_final3_test.dart
diff --git a/tests/language/lazy_final3_test.dart b/tests/language/lazy_final3_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..dc9cac03c41b72f806a0803fbc0152678d233a62
--- /dev/null
+++ b/tests/language/lazy_final3_test.dart
@@ -0,0 +1,55 @@
+// 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();
+var x2 = foo2();
+var x3 = foo3();
+var x4 = foo4();
+var x5 = foo5();
+final x6 = foo6();
+var x7 = x7 + 1;
+
+foo() { throw "interrupt initialization"; }
+foo2() { x2 = 499; throw "interrupt initialization"; }
+foo3() => x3 + 1;
+foo4() {
+ x4 = 498;
+ x4 = x4 + 1;
+ return x4;
+}
+foo5() {
+ x5 = 498;
+ x5 = x5 + 1;
+}
+foo6() {
+ try {
+ return x5 + 1;
+ } catch(e) {
kasperl 2012/09/05 08:54:54 I prefer to put a space between catch and (.
floitsch 2012/09/05 09:31:07 Done.
+ return 499;
+ }
+}
+
+fib(x) {
+ if (x < 2) return x;
+ return fib(x - 1) + fib(x - 2);
+}
+
+main() {
+ Expect.throws(() => fib(x));
kasperl 2012/09/05 08:54:54 How about adding a check that verifies that you're
floitsch 2012/09/05 09:31:07 Done.
+ Expect.equals(null, x);
+
+ Expect.throws(() => fib(x2));
+ Expect.equals(499, x2);
+
+ Expect.throws(() => fib(x3));
+ Expect.equals(null, x3);
+
+ Expect.equals(499, x4);
+
+ Expect.equals(null, x5);
+
+ Expect.equals(499, x6);
+
+ Expect.throws(() => fib(x7));
+}

Powered by Google App Engine
This is Rietveld 408576698