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 { |