OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // Dart test program for testing invocation of implicit closures. | 4 // Dart test program for testing invocation of implicit closures. |
5 | 5 |
| 6 import "package:expect/expect.dart"; |
| 7 |
6 class BaseClass { | 8 class BaseClass { |
7 BaseClass(this._i) {} | 9 BaseClass(this._i) {} |
8 int foo() { return _i; } | 10 int foo() { return _i; } |
9 int _i; | 11 int _i; |
10 } | 12 } |
11 | 13 |
12 class DerivedClass extends BaseClass { | 14 class DerivedClass extends BaseClass { |
13 DerivedClass(this._y, int j) : super(j) {} | 15 DerivedClass(this._y, int j) : super(j) {} |
14 int foo() { return _y; } | 16 int foo() { return _y; } |
15 getSuper() { return super.foo; } | 17 getSuper() { return super.foo; } |
16 int _y; | 18 int _y; |
17 } | 19 } |
18 | 20 |
19 class SuperImplicitClosureTest { | 21 class SuperImplicitClosureTest { |
20 static void testMain() { | 22 static void testMain() { |
21 DerivedClass obj = new DerivedClass(20, 10); | 23 DerivedClass obj = new DerivedClass(20, 10); |
22 | 24 |
23 var ib = obj.foo; | 25 var ib = obj.foo; |
24 Expect.equals(obj._y, ib()); | 26 Expect.equals(obj._y, ib()); |
25 | 27 |
26 ib = obj.getSuper(); | 28 ib = obj.getSuper(); |
27 Expect.equals(obj._i, ib()); | 29 Expect.equals(obj._i, ib()); |
28 } | 30 } |
29 } | 31 } |
30 | 32 |
31 | 33 |
32 main() { | 34 main() { |
33 SuperImplicitClosureTest.testMain(); | 35 SuperImplicitClosureTest.testMain(); |
34 } | 36 } |
OLD | NEW |