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

Side by Side Diff: dart/tests/language/no_such_method_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) 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 testing that NoSuchMethod is properly called. 4 // Dart test program testing that NoSuchMethod is properly called.
5 5
6 import "dart:mirrors" show reflect;
6 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
7 8
8 class GetName { 9 class GetName {
9 foo({a, b}) => "foo"; 10 foo({a, b}) => "foo";
10 moo({b}) => "moo"; 11 moo({b}) => "moo";
11 } 12 }
12 13
13 String getName(im) => im.invokeOn(new GetName()); 14 String getName(im) => reflect(new GetName()).delegate(im);
14 15
15 class NoSuchMethodTest { 16 class NoSuchMethodTest {
16 17
17 foo({a : 10, b : 20}) { 18 foo({a : 10, b : 20}) {
18 return (10 * a) + b; 19 return (10 * a) + b;
19 } 20 }
20 21
21 noSuchMethod(Invocation im) { 22 noSuchMethod(Invocation im) {
22 Expect.equals("moo", getName(im)); 23 Expect.equals("moo", getName(im));
23 Expect.equals(0, im.positionalArguments.length); 24 Expect.equals(0, im.positionalArguments.length);
24 Expect.equals(1, im.namedArguments.length); 25 Expect.equals(1, im.namedArguments.length);
25 return foo(b:im.namedArguments[const Symbol("b")]); 26 return foo(b:im.namedArguments[const Symbol("b")]);
26 } 27 }
27 28
28 static testMain() { 29 static testMain() {
29 var obj = new NoSuchMethodTest(); 30 var obj = new NoSuchMethodTest();
30 Expect.equals(199, obj.moo(b:99)); // obj.NoSuchMethod called here. 31 Expect.equals(199, obj.moo(b:99)); // obj.NoSuchMethod called here.
31 } 32 }
32 } 33 }
33 34
34 main() { 35 main() {
35 NoSuchMethodTest.testMain(); 36 NoSuchMethodTest.testMain();
36 } 37 }
OLDNEW
« no previous file with comments | « dart/tests/language/many_overridden_no_such_method_test.dart ('k') | dart/tests/language/overridden_no_such_method.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698