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

Side by Side 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: Address comments and move some code from compiler to backend. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 final x = foo();
6 final y = y2(y3);
7 final y2 = incrementCreator();
8 final y3 = fib(5);
9
10 foo() => 499;
11
12 incrementCreator() => (x) => x + 1;
13 fib(x) {
14 if (x < 2) return x;
15 return fib(x - 1) + fib(x - 2);
16 }
17
18 var count = 0;
19 sideEffect() => count++;
20
21 final t = sideEffect();
22 final t2 = sideEffect();
23
24 class A {
25 static final a = toto();
26 static final b = b2(b3);
27 static final b2 = decrementCreator();
28 static final b3 = fact(5);
29
30 static toto() => 666;
31
32 static decrementCreator() => (x) => x - 1;
33 static fact(x) {
34 if (x <= 1) return x;
35 return x * fact(x - 1);
36 }
37 }
38
39 main() {
40 Expect.equals(499, x);
41 Expect.equals(6, y);
42 Expect.equals(666, A.a);
43 Expect.equals(119, A.b);
44 Expect.equals(0, t);
45 t2 = 499;
46 Expect.equals(499, t2);
47 Expect.equals(1, count);
48 }
OLDNEW
« lib/compiler/implementation/compiler.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