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

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

Issue 19299003: Moved some MethodMirror properties from embedded API to native calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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
« runtime/lib/mirrors.cc ('K') | « runtime/vm/bootstrap_natives.h ('k') | no next file » | 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 "../../../pkg/unittest/lib/unittest.dart"; 7 import "../../../pkg/unittest/lib/unittest.dart";
ahe 2013/07/16 20:36:53 It would be great if you could avoid using the uni
Michael Lippautz (Google) 2013/07/16 21:14:00 Using stringify.dart or expect/expect.dart now. Do
8 8
9 String _symbolToString(Symbol sym) { 9 String _symbolToString(Symbol sym) {
10 return MirrorSystem.getName(sym); 10 return MirrorSystem.getName(sym);
11 } 11 }
12 12
13 doNothing42() {} 13 doNothing42() {}
14 14
15 int _x = 5;
16 int get topGetter => _x;
17 void set topSetter(x) { _x = x }
18
19 class AbstractC {
20
21 AbstractC();
22
23 void bar();
24 get priv;
25 set priv(value);
26 }
27
28 class C extends AbstractC {
29
30 static foo() {}
31
32 C();
33 C.other();
34 C.other2() : this.other();
35
36 var _priv;
37 get priv => _priv;
38 set priv(value) => _priv = value;
39 }
40
41 checkKinds(method, kinds) {
42 expect(method.isStatic, kinds[0]);
43 expect(method.isAbstract, kinds[1]);
44 expect(method.isGetter, kinds[2]);
45 expect(method.isSetter, kinds[3]);
46 expect(method.isConstructor, kinds[4]);
47 }
48
15 main() { 49 main() {
16 // Regression test for http://www.dartbug.com/6335 50 // Regression test for http://www.dartbug.com/6335
17 test("NamedMethodName", () { 51 test("NamedMethodName", () {
18 var closureMirror = reflect(doNothing42); 52 var closureMirror = reflect(doNothing42);
19 expect(_symbolToString(closureMirror.function.simpleName), "doNothing42"); 53 expect(_symbolToString(closureMirror.function.simpleName), "doNothing42");
20 }); 54 });
55 test("FunctionKinds", () {
ahe 2013/07/16 20:36:53 As far as I can tell, the added tests reuse virtua
Michael Lippautz (Google) 2013/07/16 21:14:00 Done.
56 // Top level functions should be static.
57 var closureMirror = reflect(doNothing42);
58 checkKinds(closureMirror.function,
59 [true, false, false, false, false]);
60 var libraryMirror = reflectClass(C).owner;
61 checkKinds(libraryMirror.getters[const Symbol("topGetter")],
62 [true, false, true, false, false]);
63 checkKinds(libraryMirror.setters[const Symbol("topSetter=")],
64 [true, false, false, true, false]);
65 var classMirror;
66 classMirror = reflectClass(C);
67 checkKinds(classMirror.members[const Symbol("foo")],
68 [true, false, false, false, false]);
69 checkKinds(classMirror.members[const Symbol("priv")],
70 [false, false, true, false, false]);
71 checkKinds(classMirror.members[const Symbol("priv=")],
72 [false, false, false, true, false]);
73 checkKinds(classMirror.constructors[const Symbol("C")],
74 [false, false, false, false, true]);
75 checkKinds(classMirror.constructors[const Symbol("C.other")],
76 [false, false, false, false, true]);
77 checkKinds(classMirror.constructors[const Symbol("C.other2")],
78 [false, false, false, false, true]);
79 classMirror = reflectClass(AbstractC);
80 checkKinds(classMirror.constructors[const Symbol("AbstractC")],
81 [false, false, false, false, true]);
82 checkKinds(classMirror.members[const Symbol("bar")],
83 [false, true, false, false, false]);
84 checkKinds(classMirror.members[const Symbol("priv")],
85 [false, true, true, false, false]);
86 checkKinds(classMirror.members[const Symbol("priv=")],
87 [false, true, false, true, false]);
88 });
21 } 89 }
OLDNEW
« runtime/lib/mirrors.cc ('K') | « runtime/vm/bootstrap_natives.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698