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

Side by Side Diff: test_reflectable/test/declarations_test.dart

Issue 1289933004: Implements support for reflection on parameters. (Closed) Base URL: https://github.com/dart-lang/reflectable.git@master
Patch Set: Merging with code from Sigurd, caused several adjustments Created 5 years, 4 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
« no previous file with comments | « test_reflectable/test/capabilities_test.dart ('k') | test_reflectable/test/metadata_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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library test_reflectable.test.declarations_test; 5 library test_reflectable.test.declarations_test;
6 6
7 import "package:reflectable/reflectable.dart"; 7 import "package:reflectable/reflectable.dart";
8 import "package:unittest/unittest.dart"; 8 import "package:unittest/unittest.dart";
9 9
10 class Reflector extends Reflectable { 10 class Reflector extends Reflectable {
11 const Reflector() : super(instanceInvokeCapability, newInstanceCapability); 11 const Reflector()
12 : super(instanceInvokeCapability, newInstanceCapability,
13 declarationsCapability);
12 } 14 }
13 15
14 // TODO(sigurdm) implement: Adapt this test when we support fields. 16 // TODO(sigurdm) implement: Adapt this test when we support fields.
15 17
16 @Reflector() 18 @Reflector()
17 abstract class A { 19 abstract class A {
18 A(); 20 A();
19 A.redirecting() : this(); 21 A.redirecting() : this();
20 factory A.factory() { 22 factory A.factory() {
21 return new B(); 23 return new B();
(...skipping 20 matching lines...) Expand all
42 } 44 }
43 45
44 main() { 46 main() {
45 const reflector = const Reflector(); 47 const reflector = const Reflector();
46 Map<String, DeclarationMirror> declarationsA = 48 Map<String, DeclarationMirror> declarationsA =
47 reflector.reflectType(A).declarations; 49 reflector.reflectType(A).declarations;
48 Map<String, DeclarationMirror> declarationsB = 50 Map<String, DeclarationMirror> declarationsB =
49 reflector.reflectType(B).declarations; 51 reflector.reflectType(B).declarations;
50 52
51 test("declarations", () { 53 test("declarations", () {
52 expect(declarationsA.values.map((x) => x.simpleName), new Set.from([ 54 expect(
53 "foo", 55 declarationsA.values.map((x) => x.simpleName),
54 "getter1", 56 new Set.from([
55 "getter2", 57 "foo",
56 "setter1=", 58 "getter1",
57 "+", 59 "getter2",
58 "A", 60 "setter1=",
59 "A.redirecting", 61 "+",
60 "A.factory", 62 "A",
61 "A.redirectingFactory", 63 "A.redirecting",
62 "A.c" 64 "A.factory",
63 ])); 65 "A.redirectingFactory",
66 "A.c"
67 ]));
64 68
65 expect(declarationsB.values.map((x) => x.simpleName), 69 expect(declarationsB.values.map((x) => x.simpleName),
66 new Set.from(["bar", "getter1", "getter2", "setter2=", "B"])); 70 new Set.from(["bar", "getter1", "getter2", "setter2=", "B"]));
67 }); 71 });
68 72
69 test("MethodMirror properties", () { 73 test("MethodMirror properties", () {
70 MethodMirror foo = declarationsA["foo"] as MethodMirror; 74 MethodMirror foo = declarationsA["foo"] as MethodMirror;
71 expect(foo.isRegularMethod, isTrue); 75 expect(foo.isRegularMethod, isTrue);
72 expect(foo.isStatic, isFalse); 76 expect(foo.isStatic, isFalse);
73 expect(foo.isGetter, isFalse); 77 expect(foo.isGetter, isFalse);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 expect(redirectingFactoryConstructorA.isConstructor, isTrue); 159 expect(redirectingFactoryConstructorA.isConstructor, isTrue);
156 expect(redirectingFactoryConstructorA.isGenerativeConstructor, isFalse); 160 expect(redirectingFactoryConstructorA.isGenerativeConstructor, isFalse);
157 expect(redirectingFactoryConstructorA.isFactoryConstructor, isTrue); 161 expect(redirectingFactoryConstructorA.isFactoryConstructor, isTrue);
158 expect(redirectingFactoryConstructorA.isConstConstructor, isTrue); 162 expect(redirectingFactoryConstructorA.isConstConstructor, isTrue);
159 expect(redirectingFactoryConstructorA.isRedirectingConstructor, isTrue); 163 expect(redirectingFactoryConstructorA.isRedirectingConstructor, isTrue);
160 }); 164 });
161 165
162 test("instanceMethods", () { 166 test("instanceMethods", () {
163 Map<String, DeclarationMirror> instanceMembersA = 167 Map<String, DeclarationMirror> instanceMembersA =
164 reflector.reflectType(A).instanceMembers; 168 reflector.reflectType(A).instanceMembers;
165 expect(instanceMembersA.values.map((x) => x.simpleName), new Set.from([ 169 expect(
166 "toString", 170 instanceMembersA.values.map((x) => x.simpleName),
167 "hashCode", 171 new Set.from([
168 "==", 172 "toString",
169 "noSuchMethod", 173 "hashCode",
170 "runtimeType", 174 "==",
171 "foo", 175 "noSuchMethod",
172 "getter1", 176 "runtimeType",
173 "setter1=", 177 "foo",
174 "+" 178 "getter1",
175 ])); 179 "setter1=",
180 "+"
181 ]));
176 Map<String, DeclarationMirror> instanceMembersB = 182 Map<String, DeclarationMirror> instanceMembersB =
177 reflector.reflectType(B).instanceMembers; 183 reflector.reflectType(B).instanceMembers;
178 expect(instanceMembersB.values.map((x) => x.simpleName), new Set.from([ 184 expect(
179 "toString", 185 instanceMembersB.values.map((x) => x.simpleName),
180 "hashCode", 186 new Set.from([
181 "==", 187 "toString",
182 "noSuchMethod", 188 "hashCode",
183 "runtimeType", 189 "==",
184 "foo", 190 "noSuchMethod",
185 "bar", 191 "runtimeType",
186 "getter1", 192 "foo",
187 "getter2", 193 "bar",
188 "setter1=", 194 "getter1",
189 "setter2=", 195 "getter2",
190 "+" 196 "setter1=",
191 ])); 197 "setter2=",
198 "+"
199 ]));
192 }); 200 });
193 } 201 }
OLDNEW
« no previous file with comments | « test_reflectable/test/capabilities_test.dart ('k') | test_reflectable/test/metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698