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

Unified Diff: sdk/lib/core/expect.dart

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/errors.dart ('k') | sdk/lib/core/map.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/expect.dart
diff --git a/sdk/lib/core/expect.dart b/sdk/lib/core/expect.dart
index b26ddc53a99420b95087dcf4e30863150d3eb36d..2049b9245de8d42f81dd235d748df0be27d5fe76 100644
--- a/sdk/lib/core/expect.dart
+++ b/sdk/lib/core/expect.dart
@@ -23,7 +23,7 @@ class Expect {
* Checks whether the actual value is a bool and its value is true.
*/
static void isTrue(var actual, [String reason = null]) {
- if (actual === true) return;
+ if (_identical(actual, true)) return;
String msg = _getMessage(reason);
_fail("Expect.isTrue($actual$msg) fails.");
}
@@ -32,7 +32,7 @@ class Expect {
* Checks whether the actual value is a bool and its value is false.
*/
static void isFalse(var actual, [String reason = null]) {
- if (actual === false) return;
+ if (_identical(actual, false)) return;
String msg = _getMessage(reason);
_fail("Expect.isFalse($actual$msg) fails.");
}
@@ -41,7 +41,7 @@ class Expect {
* Checks whether [actual] is null.
*/
static void isNull(actual, [String reason = null]) {
- if (null === actual) return;
+ if (null == actual) return;
String msg = _getMessage(reason);
_fail("Expect.isNull(actual: <$actual>$msg) fails.");
}
@@ -50,7 +50,7 @@ class Expect {
* Checks whether [actual] is not null.
*/
static void isNotNull(actual, [String reason = null]) {
- if (null !== actual) return;
+ if (null != actual) return;
String msg = _getMessage(reason);
_fail("Expect.isNotNull(actual: <$actual>$msg) fails.");
}
@@ -60,7 +60,7 @@ class Expect {
* (using `===`).
*/
static void identical(var expected, var actual, [String reason = null]) {
- if (expected === actual) return;
+ if (_identical(expected, actual)) return;
String msg = _getMessage(reason);
_fail("Expect.identical(expected: <$expected>, actual: <$actual>$msg) "
"fails.");
@@ -80,7 +80,7 @@ class Expect {
num actual,
[num tolerance = null,
String reason = null]) {
- if (tolerance === null) {
+ if (tolerance == null) {
tolerance = (expected / 1e4).abs();
}
// Note: use !( <= ) rather than > so we fail on NaNs
@@ -159,7 +159,7 @@ class Expect {
'Expect.stringEquals(expected: <$expected>", <$actual>$msg) fails';
if (expected == actual) return;
- if ((expected === null) || (actual === null)) {
+ if ((expected == null) || (actual == null)) {
_fail('$defaultMessage');
}
// scan from the left until we find a mismatch
@@ -265,7 +265,7 @@ class Expect {
try {
f();
} catch (e, s) {
- if (check !== null) {
+ if (check != null) {
if (!check(e)) {
String msg = reason == null ? "" : reason;
_fail("Expect.throws($msg): Unexpected '$e'\n$s");
@@ -278,13 +278,15 @@ class Expect {
}
static String _getMessage(String reason)
- => (reason === null) ? "" : ", '$reason'";
+ => (reason == null) ? "" : ", '$reason'";
static void _fail(String message) {
throw new ExpectException(message);
}
}
+bool _identical(a, b) => identical(a, b);
+
typedef bool _CheckExceptionFn(exception);
class ExpectException implements Exception {
« no previous file with comments | « sdk/lib/core/errors.dart ('k') | sdk/lib/core/map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698