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

Side by Side Diff: corelib/src/expect.dart

Issue 8576008: Fix Expect.listEquals error message. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 class Expect { 5 class Expect {
6 6
7 /** 7 /**
8 * Checks whether the expected and actual values are equal (using [:==:]). 8 * Checks whether the expected and actual values are equal (using [:==:]).
9 */ 9 */
10 static void equals(var expected, var actual, [String reason = null]) { 10 static void equals(var expected, var actual, [String reason = null]) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 * This is different than the typical check for identity equality [:===:] 97 * This is different than the typical check for identity equality [:===:]
98 * used by the standard list implementation. It should also produce nicer 98 * used by the standard list implementation. It should also produce nicer
99 * error messages than just calling [:Expect.equals(expected, actual):]. 99 * error messages than just calling [:Expect.equals(expected, actual):].
100 */ 100 */
101 static void listEquals(List expected, List actual, [String reason = null]) { 101 static void listEquals(List expected, List actual, [String reason = null]) {
102 String msg = _getMessage(reason); 102 String msg = _getMessage(reason);
103 int n = Math.min(expected.length, actual.length); 103 int n = Math.min(expected.length, actual.length);
104 for (int i = 0; i < n; i++) { 104 for (int i = 0; i < n; i++) {
105 if (expected[i] != actual[i]) { 105 if (expected[i] != actual[i]) {
106 _fail('Expect.listEquals(at index $i, ' + 106 _fail('Expect.listEquals(at index $i, ' +
107 'expected: <${expected[0]}>, actual: <${actual[i]}>$msg) fails'); 107 'expected: <${expected[i]}>, actual: <${actual[i]}>$msg) fails');
108 } 108 }
109 } 109 }
110 // We check on length at the end in order to provide better error 110 // We check on length at the end in order to provide better error
111 // messages when an unexpected item is inserted in a list. 111 // messages when an unexpected item is inserted in a list.
112 if (expected.length != actual.length) { 112 if (expected.length != actual.length) {
113 _fail('Expect.listEquals(list length, ' + 113 _fail('Expect.listEquals(list length, ' +
114 'expected: <${expected.length}>, actual: <${actual.length}>$msg) ' + 114 'expected: <${expected.length}>, actual: <${actual.length}>$msg) ' +
115 'fails'); 115 'fails');
116 } 116 }
117 } 117 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 } 252 }
253 253
254 typedef bool _CheckExceptionFn(exception); 254 typedef bool _CheckExceptionFn(exception);
255 255
256 class ExpectException implements Exception { 256 class ExpectException implements Exception {
257 ExpectException(this.message); 257 ExpectException(this.message);
258 String toString() => message; 258 String toString() => message;
259 String message; 259 String message;
260 } 260 }
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