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

Side by Side Diff: pkg/unittest/lib/src/core_matchers.dart

Issue 20613003: Fix issue in DeepMatcher where == throws. (Closed) Base URL: http://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
« no previous file with comments | « no previous file | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of matcher; 5 part of matcher;
6 6
7 /** 7 /**
8 * Returns a matcher that matches empty strings, maps or iterables 8 * Returns a matcher that matches empty strings, maps or iterables
9 * (including collections). 9 * (including collections).
10 */ 10 */
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 return null; 123 return null;
124 } 124 }
125 } 125 }
126 return null; 126 return null;
127 } 127 }
128 128
129 List _recursiveMatch(expected, actual, String location, int depth) { 129 List _recursiveMatch(expected, actual, String location, int depth) {
130 String reason = null; 130 String reason = null;
131 // If _limit is 1 we can only recurse one level into object. 131 // If _limit is 1 we can only recurse one level into object.
132 bool canRecurse = depth == 0 || _limit > 1; 132 bool canRecurse = depth == 0 || _limit > 1;
133 if (expected == actual) { 133 bool equal;
134 try {
135 equal = (expected == actual);
136 } catch (e,s) {
137 // TODO(gram): Add a test for this case.
138 reason = '== threw "$e"';
139 return [reason, location];
140 }
141 if (equal) {
134 // Do nothing. 142 // Do nothing.
135 } else if (depth > _limit) { 143 } else if (depth > _limit) {
136 reason = 'recursion depth limit exceeded'; 144 reason = 'recursion depth limit exceeded';
137 } else { 145 } else {
138 if (expected is Iterable && canRecurse) { 146 if (expected is Iterable && canRecurse) {
139 List result = _compareIterables(expected, actual, 147 List result = _compareIterables(expected, actual,
140 _recursiveMatch, depth + 1, location); 148 _recursiveMatch, depth + 1, location);
141 if (result != null) { 149 if (result != null) {
142 reason = result[0]; 150 reason = result[0];
143 location = result[1]; 151 location = result[1];
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 var innerDescription = new StringDescription(); 892 var innerDescription = new StringDescription();
885 _matcher.describeMismatch(matchState['feature'], innerDescription, 893 _matcher.describeMismatch(matchState['feature'], innerDescription,
886 matchState['state'], verbose); 894 matchState['state'], verbose);
887 if (innerDescription.length > 0) { 895 if (innerDescription.length > 0) {
888 mismatchDescription.add(' which ').add(innerDescription.toString()); 896 mismatchDescription.add(' which ').add(innerDescription.toString());
889 } 897 }
890 return mismatchDescription; 898 return mismatchDescription;
891 } 899 }
892 } 900 }
893 901
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698