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

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

Issue 14066019: Change memberName and namedArguments in Invocation to use Symbol. (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 "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 7
8 class GetName { 8 class GetName {
9 foo({a, b}) => "foo"; 9 foo({a, b}) => "foo";
10 moo({b}) => "moo"; 10 moo({b}) => "moo";
11 } 11 }
12 12
13 String getName(im) => im.invokeOn(new GetName()); 13 String getName(im) => im.invokeOn(new GetName());
14 14
15 class NoSuchMethodTest { 15 class NoSuchMethodTest {
16 16
17 foo({a : 10, b : 20}) { 17 foo({a : 10, b : 20}) {
18 return (10 * a) + b; 18 return (10 * a) + b;
19 } 19 }
20 20
21 noSuchMethod(Invocation im) { 21 noSuchMethod(Invocation im) {
22 Expect.equals("moo", getName(im)); 22 Expect.equals("moo", getName(im));
23 Expect.equals(0, im.positionalArguments.length); 23 Expect.equals(0, im.positionalArguments.length);
24 Expect.equals(1, im.namedArguments.length); 24 Expect.equals(1, im.namedArguments.length);
25 return foo(b:im.namedArguments["b"]); 25 return foo(b:im.namedArguments[const Symbol("b")]);
26 } 26 }
27 27
28 static testMain() { 28 static testMain() {
29 var obj = new NoSuchMethodTest(); 29 var obj = new NoSuchMethodTest();
30 Expect.equals(199, obj.moo(b:99)); // obj.NoSuchMethod called here. 30 Expect.equals(199, obj.moo(b:99)); // obj.NoSuchMethod called here.
31 } 31 }
32 } 32 }
33 33
34 main() { 34 main() {
35 NoSuchMethodTest.testMain(); 35 NoSuchMethodTest.testMain();
36 } 36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698