Chromium Code Reviews| Index: lib/core/expect.dart |
| =================================================================== |
| --- lib/core/expect.dart (revision 13856) |
| +++ lib/core/expect.dart (working copy) |
| @@ -23,7 +23,7 @@ |
| * 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; |
|
ahe
2012/10/22 09:05:21
true == actual
floitsch
2012/10/22 12:07:37
I prefer "identical".
|
| String msg = _getMessage(reason); |
| _fail("Expect.isTrue($actual$msg) fails."); |
| } |
| @@ -32,7 +32,7 @@ |
| * 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; |
|
ahe
2012/10/22 09:05:21
false == actual
floitsch
2012/10/22 12:07:37
ditto.
|
| String msg = _getMessage(reason); |
| _fail("Expect.isFalse($actual$msg) fails."); |
| } |
| @@ -41,7 +41,7 @@ |
| * 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 @@ |
| * 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 @@ |
| * (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 @@ |
| 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 @@ |
| '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 @@ |
| try { |
| f(); |
| } catch (e) { |
| - if (check !== null) { |
| + if (check != null) { |
| Expect.isTrue(check(e)); |
| } |
| return; |
| @@ -275,7 +275,7 @@ |
| } |
| static String _getMessage(String reason) |
| - => (reason === null) ? "" : ", '$reason'"; |
| + => (reason == null) ? "" : ", '$reason'"; |
| static void _fail(String message) { |
| throw new ExpectException(message); |