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

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

Issue 14251021: Move invokeOn to InstanceMirror. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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
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 "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
6 7
7 // Testing Invocation.invokeOn method; test of issue 7227. 8 // Testing InstanceMirror.delegate method; test of issue 7227.
8 9
9 var reachedSetX = 0; 10 var reachedSetX = 0;
10 var reachedGetX = 0; 11 var reachedGetX = 0;
11 var reachedM = 0; 12 var reachedM = 0;
12 13
13 class A { 14 class A {
14 15
15 set x(val) { 16 set x(val) {
16 reachedSetX = val; 17 reachedSetX = val;
17 } 18 }
18 19
19 get x { 20 get x {
20 reachedGetX = 1; 21 reachedGetX = 1;
21 } 22 }
22 23
23 m() { reachedM = 1; } 24 m() { reachedM = 1; }
24 } 25 }
25 26
26 class B { 27 class B {
27 final a = new A(); 28 final a = new A();
28 noSuchMethod(mirror) => mirror.invokeOn(a); 29 noSuchMethod(mirror) => reflect(a).delegate(mirror);
29 } 30 }
30 31
31 main () { 32 main () {
32 var b = new B(); 33 var b = new B();
33 b.x = 10; 34 b.x = 10;
34 Expect.equals(10, reachedSetX); 35 Expect.equals(10, reachedSetX);
35 b.x; 36 b.x;
36 Expect.equals(1, reachedGetX); 37 Expect.equals(1, reachedGetX);
37 b.m(); 38 b.m();
38 Expect.equals(1, reachedM); 39 Expect.equals(1, reachedM);
39 } 40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698