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

Side by Side Diff: sdk/lib/core/expect.dart

Issue 11308305: More cleanups === => identical (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | « runtime/lib/expando_patch.dart ('k') | 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 /** 5 /**
6 * Expect is used for tests that do not want to make use of the 6 * Expect is used for tests that do not want to make use of the
7 * Dart unit test library - for example, the core language tests. 7 * Dart unit test library - for example, the core language tests.
8 * Third parties are discouraged from using this, and should use 8 * Third parties are discouraged from using this, and should use
9 * the expect() function in the unit test library instead for 9 * the expect() function in the unit test library instead for
10 * test assertions. 10 * test assertions.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 * Checks whether [actual] is not null. 50 * Checks whether [actual] is not null.
51 */ 51 */
52 static void isNotNull(actual, [String reason = null]) { 52 static void isNotNull(actual, [String reason = null]) {
53 if (null != actual) return; 53 if (null != actual) return;
54 String msg = _getMessage(reason); 54 String msg = _getMessage(reason);
55 _fail("Expect.isNotNull(actual: <$actual>$msg) fails."); 55 _fail("Expect.isNotNull(actual: <$actual>$msg) fails.");
56 } 56 }
57 57
58 /** 58 /**
59 * Checks whether the expected and actual values are identical 59 * Checks whether the expected and actual values are identical
60 * (using `===`). 60 * (using `identical`).
61 */ 61 */
62 static void identical(var expected, var actual, [String reason = null]) { 62 static void identical(var expected, var actual, [String reason = null]) {
63 if (_identical(expected, actual)) return; 63 if (_identical(expected, actual)) return;
64 String msg = _getMessage(reason); 64 String msg = _getMessage(reason);
65 _fail("Expect.identical(expected: <$expected>, actual: <$actual>$msg) " 65 _fail("Expect.identical(expected: <$expected>, actual: <$actual>$msg) "
66 "fails."); 66 "fails.");
67 } 67 }
68 68
69 // Unconditional failure. 69 // Unconditional failure.
70 static void fail(String msg) { 70 static void fail(String msg) {
(...skipping 22 matching lines...) Expand all
93 93
94 static void notEquals(unexpected, actual, [String reason = null]) { 94 static void notEquals(unexpected, actual, [String reason = null]) {
95 if (unexpected != actual) return; 95 if (unexpected != actual) return;
96 String msg = _getMessage(reason); 96 String msg = _getMessage(reason);
97 _fail("Expect.notEquals(unexpected: <$unexpected>, actual:<$actual>$msg) " 97 _fail("Expect.notEquals(unexpected: <$unexpected>, actual:<$actual>$msg) "
98 "fails."); 98 "fails.");
99 } 99 }
100 100
101 /** 101 /**
102 * Checks that all elements in [expected] and [actual] are equal `==`. 102 * Checks that all elements in [expected] and [actual] are equal `==`.
103 * This is different than the typical check for identity equality `===` 103 * This is different than the typical check for identity equality `identical`
104 * used by the standard list implementation. It should also produce nicer 104 * used by the standard list implementation. It should also produce nicer
105 * error messages than just calling `Expect.equals(expected, actual)`. 105 * error messages than just calling `Expect.equals(expected, actual)`.
106 */ 106 */
107 static void listEquals(List expected, List actual, [String reason = null]) { 107 static void listEquals(List expected, List actual, [String reason = null]) {
108 String msg = _getMessage(reason); 108 String msg = _getMessage(reason);
109 int n = (expected.length < actual.length) ? expected.length : actual.length; 109 int n = (expected.length < actual.length) ? expected.length : actual.length;
110 for (int i = 0; i < n; i++) { 110 for (int i = 0; i < n; i++) {
111 if (expected[i] != actual[i]) { 111 if (expected[i] != actual[i]) {
112 _fail('Expect.listEquals(at index $i, ' 112 _fail('Expect.listEquals(at index $i, '
113 'expected: <${expected[i]}>, actual: <${actual[i]}>$msg) fails'); 113 'expected: <${expected[i]}>, actual: <${actual[i]}>$msg) fails');
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 287
288 bool _identical(a, b) => identical(a, b); 288 bool _identical(a, b) => identical(a, b);
289 289
290 typedef bool _CheckExceptionFn(exception); 290 typedef bool _CheckExceptionFn(exception);
291 291
292 class ExpectException implements Exception { 292 class ExpectException implements Exception {
293 ExpectException(this.message); 293 ExpectException(this.message);
294 String toString() => message; 294 String toString() => message;
295 String message; 295 String message;
296 } 296 }
OLDNEW
« no previous file with comments | « runtime/lib/expando_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698