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

Unified Diff: test_reflectable/test/declarations_test.dart

Issue 1182083002: Implement `.instanceMembers`. (Closed) Base URL: https://github.com/dart-lang/reflectable.git@master
Patch Set: Rebase Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test_reflectable/pubspec.yaml ('k') | test_reflectable/test/invoke_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test_reflectable/test/declarations_test.dart
diff --git a/test_reflectable/test/declarations_test.dart b/test_reflectable/test/declarations_test.dart
index 75a4dde98260436572f4a4589ad36cd60c946406..7a87a2a05607c4b3069d2c8babc2af33e618eeca 100644
--- a/test_reflectable/test/declarations_test.dart
+++ b/test_reflectable/test/declarations_test.dart
@@ -13,6 +13,8 @@ class Reflector extends Reflectable {
const Reflector() : super(instanceInvokeCapability);
}
+// TODO(sigurdm): Adapt this test when we support fields.
+
@Reflector()
abstract class A {
A();
@@ -43,14 +45,13 @@ class B extends A {
main() {
const reflector = const Reflector();
- test("Test declarations", () {
- // TODO(sigurdm): Adapt this test when we support constructors, fields,
- // in declarations.
- Map<String, DeclarationMirror> declarationsA =
- reflector.reflectType(A).declarations;
- expect(declarationsA.values
- .where((DeclarationMirror x) => x is MethodMirror)
- .map((x) => x.simpleName), new Set.from([
+ Map<String, DeclarationMirror> declarationsA =
+ reflector.reflectType(A).declarations;
+ Map<String, DeclarationMirror> declarationsB =
+ reflector.reflectType(B).declarations;
+
+ test("declarations", () {
+ expect(declarationsA.values.map((x) => x.simpleName), new Set.from([
"foo",
"getter1",
"getter2",
@@ -62,6 +63,12 @@ main() {
"A.redirectingFactory",
"A.c"
]));
+
+ expect(declarationsB.values.map((x) => x.simpleName),
+ new Set.from(["bar", "getter1", "getter2", "setter2=", "B"]));
+ });
+
+ test("MethodMirror properties", () {
MethodMirror foo = declarationsA["foo"] as MethodMirror;
expect(foo.isRegularMethod, isTrue);
expect(foo.isStatic, isFalse);
@@ -152,10 +159,37 @@ main() {
expect(redirectingFactoryConstructorA.isFactoryConstructor, isTrue);
expect(redirectingFactoryConstructorA.isConstConstructor, isTrue);
expect(redirectingFactoryConstructorA.isRedirectingConstructor, isTrue);
- var declarationsB = reflector.reflectType(B).declarations;
- expect(declarationsB.values
- .where((DeclarationMirror x) => x is MethodMirror)
- .map((x) => x.simpleName),
- new Set.from(["bar", "getter1", "getter2", "setter2=", "B"]));
+ });
+
+ test("instanceMethods", () {
+ Map<String, DeclarationMirror> instanceMembersA =
+ reflector.reflectType(A).instanceMembers;
+ expect(instanceMembersA.values.map((x) => x.simpleName), new Set.from([
+ "toString",
+ "hashCode",
+ "==",
+ "noSuchMethod",
+ "runtimeType",
+ "foo",
+ "getter1",
+ "setter1=",
+ "+"
+ ]));
+ Map<String, DeclarationMirror> instanceMembersB =
+ reflector.reflectType(B).instanceMembers;
+ expect(instanceMembersB.values.map((x) => x.simpleName), new Set.from([
+ "toString",
+ "hashCode",
+ "==",
+ "noSuchMethod",
+ "runtimeType",
+ "foo",
+ "bar",
+ "getter1",
+ "getter2",
+ "setter1=",
+ "setter2=",
+ "+"
+ ]));
});
}
« no previous file with comments | « test_reflectable/pubspec.yaml ('k') | test_reflectable/test/invoke_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698