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

Unified Diff: pkg/unittest/lib/mirror_matchers.dart

Issue 84993006: Remove use of deprecated mirror API from pkg/unittest. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: test 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 | « no previous file | pkg/unittest/test/mirror_matchers_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/mirror_matchers.dart
diff --git a/pkg/unittest/lib/mirror_matchers.dart b/pkg/unittest/lib/mirror_matchers.dart
index 7d1597f2ac27f59c752109141a93a6a58ce6c51c..25f2b6d69206d80b4b77bedadd1901eafd634b09 100644
--- a/pkg/unittest/lib/mirror_matchers.dart
+++ b/pkg/unittest/lib/mirror_matchers.dart
@@ -49,10 +49,19 @@ class _HasProperty extends Matcher {
var mirror = reflect(item);
var classMirror = mirror.type;
var symbol = new Symbol(_name);
- if (!classMirror.getters.containsKey(symbol)) {
+ var candidate = classMirror.declarations[symbol];
+ if (candidate == null) {
addStateInfo(matchState, {'reason': 'has no property named "$_name"'});
return false;
}
+ bool isInstanceField = candidate is VariableMirror && !candidate.isStatic;
+ bool isInstanceGetter =
+ candidate is MethodMirror && candidate.isGetter && !candidate.isStatic;
+ if (!(isInstanceField || isInstanceGetter)) {
+ addStateInfo(matchState, {'reason':
+ 'has a member named "$_name", but it is not an instance property'});
+ return false;
+ }
if (_matcher == null) return true;
var result = mirror.getField(symbol);
var resultMatches = _matcher.matches(result.reflectee, matchState);
« no previous file with comments | « no previous file | pkg/unittest/test/mirror_matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698