OLD | NEW |
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 _fail('$defaultMessage\nDiff:\n[ ]...\n[ $snippet ]...'); | 170 _fail('$defaultMessage\nDiff:\n[ ]...\n[ $snippet ]...'); |
171 return; | 171 return; |
172 } | 172 } |
173 if (expected[eLen - right - 1] != actual[aLen - right - 1]) { | 173 if (expected[eLen - right - 1] != actual[aLen - right - 1]) { |
174 break; | 174 break; |
175 } | 175 } |
176 right++; | 176 right++; |
177 } | 177 } |
178 String eSnippet = expected.substring(left, eLen - right); | 178 String eSnippet = expected.substring(left, eLen - right); |
179 String aSnippet = actual.substring(left, aLen - right); | 179 String aSnippet = actual.substring(left, aLen - right); |
180 String diff = '\nDiff:\n...[ $eSnippet} ]...\n...[ $aSnippet ]...'; | 180 String diff = '\nDiff:\n...[ $eSnippet ]...\n...[ $aSnippet ]...'; |
181 _fail('$defaultMessage$diff'); | 181 _fail('$defaultMessage$diff'); |
182 } | 182 } |
183 | 183 |
184 /** | 184 /** |
185 * Checks that every element of [expected] is also in [actual], and that | 185 * Checks that every element of [expected] is also in [actual], and that |
186 * every element of [actual] is also in [expected]. | 186 * every element of [actual] is also in [expected]. |
187 */ | 187 */ |
188 static void setEquals(Iterable expected, | 188 static void setEquals(Iterable expected, |
189 Iterable actual, | 189 Iterable actual, |
190 [String reason = null]) { | 190 [String reason = null]) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |