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

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

Issue 9369006: First prototype of import map generator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix path to JSON. Created 8 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 | « client/testing/unittest/unittest_vm.dart ('k') | tools/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) 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
118 118
119 /**
120 * Checks that all [expected] and [actual] have the same set of keys (using
121 * the semantics of [Map.containsKey] to determine what "same" means. For
122 * each key, checks that the values in both maps are equal using [:==:].
123 */
124 static void mapEquals(Map expected, Map actual, [String reason = null]) {
125 String msg = _getMessage(reason);
126
127 // Make sure all of the values are present in both and match.
128 for (final key in expected.getKeys()) {
129 if (!actual.containsKey(key)) {
130 _fail('Expect.mapEquals(missing expected key: <$key>$msg) fails');
131 }
132
133 Expect.equals(expected[key], actual[key]);
134 }
135
136 // Make sure the actual map doesn't have any extra keys.
137 for (final key in actual.getKeys()) {
138 if (!expected.containsKey(key)) {
139 _fail('Expect.mapEquals(unexpected key: <$key>$msg) fails');
140 }
141 }
142 }
119 143
120 /** 144 /**
121 * Specialized equality test for strings. When the strings don't match, 145 * Specialized equality test for strings. When the strings don't match,
122 * this method shows where the mismatch starts and ends. 146 * this method shows where the mismatch starts and ends.
123 */ 147 */
124 static void stringEquals(String expected, 148 static void stringEquals(String expected,
125 String actual, 149 String actual,
126 [String reason = null]) { 150 [String reason = null]) {
127 String msg = _getMessage(reason); 151 String msg = _getMessage(reason);
128 String defaultMessage = 152 String defaultMessage =
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 275 }
252 } 276 }
253 277
254 typedef bool _CheckExceptionFn(exception); 278 typedef bool _CheckExceptionFn(exception);
255 279
256 class ExpectException implements Exception { 280 class ExpectException implements Exception {
257 ExpectException(this.message); 281 ExpectException(this.message);
258 String toString() => message; 282 String toString() => message;
259 String message; 283 String message;
260 } 284 }
OLDNEW
« no previous file with comments | « client/testing/unittest/unittest_vm.dart ('k') | tools/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698