OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 | 4 |
5 import "dart:mirrors" show reflect; | 5 import "dart:mirrors" show reflect; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 // Testing InstanceMirror.delegate method; test of issue 7227. | 8 // Testing InstanceMirror.delegate method; test of issue 7227. |
9 | 9 |
10 var reachedSetX = 0; | 10 var reachedSetX = 0; |
11 var reachedGetX = 0; | 11 var reachedGetX = 0; |
12 var reachedM = 0; | 12 var reachedM = 0; |
13 | 13 |
14 class A { | 14 class A { |
15 | |
16 set x(val) { | 15 set x(val) { |
17 reachedSetX = val; | 16 reachedSetX = val; |
18 } | 17 } |
19 | 18 |
20 get x { | 19 get x { |
21 reachedGetX = 1; | 20 reachedGetX = 1; |
22 } | 21 } |
23 | 22 |
24 m() { reachedM = 1; } | 23 m() { |
| 24 reachedM = 1; |
| 25 } |
25 } | 26 } |
26 | 27 |
27 class B { | 28 class B { |
28 final a = new A(); | 29 final a = new A(); |
29 noSuchMethod(mirror) => reflect(a).delegate(mirror); | 30 noSuchMethod(mirror) => reflect(a).delegate(mirror); |
30 } | 31 } |
31 | 32 |
32 main () { | 33 main() { |
33 var b = new B(); | 34 var b = new B(); |
34 b.x = 10; | 35 b.x = 10; |
35 Expect.equals(10, reachedSetX); | 36 Expect.equals(10, reachedSetX); |
36 b.x; | 37 b.x; |
37 Expect.equals(1, reachedGetX); | 38 Expect.equals(1, reachedGetX); |
38 b.m(); | 39 b.m(); |
39 Expect.equals(1, reachedM); | 40 Expect.equals(1, reachedM); |
40 } | 41 } |
OLD | NEW |