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

Unified Diff: tests/lib/mirrors/reflect_model_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/lib/mirrors/reflect_class_test.dart ('k') | tests/lib/mirrors/reflect_runtime_type_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/reflect_model_test.dart
diff --git a/tests/lib/mirrors/reflect_model_test.dart b/tests/lib/mirrors/reflect_model_test.dart
index 69239e1e16db3d81091c651f41a27c2095531426..b1fe3b31c9c3a97afbda8dd520558095b908bfee 100644
--- a/tests/lib/mirrors/reflect_model_test.dart
+++ b/tests/lib/mirrors/reflect_model_test.dart
@@ -13,6 +13,38 @@ import 'stringify.dart';
isNoSuchMethodError(e) => e is NoSuchMethodError;
+variablesOf(ClassMirror cm) {
+ var result = new Map();
+ cm.declarations.forEach((k,v) {
+ if (v is VariableMirror) result[k] = v;
+ });
+ return result;
+}
+
+gettersOf(ClassMirror cm) {
+ var result = new Map();
+ cm.declarations.forEach((k,v) {
+ if (v is MethodMirror && v.isGetter) result[k] = v;
+ });
+ return result;
+}
+
+settersOf(ClassMirror cm) {
+ var result = new Map();
+ cm.declarations.forEach((k,v) {
+ if (v is MethodMirror && v.isSetter) result[k] = v;
+ });
+ return result;
+}
+
+methodsOf(ClassMirror cm) {
+ var result = new Map();
+ cm.declarations.forEach((k,v) {
+ if (v is MethodMirror && v.isRegularMethod) result[k] = v;
+ });
+ return result;
+}
+
main() {
var unnamed = new Symbol('');
var field = new Symbol('field');
@@ -29,9 +61,9 @@ main() {
var b = bClass.newInstance(unnamed, []);
var c = cClass.newInstance(unnamed, []);
- expect('{field: Variable(s(field) in s(A))}', aClass.variables);
- expect('{}', bClass.variables);
- expect('{}', cClass.variables);
+ expect('{field: Variable(s(field) in s(A))}', variablesOf(aClass));
+ expect('{}', variablesOf(bClass));
+ expect('{}', variablesOf(cClass));
Expect.isNull(a.getField(field).reflectee);
Expect.equals('B:get field', b.getField(field).reflectee);
@@ -48,21 +80,21 @@ main() {
expect('{accessor: Method(s(accessor) in s(A), getter)'
'}',
- aClass.getters);
+ gettersOf(aClass));
expect('{accessor: Method(s(accessor) in s(B), getter)'
', field: Method(s(field) in s(B), getter)}',
- bClass.getters);
+ gettersOf(bClass));
expect('{accessor: Method(s(accessor) in s(C), getter)}',
- cClass.getters);
+ gettersOf(cClass));
expect('{accessor=: Method(s(accessor=) in s(A), setter)'
'}',
- aClass.setters);
+ settersOf(aClass));
expect('{accessor=: Method(s(accessor=) in s(B), setter)}',
- bClass.setters);
+ settersOf(bClass));
expect('{accessor=: Method(s(accessor=) in s(C), setter)'
', field=: Method(s(field=) in s(C), setter)}',
- cClass.setters);
+ settersOf(cClass));
Expect.equals('A:instanceMethod(7)', a.invoke(instanceMethod, [7]).reflectee);
Expect.equals('B:instanceMethod(9)', b.invoke(instanceMethod, [9]).reflectee);
@@ -72,16 +104,16 @@ main() {
expect(
'{aMethod: Method(s(aMethod) in s(A))'
', instanceMethod: Method(s(instanceMethod) in s(A))}',
- aClass.methods);
+ methodsOf(aClass));
expect(
'{bMethod: Method(s(bMethod) in s(B))'
', instanceMethod: Method(s(instanceMethod) in s(B))}',
- bClass.methods);
+ methodsOf(bClass));
expect(
'{cMethod: Method(s(cMethod) in s(C))'
', instanceMethod: Method(s(instanceMethod) in s(C))}',
- cClass.methods);
+ methodsOf(cClass));
Expect.equals('A:get accessor', a.getField(accessor).reflectee);
Expect.equals('B:get accessor', b.getField(accessor).reflectee);
« no previous file with comments | « tests/lib/mirrors/reflect_class_test.dart ('k') | tests/lib/mirrors/reflect_runtime_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698