summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_5/Date
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_5/Date
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_5/Date')
-rw-r--r--js/src/tests/ecma_5/Date/15.9.4.2.js136
-rw-r--r--js/src/tests/ecma_5/Date/UTC-convert-all-arguments.js70
-rw-r--r--js/src/tests/ecma_5/Date/browser.js0
-rw-r--r--js/src/tests/ecma_5/Date/constructor-convert-all-arguments.js70
-rw-r--r--js/src/tests/ecma_5/Date/constructor-one-argument.js26
-rw-r--r--js/src/tests/ecma_5/Date/defaultvalue.js190
-rw-r--r--js/src/tests/ecma_5/Date/equality-to-boolean.js39
-rw-r--r--js/src/tests/ecma_5/Date/fractions.js24
-rw-r--r--js/src/tests/ecma_5/Date/setTime-argument-shortcircuiting.js147
-rw-r--r--js/src/tests/ecma_5/Date/shell.js0
-rw-r--r--js/src/tests/ecma_5/Date/timeclip.js42
-rw-r--r--js/src/tests/ecma_5/Date/toISOString.js24
-rw-r--r--js/src/tests/ecma_5/Date/toJSON-01.js238
13 files changed, 1006 insertions, 0 deletions
diff --git a/js/src/tests/ecma_5/Date/15.9.4.2.js b/js/src/tests/ecma_5/Date/15.9.4.2.js
new file mode 100644
index 000000000..fb34efef6
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/15.9.4.2.js
@@ -0,0 +1,136 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 430930;
+
+
+//-----------------------------------------------------------------------------
+test();
+//-----------------------------------------------------------------------------
+
+function iso(d)
+{
+ return new Date(d).toISOString();
+}
+
+function check(s, millis){
+ description = "Date.parse('"+s+"') == '"+iso(millis)+"'";
+ expected = millis;
+ actual = Date.parse(s);
+ reportCompare(expected, actual, description);
+}
+
+function checkInvalid(s)
+{
+ description = "Date.parse('"+s+"') produces invalid date";
+ expected = NaN;
+ actual = Date.parse(s);
+ reportCompare(expected, actual, description);
+}
+
+function dd(year, month, day, hour, minute, second, millis){
+ return Date.UTC(year, month-1, day, hour, minute, second, millis);
+}
+
+function TZAtDate(d){
+ return d.getTimezoneOffset() * 60000;
+}
+
+function TZInMonth(month){
+ return TZAtDate(new Date(dd(2009,month,1,0,0,0,0)));
+}
+
+function test()
+{
+ enterFunc ('test');
+ printBugNumber(BUGNUMBER);
+
+ JanTZ = TZInMonth(1);
+ JulTZ = TZInMonth(7);
+ CurrTZ = TZAtDate(new Date());
+
+ // formats with explicit timezone
+ check("2009-07-23T19:53:21.001+12:00", dd(2009,7,23,7,53,21,1));
+ check("2009-07-23T19:53:21+12:00", dd(2009,7,23,7,53,21,0));
+ check("2009-07-23T19:53+12:00", dd(2009,7,23,7,53,0,0));
+
+ check("2009-07T19:53:21.001+12:00", dd(2009,7,1,7,53,21,1));
+ check("2009-07T19:53:21+12:00", dd(2009,7,1,7,53,21,0));
+ check("2009-07T19:53+12:00", dd(2009,7,1,7,53,0,0));
+
+ check("2009T19:53:21.001+12:00", dd(2009,1,1,7,53,21,1));
+ check("2009T19:53:21+12:00", dd(2009,1,1,7,53,21,0));
+ check("2009T19:53+12:00", dd(2009,1,1,7,53,0,0));
+
+ check("T19:53:21.001+12:00", dd(1970,1,1,7,53,21,1));
+ check("T19:53:21+12:00", dd(1970,1,1,7,53,21,0));
+ check("T19:53+12:00", dd(1970,1,1,7,53,0,0));
+
+ // formats without timezone uses the timezone as at that date
+ check("2009-07-23T19:53:21.001", dd(2009,7,23,19,53,21,1)+JulTZ);
+ check("2009-07-23T19:53:21", dd(2009,7,23,19,53,21,0)+JulTZ);
+ check("2009-07-23T19:53", dd(2009,7,23,19,53,0,0)+JulTZ);
+
+ check("2009-07T19:53:21.001", dd(2009,7,1,19,53,21,1)+JulTZ);
+ check("2009-07T19:53:21", dd(2009,7,1,19,53,21,0)+JulTZ);
+ check("2009-07T19:53", dd(2009,7,1,19,53,0,0)+JulTZ);
+
+ check("2009T19:53:21.001", dd(2009,1,1,19,53,21,1)+JanTZ);
+ check("2009T19:53:21", dd(2009,1,1,19,53,21,0)+JanTZ);
+ check("2009T19:53", dd(2009,1,1,19,53,0,0)+JanTZ);
+
+ check("T19:53:21.001", dd(1970,1,1,19,53,21,1)+JanTZ);
+ check("T19:53:21", dd(1970,1,1,19,53,21,0)+JanTZ);
+ check("T19:53", dd(1970,1,1,19,53,0,0)+JanTZ);
+
+ // with no time at all assume UTC
+ check("2009-07-23", dd(2009,7,23,0,0,0,0));
+ check("2009-07", dd(2009,7,1,0,0,0,0));
+ check("2009", dd(2009,1,1,0,0,0,0));
+
+ // one field too big
+ checkInvalid("2009-13-23T19:53:21.001+12:00");
+ checkInvalid("2009-07-32T19:53:21.001+12:00");
+ checkInvalid("2009-07-23T25:53:21.001+12:00");
+ checkInvalid("2009-07-23T19:60:21.001+12:00");
+ checkInvalid("2009-07-23T19:53:60.001+12:00");
+ checkInvalid("2009-07-23T19:53:21.001+24:00");
+ checkInvalid("2009-07-23T19:53:21.001+12:60");
+
+ // other month ends
+ check("2009-06-30T19:53:21.001+12:00", dd(2009,6,30,7,53,21,1));
+ checkInvalid("2009-06-31T19:53:21.001+12:00");
+ check("2009-02-28T19:53:21.001+12:00", dd(2009,2,28,7,53,21,1));
+ checkInvalid("2009-02-29T19:53:21.001+12:00");
+ check("2008-02-29T19:53:21.001+12:00", dd(2008,2,29,7,53,21,1));
+ checkInvalid("2008-02-30T19:53:21.001+12:00");
+
+ // limits of representation
+ checkInvalid("-271821-04-19T23:59:59.999Z");
+ check("-271821-04-20", -8.64e15);
+ check("+275760-09-13", 8.64e15);
+ checkInvalid("+275760-09-13T00:00:00.001Z");
+
+ check("-269845-07-23T19:53:21.001+12:00", dd(-269845,7,23,7,53,21,1));
+ check("+273785-07-23T19:53:21.001+12:00", dd(273785,7,23,7,53,21,1));
+
+ // explicit UTC
+ check("2009-07-23T19:53:21.001Z", dd(2009,7,23,19,53,21,1));
+ check("+002009-07-23T19:53:21.001Z", dd(2009,7,23,19,53,21,1));
+
+ // different timezones
+ check("2009-07-23T19:53:21.001+12:00", dd(2009,7,23,7,53,21,1));
+ check("2009-07-23T00:53:21.001-07:00", dd(2009,7,23,7,53,21,1));
+
+ // 00:00 and 24:00
+ check("2009-07-23T00:00:00.000-07:00", dd(2009,7,23,7,0,0,0));
+ check("2009-07-23T24:00:00.000-07:00", dd(2009,7,24,7,0,0,0));
+
+ // Bug 730838 - non-zero fraction part for midnight should produce NaN
+ checkInvalid("1970-01-01T24:00:00.500Z");
+
+ exitFunc ('test');
+}
diff --git a/js/src/tests/ecma_5/Date/UTC-convert-all-arguments.js b/js/src/tests/ecma_5/Date/UTC-convert-all-arguments.js
new file mode 100644
index 000000000..2fee8b951
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/UTC-convert-all-arguments.js
@@ -0,0 +1,70 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommonn.org/licenses/publicdomain/
+ */
+
+var BUGNUMBER = 1160356;
+var summary =
+ "Date.UTC must convert *all* arguments to number, not return NaN early if " +
+ "a non-finite argument is encountered";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+function expectThrowTypeError(f, i)
+{
+ try
+ {
+ f();
+ throw new Error("didn't throw");
+ }
+ catch (e)
+ {
+ assertEq(e, 42, "index " + i + ": expected 42, got " + e);
+ }
+}
+
+var bad =
+ { toString: function() { throw 17; }, valueOf: function() { throw 42; } };
+
+var args =
+ [
+ [bad],
+
+ [NaN, bad],
+ [Infinity, bad],
+ [1970, bad],
+
+ [1970, NaN, bad],
+ [1970, Infinity, bad],
+ [1970, 4, bad],
+
+ [1970, 4, NaN, bad],
+ [1970, 4, Infinity, bad],
+ [1970, 4, 17, bad],
+
+ [1970, 4, 17, NaN, bad],
+ [1970, 4, 17, Infinity, bad],
+ [1970, 4, 17, 13, bad],
+
+ [1970, 4, 17, 13, NaN, bad],
+ [1970, 4, 17, 13, Infinity, bad],
+ [1970, 4, 17, 13, 37, bad],
+
+ [1970, 4, 17, 13, 37, NaN, bad],
+ [1970, 4, 17, 13, 37, Infinity, bad],
+ [1970, 4, 17, 13, 37, 23, bad],
+ ];
+
+for (var i = 0, len = args.length; i < len; i++)
+ expectThrowTypeError(function() { Date.UTC.apply(null, args[i]); }, i);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/ecma_5/Date/browser.js b/js/src/tests/ecma_5/Date/browser.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/browser.js
diff --git a/js/src/tests/ecma_5/Date/constructor-convert-all-arguments.js b/js/src/tests/ecma_5/Date/constructor-convert-all-arguments.js
new file mode 100644
index 000000000..3a281cae2
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/constructor-convert-all-arguments.js
@@ -0,0 +1,70 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommonn.org/licenses/publicdomain/
+ */
+
+var BUGNUMBER = 1160356;
+var summary =
+ "new Date(...) must convert *all* arguments to number, not return NaN " +
+ "early if a non-finite argument is encountered";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+function expectThrowTypeError(f, i)
+{
+ try
+ {
+ f();
+ throw new Error("didn't throw");
+ }
+ catch (e)
+ {
+ assertEq(e, 42, "index " + i + ": expected 42, got " + e);
+ }
+}
+
+var bad =
+ { toString: function() { throw 17; }, valueOf: function() { throw 42; } };
+
+var funcs =
+ [
+ function() { new Date(bad); },
+
+ function() { new Date(NaN, bad); },
+ function() { new Date(Infinity, bad); },
+ function() { new Date(1970, bad); },
+
+ function() { new Date(1970, NaN, bad); },
+ function() { new Date(1970, Infinity, bad); },
+ function() { new Date(1970, 4, bad); },
+
+ function() { new Date(1970, 4, NaN, bad); },
+ function() { new Date(1970, 4, Infinity, bad); },
+ function() { new Date(1970, 4, 17, bad); },
+
+ function() { new Date(1970, 4, 17, NaN, bad); },
+ function() { new Date(1970, 4, 17, Infinity, bad); },
+ function() { new Date(1970, 4, 17, 13, bad); },
+
+ function() { new Date(1970, 4, 17, 13, NaN, bad); },
+ function() { new Date(1970, 4, 17, 13, Infinity, bad); },
+ function() { new Date(1970, 4, 17, 13, 37, bad); },
+
+ function() { new Date(1970, 4, 17, 13, 37, NaN, bad); },
+ function() { new Date(1970, 4, 17, 13, 37, Infinity, bad); },
+ function() { new Date(1970, 4, 17, 13, 37, 23, bad); },
+ ];
+
+for (var i = 0, len = funcs.length; i < len; i++)
+ expectThrowTypeError(funcs[i]);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/ecma_5/Date/constructor-one-argument.js b/js/src/tests/ecma_5/Date/constructor-one-argument.js
new file mode 100644
index 000000000..d7acd33aa
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/constructor-one-argument.js
@@ -0,0 +1,26 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommonn.org/licenses/publicdomain/
+ */
+
+var BUGNUMBER = 738511;
+var summary =
+ "new Date(value) should call ToPrimitive on value before testing for " +
+ "string-ness";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+assertEq(new Date(new String("2012-01-31T00:00:00.000Z")).valueOf(),
+ 1327968000000,
+ "Date constructor passed a String object should parse it");
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/ecma_5/Date/defaultvalue.js b/js/src/tests/ecma_5/Date/defaultvalue.js
new file mode 100644
index 000000000..2fc5887d1
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/defaultvalue.js
@@ -0,0 +1,190 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommonn.org/licenses/publicdomain/
+ */
+
+var BUGNUMBER = 645464;
+var summary =
+ "[[DefaultValue]] behavior wrong for Date with overridden valueOf/toString";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+function allTests()
+{
+ var DS = new Date(2010, 1, 1).toString();
+
+ // equality
+
+ var d = new Date(2010, 1, 1);
+ assertEq(d == DS, true);
+
+ var d2 = new Date(2010, 1, 1);
+ d2.valueOf = function() { assertEq(arguments.length, 0); return 17; };
+ assertEq(d2 == DS, true);
+
+ var d3 = new Date(2010, 1, 1);
+ d3.toString = function() { return 42; };
+ assertEq(d3 == 42, true);
+
+ function testEquality()
+ {
+ var d = new Date(2010, 1, 1);
+ assertEq(d == DS, true);
+
+ var d2 = new Date(2010, 1, 1);
+ d2.valueOf = function() { assertEq(arguments.length, 0); return 17; };
+ assertEq(d2 == DS, true);
+
+ var d3 = new Date(2010, 1, 1);
+ d3.toString = function() { return 42; };
+ assertEq(d3 == 42, true);
+ }
+ testEquality();
+
+
+ // addition of Date to number
+
+ var d = new Date(2010, 1, 1);
+ assertEq(d + 5, DS + "5");
+
+ var d2 = new Date(2010, 1, 1);
+ d2.toString = function() { return 9; };
+ assertEq(d2 + 3, 9 + 3);
+
+ var d3 = new Date(2010, 1, 1);
+ d3.valueOf = function() { assertEq(arguments.length, 0); return 17; };
+ assertEq(d3 + 5, DS + "5");
+
+ function testDateNumberAddition()
+ {
+ var d = new Date(2010, 1, 1);
+ assertEq(d + 5, DS + "5");
+
+ var d2 = new Date(2010, 1, 1);
+ d2.toString = function() { return 9; };
+ assertEq(d2 + 3, 9 + 3);
+
+ var d3 = new Date(2010, 1, 1);
+ d3.valueOf = function() { assertEq(arguments.length, 0); return 17; };
+ assertEq(d3 + 5, DS + "5");
+ }
+ testDateNumberAddition();
+
+
+ // addition of Date to Date
+
+ var d = new Date(2010, 1, 1);
+ assertEq(d + d, DS + DS);
+
+ var d2 = new Date(2010, 1, 1);
+ d2.toString = function() { return 5; };
+ assertEq(d2 + d2, 10);
+
+ var d3 = new Date(2010, 1, 1);
+ d3.valueOf = function() { assertEq(arguments.length, 0); return 8.5; };
+ assertEq(d3 + d3, DS + DS);
+
+ function testDateDateAddition()
+ {
+ var d = new Date(2010, 1, 1);
+ assertEq(d + d, DS + DS);
+
+ var d2 = new Date(2010, 1, 1);
+ d2.toString = function() { return 5; };
+ assertEq(d2 + d2, 10);
+
+ var d3 = new Date(2010, 1, 1);
+ d3.valueOf = function() { assertEq(arguments.length, 0); return 8.5; };
+ assertEq(d3 + d3, DS + DS);
+ }
+ testDateDateAddition();
+
+
+ // Date as bracketed property name
+
+ var obj = { 8: 42, 9: 73 };
+ obj[DS] = 17;
+
+ var d = new Date(2010, 1, 1);
+ assertEq(obj[d], 17);
+
+ var d2 = new Date(2010, 1, 1);
+ d2.valueOf = function() { assertEq(arguments.length, 0); return 8; }
+ assertEq(obj[d2], 17);
+
+ var d3 = new Date(2010, 1, 1);
+ d3.toString = function() { return 9; };
+ assertEq(obj[d3], 73);
+
+ function testPropertyName()
+ {
+ var obj = { 8: 42, 9: 73 };
+ obj[DS] = 17;
+
+ var d = new Date(2010, 1, 1);
+ assertEq(obj[d], 17);
+
+ var d2 = new Date(2010, 1, 1);
+ d2.valueOf = function() { assertEq(arguments.length, 0); return 8; }
+ assertEq(obj[d2], 17);
+
+ var d3 = new Date(2010, 1, 1);
+ d3.toString = function() { return 9; };
+ assertEq(obj[d3], 73);
+ }
+ testPropertyName();
+
+
+ // Date as property name with |in| operator
+
+ var obj = {};
+ obj[DS] = 5;
+
+ var d = new Date(2010, 1, 1);
+ assertEq(d in obj, true);
+
+ var d2 = new Date(2010, 1, 1);
+ d2.toString = function() { return "baz"; };
+ assertEq(d2 in { baz: 42 }, true);
+
+ var d3 = new Date(2010, 1, 1);
+ d3.valueOf = function() { assertEq(arguments.length, 0); return "quux"; };
+ assertEq(d3 in obj, true);
+
+ function testInOperatorName()
+ {
+ var obj = {};
+ obj[DS] = 5;
+
+ var d = new Date(2010, 1, 1);
+ assertEq(d in obj, true);
+
+ var d2 = new Date(2010, 1, 1);
+ d2.toString = function() { return "baz"; };
+ assertEq(d2 in { baz: 42 }, true);
+
+ var d3 = new Date(2010, 1, 1);
+ d3.valueOf = function() { assertEq(arguments.length, 0); return "quux"; };
+ assertEq(d3 in obj, true);
+ }
+ testInOperatorName();
+}
+
+allTests();
+
+if (typeof newGlobal === "function")
+{
+ Date = newGlobal().Date;
+ allTests();
+}
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("All tests passed!");
diff --git a/js/src/tests/ecma_5/Date/equality-to-boolean.js b/js/src/tests/ecma_5/Date/equality-to-boolean.js
new file mode 100644
index 000000000..c60319b9d
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/equality-to-boolean.js
@@ -0,0 +1,39 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+print("Test for correct implementation of |Date == boolean| and vice versa");
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+Date.prototype.toString = function() { return 1; };
+Date.prototype.valueOf = function() { return 0; };
+
+/*
+ * ES5 11.9.3 doesn't directly handle obj == boolean. Instead it translates it
+ * as follows:
+ *
+ * obj == boolean
+ * ↳ obj == ToNumber(boolean), per step 7
+ * ↳ ToPrimitive(obj) == ToNumber(boolean), per step 9
+ *
+ * ToPrimitive calls [[DefaultValue]] with no hint. For Date objects this is
+ * treated as if it were instead called with hint String. That calls toString,
+ * which returns 1, so Date objects here should compare equal to true and
+ * unequal to false.
+ */
+assertEq(new Date == true, true);
+assertEq(new Date == false, false);
+
+/* == is symmetric. */
+assertEq(true == new Date, true);
+assertEq(false == new Date, false);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/ecma_5/Date/fractions.js b/js/src/tests/ecma_5/Date/fractions.js
new file mode 100644
index 000000000..30dd663dd
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/fractions.js
@@ -0,0 +1,24 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommonn.org/licenses/publicdomain/
+ */
+
+var BUGNUMBER = 771946;
+var summary = "Fractional days, months, years shouldn't trigger asserts";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+new Date(0).setFullYear(1.5);
+new Date(0).setUTCDate(1.5);
+new Date(0).setMonth(1.5);
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/ecma_5/Date/setTime-argument-shortcircuiting.js b/js/src/tests/ecma_5/Date/setTime-argument-shortcircuiting.js
new file mode 100644
index 000000000..7e67d0374
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/setTime-argument-shortcircuiting.js
@@ -0,0 +1,147 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+//-----------------------------------------------------------------------------
+print("Test for correct short-circuiting implementation of Date.set methods");
+
+/**************
+ * BEGIN TEST *
+ **************/
+var global = 0;
+var date;
+
+/* Test that methods don't short circuit argument evaluation. */
+date = new Date(0).setSeconds(NaN, {valueOf:function(){global = 3}});
+assertEq(global, 3);
+
+date = new Date(0).setUTCSeconds(NaN, {valueOf:function(){global = 4}});
+assertEq(global, 4);
+
+date = new Date(0).setMinutes(NaN, {valueOf:function(){global = 5}});
+assertEq(global, 5);
+
+date = new Date(0).setUTCMinutes(NaN, {valueOf:function(){global = 6}});
+assertEq(global, 6);
+
+date = new Date(0).setHours(NaN, {valueOf:function(){global = 7}});
+assertEq(global, 7);
+
+date = new Date(0).setUTCHours(NaN, {valueOf:function(){global = 8}});
+assertEq(global, 8);
+
+date = new Date(0).setMonth(NaN, {valueOf:function(){global = 11}});
+assertEq(global, 11);
+
+date = new Date(0).setUTCMonth(NaN, {valueOf:function(){global = 12}});
+assertEq(global, 12);
+
+date = new Date(0).setFullYear(NaN, {valueOf:function(){global = 13}});
+assertEq(global, 13);
+
+date = new Date(0).setUTCFullYear(NaN, {valueOf:function(){global = 14}});
+assertEq(global, 14);
+
+
+
+/* Test that argument evaluation is not short circuited if Date == NaN */
+date = new Date(NaN).setMilliseconds({valueOf:function(){global = 15}});
+assertEq(global, 15);
+
+date = new Date(NaN).setUTCMilliseconds({valueOf:function(){global = 16}});
+assertEq(global, 16);
+
+date = new Date(NaN).setSeconds({valueOf:function(){global = 17}});
+assertEq(global, 17);
+
+date = new Date(NaN).setUTCSeconds({valueOf:function(){global = 18}});
+assertEq(global, 18);
+
+date = new Date(NaN).setMinutes({valueOf:function(){global = 19}});
+assertEq(global, 19);
+
+date = new Date(NaN).setUTCMinutes({valueOf:function(){global = 20}});
+assertEq(global, 20);
+
+date = new Date(NaN).setHours({valueOf:function(){global = 21}});
+assertEq(global, 21);
+
+date = new Date(NaN).setUTCHours({valueOf:function(){global = 22}});
+assertEq(global, 22);
+
+date = new Date(NaN).setDate({valueOf:function(){global = 23}});
+assertEq(global, 23);
+
+date = new Date(NaN).setUTCDate({valueOf:function(){global = 24}});
+assertEq(global, 24);
+
+date = new Date(NaN).setMonth({valueOf:function(){global = 25}});
+assertEq(global, 25);
+
+date = new Date(NaN).setUTCMonth({valueOf:function(){global = 26}});
+assertEq(global, 26);
+
+date = new Date(NaN).setFullYear({valueOf:function(){global = 27}});
+assertEq(global, 27);
+
+date = new Date(NaN).setUTCFullYear({valueOf:function(){global = 28}});
+assertEq(global, 28);
+
+
+/* Test the combination of the above two. */
+date = new Date(NaN).setSeconds(NaN, {valueOf:function(){global = 31}});
+assertEq(global, 31);
+
+date = new Date(NaN).setUTCSeconds(NaN, {valueOf:function(){global = 32}});
+assertEq(global, 32);
+
+date = new Date(NaN).setMinutes(NaN, {valueOf:function(){global = 33}});
+assertEq(global, 33);
+
+date = new Date(NaN).setUTCMinutes(NaN, {valueOf:function(){global = 34}});
+assertEq(global, 34);
+
+date = new Date(NaN).setHours(NaN, {valueOf:function(){global = 35}});
+assertEq(global, 35);
+
+date = new Date(NaN).setUTCHours(NaN, {valueOf:function(){global = 36}});
+assertEq(global, 36);
+
+date = new Date(NaN).setMonth(NaN, {valueOf:function(){global = 39}});
+assertEq(global, 39);
+
+date = new Date(NaN).setUTCMonth(NaN, {valueOf:function(){global = 40}});
+assertEq(global, 40);
+
+date = new Date(NaN).setFullYear(NaN, {valueOf:function(){global = 41}});
+assertEq(global, 41);
+
+date = new Date(NaN).setUTCFullYear(NaN, {valueOf:function(){global = 42}});
+assertEq(global, 42);
+
+
+/*Test two methods evaluation*/
+var secondGlobal = 0;
+
+date = new Date(NaN).setFullYear({valueOf:function(){global = 43}}, {valueOf:function(){secondGlobal = 1}});
+assertEq(global, 43);
+assertEq(secondGlobal, 1);
+
+date = new Date(0).setFullYear(NaN, {valueOf:function(){global = 44}}, {valueOf:function(){secondGlobal = 2}});
+assertEq(global, 44);
+assertEq(secondGlobal, 2);
+
+
+/* Test year methods*/
+date = new Date(0).setYear({valueOf:function(){global = 45}});
+assertEq(global, 45);
+
+date = new Date(NaN).setYear({valueOf:function(){global = 46}});
+assertEq(global, 46);
+
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/ecma_5/Date/shell.js b/js/src/tests/ecma_5/Date/shell.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/shell.js
diff --git a/js/src/tests/ecma_5/Date/timeclip.js b/js/src/tests/ecma_5/Date/timeclip.js
new file mode 100644
index 000000000..50bde39e7
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/timeclip.js
@@ -0,0 +1,42 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommonn.org/licenses/publicdomain/
+ */
+
+var BUGNUMBER = 747197;
+var summary = "TimeClip behavior for very large numbers";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+function addToLimit(n) { return 8.64e15 + n; }
+
+assertEq(8.64e15 === addToLimit(0.0), true);
+assertEq(8.64e15 === addToLimit(0.5), true);
+assertEq(8.64e15 === addToLimit(0.5000000000000001), false);
+
+var times =
+ [Number.MAX_VALUE,
+ -Number.MAX_VALUE,
+ Infinity,
+ -Infinity,
+ addToLimit(0.5000000000000001),
+ -addToLimit(0.5000000000000001)];
+
+for (var i = 0, len = times.length; i < len; i++)
+{
+ var d = new Date();
+ assertEq(d.setTime(times[i]), NaN, "times[" + i + "]");
+ assertEq(d.getTime(), NaN);
+ assertEq(d.valueOf(), NaN);
+}
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("Tests complete");
diff --git a/js/src/tests/ecma_5/Date/toISOString.js b/js/src/tests/ecma_5/Date/toISOString.js
new file mode 100644
index 000000000..9eb412934
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/toISOString.js
@@ -0,0 +1,24 @@
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/
+ */
+
+function throwsRangeError(t) {
+ try {
+ var date = new Date();
+ date.setTime(t);
+ var r = date.toISOString();
+ throw new Error("toISOString didn't throw, instead returned " + r);
+ } catch (err) {
+ assertEq(err instanceof RangeError, true, 'wrong error: ' + err);
+ return;
+ }
+ assertEq(0, 1, 'not good, nyan, nyan');
+}
+
+throwsRangeError(Infinity);
+throwsRangeError(-Infinity);
+throwsRangeError(NaN);
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
diff --git a/js/src/tests/ecma_5/Date/toJSON-01.js b/js/src/tests/ecma_5/Date/toJSON-01.js
new file mode 100644
index 000000000..4a756aab5
--- /dev/null
+++ b/js/src/tests/ecma_5/Date/toJSON-01.js
@@ -0,0 +1,238 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+var gTestfile = 'toJSON-01.js';
+//-----------------------------------------------------------------------------
+var BUGNUMBER = 584811;
+var summary = "Date.prototype.toJSON isn't to spec";
+
+print(BUGNUMBER + ": " + summary);
+
+/**************
+ * BEGIN TEST *
+ **************/
+
+var called;
+
+var dateToJSON = Date.prototype.toJSON;
+assertEq(Date.prototype.hasOwnProperty("toJSON"), true);
+assertEq(typeof dateToJSON, "function");
+
+// brief test to exercise this outside of isolation, just for sanity
+var invalidDate = new Date();
+invalidDate.setTime(NaN);
+assertEq(JSON.stringify({ p: invalidDate }), '{"p":null}');
+
+
+/* 15.9.5.44 Date.prototype.toJSON ( key ) */
+assertEq(dateToJSON.length, 1);
+
+/*
+ * 1. Let O be the result of calling ToObject, giving it the this value as its
+ * argument.
+ */
+try
+{
+ dateToJSON.call(null);
+ throw new Error("should have thrown a TypeError");
+}
+catch (e)
+{
+ assertEq(e instanceof TypeError, true,
+ "ToObject throws TypeError for null/undefined");
+}
+
+try
+{
+ dateToJSON.call(undefined);
+ throw new Error("should have thrown a TypeError");
+}
+catch (e)
+{
+ assertEq(e instanceof TypeError, true,
+ "ToObject throws TypeError for null/undefined");
+}
+
+
+/*
+ * 2. Let tv be ToPrimitive(O, hint Number).
+ * ...expands to:
+ * 1. Let valueOf be the result of calling the [[Get]] internal method of object O with argument "valueOf".
+ * 2. If IsCallable(valueOf) is true then,
+ * a. Let val be the result of calling the [[Call]] internal method of valueOf, with O as the this value and
+ * an empty argument list.
+ * b. If val is a primitive value, return val.
+ * 3. Let toString be the result of calling the [[Get]] internal method of object O with argument "toString".
+ * 4. If IsCallable(toString) is true then,
+ * a. Let str be the result of calling the [[Call]] internal method of toString, with O as the this value and
+ * an empty argument list.
+ * b. If str is a primitive value, return str.
+ * 5. Throw a TypeError exception.
+ */
+try
+{
+ var r = dateToJSON.call({ get valueOf() { throw 17; } });
+ throw new Error("didn't throw, returned: " + r);
+}
+catch (e)
+{
+ assertEq(e, 17, "bad exception: " + e);
+}
+
+called = false;
+assertEq(dateToJSON.call({ valueOf: null,
+ toString: function() { called = true; return 12; },
+ toISOString: function() { return "ohai"; } }),
+ "ohai");
+assertEq(called, true);
+
+called = false;
+assertEq(dateToJSON.call({ valueOf: function() { called = true; return 42; },
+ toISOString: function() { return null; } }),
+ null);
+assertEq(called, true);
+
+try
+{
+ called = false;
+ dateToJSON.call({ valueOf: function() { called = true; return {}; },
+ get toString() { throw 42; } });
+}
+catch (e)
+{
+ assertEq(called, true);
+ assertEq(e, 42, "bad exception: " + e);
+}
+
+called = false;
+assertEq(dateToJSON.call({ valueOf: function() { called = true; return {}; },
+ get toString() { return function() { return 8675309; }; },
+ toISOString: function() { return true; } }),
+ true);
+assertEq(called, true);
+
+var asserted = false;
+called = false;
+assertEq(dateToJSON.call({ valueOf: function() { called = true; return {}; },
+ get toString()
+ {
+ assertEq(called, true);
+ asserted = true;
+ return function() { return 8675309; };
+ },
+ toISOString: function() { return NaN; } }),
+ NaN);
+assertEq(asserted, true);
+
+try
+{
+ var r = dateToJSON.call({ valueOf: null, toString: null,
+ get toISOString()
+ {
+ throw new Error("shouldn't have been gotten");
+ } });
+ throw new Error("didn't throw, returned: " + r);
+}
+catch (e)
+{
+ assertEq(e instanceof TypeError, true, "bad exception: " + e);
+}
+
+
+/* 3. If tv is a Number and is not finite, return null. */
+assertEq(dateToJSON.call({ valueOf: function() { return Infinity; } }), null);
+assertEq(dateToJSON.call({ valueOf: function() { return -Infinity; } }), null);
+assertEq(dateToJSON.call({ valueOf: function() { return NaN; } }), null);
+
+assertEq(dateToJSON.call({ valueOf: function() { return Infinity; },
+ toISOString: function() { return {}; } }), null);
+assertEq(dateToJSON.call({ valueOf: function() { return -Infinity; },
+ toISOString: function() { return []; } }), null);
+assertEq(dateToJSON.call({ valueOf: function() { return NaN; },
+ toISOString: function() { return undefined; } }), null);
+
+
+/*
+ * 4. Let toISO be the result of calling the [[Get]] internal method of O with
+ * argument "toISOString".
+ */
+try
+{
+ var r = dateToJSON.call({ get toISOString() { throw 42; } });
+ throw new Error("didn't throw, returned: " + r);
+}
+catch (e)
+{
+ assertEq(e, 42, "bad exception: " + e);
+}
+
+
+/* 5. If IsCallable(toISO) is false, throw a TypeError exception. */
+try
+{
+ var r = dateToJSON.call({ toISOString: null });
+ throw new Error("didn't throw, returned: " + r);
+}
+catch (e)
+{
+ assertEq(e instanceof TypeError, true, "bad exception: " + e);
+}
+
+try
+{
+ var r = dateToJSON.call({ toISOString: undefined });
+ throw new Error("didn't throw, returned: " + r);
+}
+catch (e)
+{
+ assertEq(e instanceof TypeError, true, "bad exception: " + e);
+}
+
+try
+{
+ var r = dateToJSON.call({ toISOString: "oogabooga" });
+ throw new Error("didn't throw, returned: " + r);
+}
+catch (e)
+{
+ assertEq(e instanceof TypeError, true, "bad exception: " + e);
+}
+
+try
+{
+ var r = dateToJSON.call({ toISOString: Math.PI });
+ throw new Error("didn't throw, returned: " + r);
+}
+catch (e)
+{
+ assertEq(e instanceof TypeError, true, "bad exception: " + e);
+}
+
+
+/*
+ * 6. Return the result of calling the [[Call]] internal method of toISO with O
+ * as the this value and an empty argument list.
+ */
+var o =
+ {
+ toISOString: function(a)
+ {
+ called = true;
+ assertEq(this, o);
+ assertEq(a, undefined);
+ assertEq(arguments.length, 0);
+ return obj;
+ }
+ };
+var obj = {};
+called = false;
+assertEq(dateToJSON.call(o), obj, "should have gotten obj back");
+assertEq(called, true);
+
+
+/******************************************************************************/
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);
+
+print("All tests passed!");