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

Side by Side Diff: tests/language/closure_in_initializer_test.dart

Issue 11273121: Support closures inside initializers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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
ahe 2012/11/06 15:14:22 What does this test do?
5 class A {
6 var f;
7 var g;
8 A(a) : f = (() => 42 + a), g = (() => ++a) {
9 a = 4;
10 }
11 }
12
13 class B extends A {
14 B() : super(42);
15 }
16
17 class C extends A {
18 var h;
19 C(a) : super(42), h = (() => ++a);
20 }
21
22 main() {
23 var a = new A(1);
24 Expect.equals(46, a.f());
25 Expect.equals(5, a.g());
26 Expect.equals(47, a.f());
27
28 a = new B();
29 Expect.equals(46, a.f());
30 Expect.equals(5, a.g());
31 Expect.equals(47, a.f());
32
33 a = new C(0);
34 Expect.equals(46, a.f());
35 Expect.equals(5, a.g());
36 Expect.equals(47, a.f());
37 Expect.equals(1, a.h());
38 Expect.equals(2, a.h());
39 Expect.equals(47, a.f());
40 Expect.equals(6, a.g());
41 Expect.equals(48, a.f());
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698