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

Side by Side Diff: tests/lib/mirrors/fake_function_with_call_test.dart

Issue 64793003: Update mirror tests for removed API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 7 years, 1 month 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
« no previous file with comments | « tests/lib/mirrors/equality_test.dart ('k') | tests/lib/mirrors/field_type_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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"; 5 import "dart:mirrors";
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 membersOf(ClassMirror cm) {
10 var result = new Map();
11 cm.declarations.forEach((k,v) {
12 if(v is MethodMirror && !v.isConstructor) result[k] = v;
13 if(v is VariableMirror) result[k] = v;
14 });
15 return result;
16 }
17
9 class WannabeFunction { 18 class WannabeFunction {
10 int call(int a, int b) => a + b; 19 int call(int a, int b) => a + b;
11 method(x) => x * x; 20 method(x) => x * x;
12 } 21 }
13 22
14 main() { 23 main() {
15 Expect.isTrue(new WannabeFunction() is Function); 24 Expect.isTrue(new WannabeFunction() is Function);
16 25
17 ClosureMirror cm = reflect(new WannabeFunction()); 26 ClosureMirror cm = reflect(new WannabeFunction());
18 Expect.equals(7, cm.invoke(#call, [3,4]).reflectee); 27 Expect.equals(7, cm.invoke(#call, [3,4]).reflectee);
(...skipping 13 matching lines...) Expand all
32 Expect.equals(#call, mm.simpleName); 41 Expect.equals(#call, mm.simpleName);
33 Expect.equals(reflectClass(WannabeFunction), mm.owner); 42 Expect.equals(reflectClass(WannabeFunction), mm.owner);
34 Expect.isTrue(mm.isRegularMethod); 43 Expect.isTrue(mm.isRegularMethod);
35 Expect.equals(#int, mm.returnType.simpleName); 44 Expect.equals(#int, mm.returnType.simpleName);
36 Expect.equals(#int, mm.parameters[0].type.simpleName); 45 Expect.equals(#int, mm.parameters[0].type.simpleName);
37 Expect.equals(#int, mm.parameters[1].type.simpleName); 46 Expect.equals(#int, mm.parameters[1].type.simpleName);
38 47
39 ClassMirror km = cm.type; 48 ClassMirror km = cm.type;
40 Expect.equals(reflectClass(WannabeFunction), km); 49 Expect.equals(reflectClass(WannabeFunction), km);
41 Expect.equals(#WannabeFunction, km.simpleName); 50 Expect.equals(#WannabeFunction, km.simpleName);
42 Expect.equals(mm, km.members[#call]); 51 Expect.equals(mm, km.declarations[#call]);
43 Expect.setEquals([#call, #method], km.members.keys); 52 Expect.setEquals([#call, #method], membersOf(km).keys);
44 } 53 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/equality_test.dart ('k') | tests/lib/mirrors/field_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698