1
// Any copyright is dedicated to the Public Domain.
2
// http://creativecommons.org/licenses/publicdomain/
4
//-----------------------------------------------------------------------------
5
print("Test for correct implementation of |Date == boolean| and vice versa");
11
Date.prototype.toString = function() { return 1; };
12
Date.prototype.valueOf = function() { return 0; };
15
* ES5 11.9.3 doesn't directly handle obj == boolean. Instead it translates it
19
* ↳ obj == ToNumber(boolean), per step 7
20
* ↳ ToPrimitive(obj) == ToNumber(boolean), per step 9
22
* ToPrimitive calls [[DefaultValue]] with no hint. For Date objects this is
23
* treated as if it were instead called with hint String. That calls toString,
24
* which returns 1, so Date objects here should compare equal to true and
27
assertEq(new Date == true, true);
28
assertEq(new Date == false, false);
30
/* == is symmetric. */
31
assertEq(true == new Date, true);
32
assertEq(false == new Date, false);
34
/******************************************************************************/
36
if (typeof reportCompare === "function")
37
reportCompare(true, true);
39
print("Tests complete");