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

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

Issue 12210100: If two Maps are compared with an equals() matcher and they have the same length, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 | pkg/unittest/test/matchers_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) 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 reason = new StringDescription('recursion depth limit exceeded'); 134 reason = new StringDescription('recursion depth limit exceeded');
135 } else { 135 } else {
136 if (expected is Iterable && canRecurse) { 136 if (expected is Iterable && canRecurse) {
137 String r = _compareIterables(expected, actual, 137 String r = _compareIterables(expected, actual,
138 _recursiveMatch, depth+1); 138 _recursiveMatch, depth+1);
139 if (r != null) reason = new StringDescription(r); 139 if (r != null) reason = new StringDescription(r);
140 } else if (expected is Map && canRecurse) { 140 } else if (expected is Map && canRecurse) {
141 if (actual is !Map) { 141 if (actual is !Map) {
142 reason = new StringDescription('expected a map'); 142 reason = new StringDescription('expected a map');
143 } else if (expected.length != actual.length) { 143 } else if (expected.length != actual.length) {
144 reason = new StringDescription('different map lengths'); 144 reason = new StringDescription('different map lengths');
Jennifer Messerly 2013/02/09 23:53:06 The bug was about this line. Unless I'm really con
Jennifer Messerly 2013/02/10 00:01:40 Here's a possible way to refactor this code. Not s
gram 2013/02/11 20:43:35 I have changed it so that it will print the mismat
145 } else { 145 } else {
146 for (var key in expected.keys) { 146 for (var key in expected.keys) {
147 if (!actual.containsKey(key)) { 147 if (!actual.containsKey(key)) {
148 reason = new StringDescription('missing map key '); 148 reason = new StringDescription('missing map key $key ');
149 reason.addDescriptionOf(key); 149 reason.addDescriptionOf(key);
150 break; 150 break;
151 } 151 }
152 reason = _recursiveMatch(expected[key], actual[key], 152 reason = _recursiveMatch(expected[key], actual[key],
153 'with key <${key}> ${location}', depth+1); 153 'with key <${key}> ${location}', depth+1);
154 if (reason != null) { 154 if (reason != null) {
155 break; 155 break;
156 } 156 }
157 } 157 }
158 } 158 }
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); 697 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher);
698 698
699 Description describeMismatch(item, Description mismatchDescription, 699 Description describeMismatch(item, Description mismatchDescription,
700 MatchState matchState, bool verbose) { 700 MatchState matchState, bool verbose) {
701 mismatchDescription.add(_featureName).add(' '); 701 mismatchDescription.add(_featureName).add(' ');
702 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, 702 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription,
703 matchState.state['innerState'], verbose); 703 matchState.state['innerState'], verbose);
704 return mismatchDescription; 704 return mismatchDescription;
705 } 705 }
706 } 706 }
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/test/matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698