diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/built-ins/Date | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Date')
855 files changed, 24315 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/15.9.1.15-1.js b/js/src/tests/test262/built-ins/Date/15.9.1.15-1.js new file mode 100644 index 0000000000..f8b4a3a846 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/15.9.1.15-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date-time-string-format +description: > + Date Time String Format - specified default values will be set for + all optional fields(MM, DD, mm, ss and time zone) when they are + absent +---*/ + +var result = false; +var expectedDateTimeStr = "1970-01-01T00:00:00.000Z"; +var dateObj = new Date("1970"); +var dateStr = dateObj.toISOString(); +result = dateStr === expectedDateTimeStr; + +assert(result, 'result !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.2.1_A1.js b/js/src/tests/test262/built-ins/Date/S15.9.2.1_A1.js new file mode 100644 index 0000000000..f728498047 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.2.1_A1.js @@ -0,0 +1,83 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date-year-month-date-hours-minutes-seconds-ms +info: | + When Date is called as a function rather than as a constructor, + it should be "string" representing the current time (UTC) +es5id: 15.9.2.1_A1 +description: Checking type of returned value +---*/ + +//CHECK#1 +if (typeof Date() !== "string") { + $ERROR('#1: typeof Date() should be "string", actual is ' + (typeof Date())); +} + +//CHECK#2 +if (typeof Date(1) !== "string") { + $ERROR('#2: typeof Date(1) should be "string", actual is ' + (typeof Date(1))); +} + +//CHECK#3 +if (typeof Date(1970, 1) !== "string") { + $ERROR('#3: typeof Date(1970, 1) should be "string", actual is ' + (typeof Date(1970, 1))); +} + +//CHECK#4 +if (typeof Date(1970, 1, 1) !== "string") { + $ERROR('#4: typeof Date(1970, 1, 1) should be "string", actual is ' + (typeof Date(1970, 1, 1))); +} + +//CHECK#5 +if (typeof Date(1970, 1, 1, 1) !== "string") { + $ERROR('#5: typeof Date(1970, 1, 1, 1) should be "string", actual is ' + (typeof Date(1970, 1, 1, 1))); +} + +//CHECK#6 +if (typeof Date(1970, 1, 1, 1) !== "string") { + $ERROR('#7: typeof Date(1970, 1, 1, 1) should be "string", actual is ' + (typeof Date(1970, 1, 1, 1))); +} + +//CHECK#8 +if (typeof Date(1970, 1, 1, 1, 0) !== "string") { + $ERROR('#8: typeof Date(1970, 1, 1, 1, 0) should be "string", actual is ' + (typeof Date(1970, 1, 1, 1, 0))); +} + +//CHECK#9 +if (typeof Date(1970, 1, 1, 1, 0, 0) !== "string") { + $ERROR('#9: typeof Date(1970, 1, 1, 1, 0, 0) should be "string", actual is ' + (typeof Date(1970, 1, 1, 1, 0, 0))); +} + +//CHECK#10 +if (typeof Date(1970, 1, 1, 1, 0, 0, 0) !== "string") { + $ERROR('#10: typeof Date(1970, 1, 1, 1, 0, 0, 0) should be "string", actual is ' + (typeof Date(1970, 1, 1, 1, 0, 0, 0))); +} + +//CHECK#11 +if (typeof Date(Number.NaN) !== "string") { + $ERROR('#11: typeof Date(Number.NaN) should be "string", actual is ' + (typeof Date(Number.NaN))); +} + +//CHECK#12 +if (typeof Date(Number.POSITIVE_INFINITY) !== "string") { + $ERROR('#12: typeof Date(Number.POSITIVE_INFINITY) should be "string", actual is ' + (typeof Date(Number.POSITIVE_INFINITY))); +} + +//CHECK#13 +if (typeof Date(Number.NEGATIVE_INFINITY) !== "string") { + $ERROR('#13: typeof Date(Number.NEGATIVE_INFINITY) should be "string", actual is ' + (typeof Date(Number.NEGATIVE_INFINITY))); +} + +//CHECK#14 +if (typeof Date(undefined) !== "string") { + $ERROR('#14: typeof Date(undefined) should be "string", actual is ' + (typeof Date(undefined))); +} + +//CHECK#15 +if (typeof Date(null) !== "string") { + $ERROR('#15: typeof Date(null) should be "string", actual is ' + (typeof Date(null))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.2.1_A2.js b/js/src/tests/test262/built-ins/Date/S15.9.2.1_A2.js new file mode 100644 index 0000000000..a9b25b8354 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.2.1_A2.js @@ -0,0 +1,94 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date-year-month-date-hours-minutes-seconds-ms +info: | + All of the arguments are optional, any arguments supplied are + accepted but are completely ignored. A string is created and returned as + if by the expression (new Date()).toString() +es5id: 15.9.2.1_A2 +description: Use various number arguments and various types of ones +---*/ + +function isEqual(d1, d2) { + if (d1 === d2) { + return true; + } else if (Math.abs(Date.parse(d1) - Date.parse(d2)) <= 1000) { + return true; + } else { + return false; + } +} + +//CHECK#1 +if (!isEqual(Date(), (new Date()).toString())) { + $ERROR('#1: Date() is equal to (new Date()).toString()'); +} + +//CHECK#2 +if (!isEqual(Date(1), (new Date()).toString())) { + $ERROR('#2: Date(1) is equal to (new Date()).toString()'); +} + +//CHECK#3 +if (!isEqual(Date(1970, 1), (new Date()).toString())) { + $ERROR('#3: Date(1970, 1) is equal to (new Date()).toString()'); +} + +//CHECK#4 +if (!isEqual(Date(1970, 1, 1), (new Date()).toString())) { + $ERROR('#4: Date(1970, 1, 1) is equal to (new Date()).toString()'); +} + +//CHECK#5 +if (!isEqual(Date(1970, 1, 1, 1), (new Date()).toString())) { + $ERROR('#5: Date(1970, 1, 1, 1) is equal to (new Date()).toString()'); +} + +//CHECK#6 +if (!isEqual(Date(1970, 1, 1, 1), (new Date()).toString())) { + $ERROR('#7: Date(1970, 1, 1, 1) is equal to (new Date()).toString()'); +} + +//CHECK#8 +if (!isEqual(Date(1970, 1, 1, 1, 0), (new Date()).toString())) { + $ERROR('#8: Date(1970, 1, 1, 1, 0) is equal to (new Date()).toString()'); +} + +//CHECK#9 +if (!isEqual(Date(1970, 1, 1, 1, 0, 0), (new Date()).toString())) { + $ERROR('#9: Date(1970, 1, 1, 1, 0, 0) is equal to (new Date()).toString()'); +} + +//CHECK#10 +if (!isEqual(Date(1970, 1, 1, 1, 0, 0, 0), (new Date()).toString())) { + $ERROR('#10: Date(1970, 1, 1, 1, 0, 0, 0) is equal to (new Date()).toString()'); +} + +//CHECK#11 +if (!isEqual(Date(Number.NaN), (new Date()).toString())) { + $ERROR('#11: Date(Number.NaN) is equal to (new Date()).toString()'); +} + +//CHECK#12 +if (!isEqual(Date(Number.POSITIVE_INFINITY), (new Date()).toString())) { + $ERROR('#12: Date(Number.POSITIVE_INFINITY) is equal to (new Date()).toString()'); +} + +//CHECK#13 +if (!isEqual(Date(Number.NEGATIVE_INFINITY), (new Date()).toString())) { + $ERROR('#13: Date(Number.NEGATIVE_INFINITY) is equal to (new Date()).toString()'); +} + +//CHECK#14 +if (!isEqual(Date(undefined), (new Date()).toString())) { + $ERROR('#14: Date(undefined) is equal to (new Date()).toString()'); +} + +//CHECK#15 +if (!isEqual(Date(null), (new Date()).toString())) { + $ERROR('#15: Date(null) is equal to (new Date()).toString()'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T1.js new file mode 100644 index 0000000000..fe47ac1d6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T1.js @@ -0,0 +1,228 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Date is called as part of a new expression it is + a constructor: it initializes the newly created object +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 2 arguments, (year, month) +---*/ + +if (typeof new Date(1899, 11) !== "object") { + $ERROR("#1.1: typeof new Date(1899, 11) should be 'object'"); +} + +if (new Date(1899, 11) === undefined) { + $ERROR("#1.2: new Date(1899, 11) should not be undefined"); +} + +var x13 = new Date(1899, 11); +if (typeof x13 !== "object") { + $ERROR("#1.3: typeof new Date(1899, 11) should be 'object'"); +} + +var x14 = new Date(1899, 11); +if (x14 === undefined) { + $ERROR("#1.4: new Date(1899, 11) should not be undefined"); +} + +if (typeof new Date(1899, 12) !== "object") { + $ERROR("#2.1: typeof new Date(1899, 12) should be 'object'"); +} + +if (new Date(1899, 12) === undefined) { + $ERROR("#2.2: new Date(1899, 12) should not be undefined"); +} + +var x23 = new Date(1899, 12); +if (typeof x23 !== "object") { + $ERROR("#2.3: typeof new Date(1899, 12) should be 'object'"); +} + +var x24 = new Date(1899, 12); +if (x24 === undefined) { + $ERROR("#2.4: new Date(1899, 12) should not be undefined"); +} + +if (typeof new Date(1900, 0) !== "object") { + $ERROR("#3.1: typeof new Date(1900, 0) should be 'object'"); +} + +if (new Date(1900, 0) === undefined) { + $ERROR("#3.2: new Date(1900, 0) should not be undefined"); +} + +var x33 = new Date(1900, 0); +if (typeof x33 !== "object") { + $ERROR("#3.3: typeof new Date(1900, 0) should be 'object'"); +} + +var x34 = new Date(1900, 0); +if (x34 === undefined) { + $ERROR("#3.4: new Date(1900, 0) should not be undefined"); +} + +if (typeof new Date(1969, 11) !== "object") { + $ERROR("#4.1: typeof new Date(1969, 11) should be 'object'"); +} + +if (new Date(1969, 11) === undefined) { + $ERROR("#4.2: new Date(1969, 11) should not be undefined"); +} + +var x43 = new Date(1969, 11); +if (typeof x43 !== "object") { + $ERROR("#4.3: typeof new Date(1969, 11) should be 'object'"); +} + +var x44 = new Date(1969, 11); +if (x44 === undefined) { + $ERROR("#4.4: new Date(1969, 11) should not be undefined"); +} + +if (typeof new Date(1969, 12) !== "object") { + $ERROR("#5.1: typeof new Date(1969, 12) should be 'object'"); +} + +if (new Date(1969, 12) === undefined) { + $ERROR("#5.2: new Date(1969, 12) should not be undefined"); +} + +var x53 = new Date(1969, 12); +if (typeof x53 !== "object") { + $ERROR("#5.3: typeof new Date(1969, 12) should be 'object'"); +} + +var x54 = new Date(1969, 12); +if (x54 === undefined) { + $ERROR("#5.4: new Date(1969, 12) should not be undefined"); +} + +if (typeof new Date(1970, 0) !== "object") { + $ERROR("#6.1: typeof new Date(1970, 0) should be 'object'"); +} + +if (new Date(1970, 0) === undefined) { + $ERROR("#6.2: new Date(1970, 0) should not be undefined"); +} + +var x63 = new Date(1970, 0); +if (typeof x63 !== "object") { + $ERROR("#6.3: typeof new Date(1970, 0) should be 'object'"); +} + +var x64 = new Date(1970, 0); +if (x64 === undefined) { + $ERROR("#6.4: new Date(1970, 0) should not be undefined"); +} + +if (typeof new Date(1999, 11) !== "object") { + $ERROR("#7.1: typeof new Date(1999, 11) should be 'object'"); +} + +if (new Date(1999, 11) === undefined) { + $ERROR("#7.2: new Date(1999, 11) should not be undefined"); +} + +var x73 = new Date(1999, 11); +if (typeof x73 !== "object") { + $ERROR("#7.3: typeof new Date(1999, 11) should be 'object'"); +} + +var x74 = new Date(1999, 11); +if (x74 === undefined) { + $ERROR("#7.4: new Date(1999, 11) should not be undefined"); +} + +if (typeof new Date(1999, 12) !== "object") { + $ERROR("#8.1: typeof new Date(1999, 12) should be 'object'"); +} + +if (new Date(1999, 12) === undefined) { + $ERROR("#8.2: new Date(1999, 12) should not be undefined"); +} + +var x83 = new Date(1999, 12); +if (typeof x83 !== "object") { + $ERROR("#8.3: typeof new Date(1999, 12) should be 'object'"); +} + +var x84 = new Date(1999, 12); +if (x84 === undefined) { + $ERROR("#8.4: new Date(1999, 12) should not be undefined"); +} + +if (typeof new Date(2000, 0) !== "object") { + $ERROR("#9.1: typeof new Date(2000, 0) should be 'object'"); +} + +if (new Date(2000, 0) === undefined) { + $ERROR("#9.2: new Date(2000, 0) should not be undefined"); +} + +var x93 = new Date(2000, 0); +if (typeof x93 !== "object") { + $ERROR("#9.3: typeof new Date(2000, 0) should be 'object'"); +} + +var x94 = new Date(2000, 0); +if (x94 === undefined) { + $ERROR("#9.4: new Date(2000, 0) should not be undefined"); +} + +if (typeof new Date(2099, 11) !== "object") { + $ERROR("#10.1: typeof new Date(2099, 11) should be 'object'"); +} + +if (new Date(2099, 11) === undefined) { + $ERROR("#10.2: new Date(2099, 11) should not be undefined"); +} + +var x103 = new Date(2099, 11); +if (typeof x103 !== "object") { + $ERROR("#10.3: typeof new Date(2099, 11) should be 'object'"); +} + +var x104 = new Date(2099, 11); +if (x104 === undefined) { + $ERROR("#10.4: new Date(2099, 11) should not be undefined"); +} + +if (typeof new Date(2099, 12) !== "object") { + $ERROR("#11.1: typeof new Date(2099, 12) should be 'object'"); +} + +if (new Date(2099, 12) === undefined) { + $ERROR("#11.2: new Date(2099, 12) should not be undefined"); +} + +var x113 = new Date(2099, 12); +if (typeof x113 !== "object") { + $ERROR("#11.3: typeof new Date(2099, 12) should be 'object'"); +} + +var x114 = new Date(2099, 12); +if (x114 === undefined) { + $ERROR("#11.4: new Date(2099, 12) should not be undefined"); +} + +if (typeof new Date(2100, 0) !== "object") { + $ERROR("#12.1: typeof new Date(2100, 0) should be 'object'"); +} + +if (new Date(2100, 0) === undefined) { + $ERROR("#12.2: new Date(2100, 0) should not be undefined"); +} + +var x123 = new Date(2100, 0); +if (typeof x123 !== "object") { + $ERROR("#12.3: typeof new Date(2100, 0) should be 'object'"); +} + +var x124 = new Date(2100, 0); +if (x124 === undefined) { + $ERROR("#12.4: new Date(2100, 0) should not be undefined"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T2.js new file mode 100644 index 0000000000..c93301e936 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T2.js @@ -0,0 +1,228 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Date is called as part of a new expression it is + a constructor: it initializes the newly created object +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 3 arguments, (year, month, date) +---*/ + +if (typeof new Date(1899, 11, 31) !== "object") { + $ERROR("#1.1: typeof new Date(1899, 11, 31) should be 'object'"); +} + +if (new Date(1899, 11, 31) === undefined) { + $ERROR("#1.2: new Date(1899, 11, 31) should not be undefined"); +} + +var x13 = new Date(1899, 11, 31); +if (typeof x13 !== "object") { + $ERROR("#1.3: typeof new Date(1899, 11, 31) should be 'object'"); +} + +var x14 = new Date(1899, 11, 31); +if (x14 === undefined) { + $ERROR("#1.4: new Date(1899, 11, 31) should not be undefined"); +} + +if (typeof new Date(1899, 12, 1) !== "object") { + $ERROR("#2.1: typeof new Date(1899, 12, 1) should be 'object'"); +} + +if (new Date(1899, 12, 1) === undefined) { + $ERROR("#2.2: new Date(1899, 12, 1) should not be undefined"); +} + +var x23 = new Date(1899, 12, 1); +if (typeof x23 !== "object") { + $ERROR("#2.3: typeof new Date(1899, 12, 1) should be 'object'"); +} + +var x24 = new Date(1899, 12, 1); +if (x24 === undefined) { + $ERROR("#2.4: new Date(1899, 12, 1) should not be undefined"); +} + +if (typeof new Date(1900, 0, 1) !== "object") { + $ERROR("#3.1: typeof new Date(1900, 0, 1) should be 'object'"); +} + +if (new Date(1900, 0, 1) === undefined) { + $ERROR("#3.2: new Date(1900, 0, 1) should not be undefined"); +} + +var x33 = new Date(1900, 0, 1); +if (typeof x33 !== "object") { + $ERROR("#3.3: typeof new Date(1900, 0, 1) should be 'object'"); +} + +var x34 = new Date(1900, 0, 1); +if (x34 === undefined) { + $ERROR("#3.4: new Date(1900, 0, 1) should not be undefined"); +} + +if (typeof new Date(1969, 11, 31) !== "object") { + $ERROR("#4.1: typeof new Date(1969, 11, 31) should be 'object'"); +} + +if (new Date(1969, 11, 31) === undefined) { + $ERROR("#4.2: new Date(1969, 11, 31) should not be undefined"); +} + +var x43 = new Date(1969, 11, 31); +if (typeof x43 !== "object") { + $ERROR("#4.3: typeof new Date(1969, 11, 31) should be 'object'"); +} + +var x44 = new Date(1969, 11, 31); +if (x44 === undefined) { + $ERROR("#4.4: new Date(1969, 11, 31) should not be undefined"); +} + +if (typeof new Date(1969, 12, 1) !== "object") { + $ERROR("#5.1: typeof new Date(1969, 12, 1) should be 'object'"); +} + +if (new Date(1969, 12, 1) === undefined) { + $ERROR("#5.2: new Date(1969, 12, 1) should not be undefined"); +} + +var x53 = new Date(1969, 12, 1); +if (typeof x53 !== "object") { + $ERROR("#5.3: typeof new Date(1969, 12, 1) should be 'object'"); +} + +var x54 = new Date(1969, 12, 1); +if (x54 === undefined) { + $ERROR("#5.4: new Date(1969, 12, 1) should not be undefined"); +} + +if (typeof new Date(1970, 0, 1) !== "object") { + $ERROR("#6.1: typeof new Date(1970, 0, 1) should be 'object'"); +} + +if (new Date(1970, 0, 1) === undefined) { + $ERROR("#6.2: new Date(1970, 0, 1) should not be undefined"); +} + +var x63 = new Date(1970, 0, 1); +if (typeof x63 !== "object") { + $ERROR("#6.3: typeof new Date(1970, 0, 1) should be 'object'"); +} + +var x64 = new Date(1970, 0, 1); +if (x64 === undefined) { + $ERROR("#6.4: new Date(1970, 0, 1) should not be undefined"); +} + +if (typeof new Date(1999, 11, 31) !== "object") { + $ERROR("#7.1: typeof new Date(1999, 11, 31) should be 'object'"); +} + +if (new Date(1999, 11, 31) === undefined) { + $ERROR("#7.2: new Date(1999, 11, 31) should not be undefined"); +} + +var x73 = new Date(1999, 11, 31); +if (typeof x73 !== "object") { + $ERROR("#7.3: typeof new Date(1999, 11, 31) should be 'object'"); +} + +var x74 = new Date(1999, 11, 31); +if (x74 === undefined) { + $ERROR("#7.4: new Date(1999, 11, 31) should not be undefined"); +} + +if (typeof new Date(1999, 12, 1) !== "object") { + $ERROR("#8.1: typeof new Date(1999, 12, 1) should be 'object'"); +} + +if (new Date(1999, 12, 1) === undefined) { + $ERROR("#8.2: new Date(1999, 12, 1) should not be undefined"); +} + +var x83 = new Date(1999, 12, 1); +if (typeof x83 !== "object") { + $ERROR("#8.3: typeof new Date(1999, 12, 1) should be 'object'"); +} + +var x84 = new Date(1999, 12, 1); +if (x84 === undefined) { + $ERROR("#8.4: new Date(1999, 12, 1) should not be undefined"); +} + +if (typeof new Date(2000, 0, 1) !== "object") { + $ERROR("#9.1: typeof new Date(2000, 0, 1) should be 'object'"); +} + +if (new Date(2000, 0, 1) === undefined) { + $ERROR("#9.2: new Date(2000, 0, 1) should not be undefined"); +} + +var x93 = new Date(2000, 0, 1); +if (typeof x93 !== "object") { + $ERROR("#9.3: typeof new Date(2000, 0, 1) should be 'object'"); +} + +var x94 = new Date(2000, 0, 1); +if (x94 === undefined) { + $ERROR("#9.4: new Date(2000, 0, 1) should not be undefined"); +} + +if (typeof new Date(2099, 11, 31) !== "object") { + $ERROR("#10.1: typeof new Date(2099, 11, 31) should be 'object'"); +} + +if (new Date(2099, 11, 31) === undefined) { + $ERROR("#10.2: new Date(2099, 11, 31) should not be undefined"); +} + +var x103 = new Date(2099, 11, 31); +if (typeof x103 !== "object") { + $ERROR("#10.3: typeof new Date(2099, 11, 31) should be 'object'"); +} + +var x104 = new Date(2099, 11, 31); +if (x104 === undefined) { + $ERROR("#10.4: new Date(2099, 11, 31) should not be undefined"); +} + +if (typeof new Date(2099, 12, 1) !== "object") { + $ERROR("#11.1: typeof new Date(2099, 12, 1) should be 'object'"); +} + +if (new Date(2099, 12, 1) === undefined) { + $ERROR("#11.2: new Date(2099, 12, 1) should not be undefined"); +} + +var x113 = new Date(2099, 12, 1); +if (typeof x113 !== "object") { + $ERROR("#11.3: typeof new Date(2099, 12, 1) should be 'object'"); +} + +var x114 = new Date(2099, 12, 1); +if (x114 === undefined) { + $ERROR("#11.4: new Date(2099, 12, 1) should not be undefined"); +} + +if (typeof new Date(2100, 0, 1) !== "object") { + $ERROR("#12.1: typeof new Date(2100, 0, 1) should be 'object'"); +} + +if (new Date(2100, 0, 1) === undefined) { + $ERROR("#12.2: new Date(2100, 0, 1) should not be undefined"); +} + +var x123 = new Date(2100, 0, 1); +if (typeof x123 !== "object") { + $ERROR("#12.3: typeof new Date(2100, 0, 1) should be 'object'"); +} + +var x124 = new Date(2100, 0, 1); +if (x124 === undefined) { + $ERROR("#12.4: new Date(2100, 0, 1) should not be undefined"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T3.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T3.js new file mode 100644 index 0000000000..9488a3f0c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T3.js @@ -0,0 +1,228 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Date is called as part of a new expression it is + a constructor: it initializes the newly created object +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 4 arguments, (year, month, date, hours) +---*/ + +if (typeof new Date(1899, 11, 31, 23) !== "object") { + $ERROR("#1.1: typeof new Date(1899, 11, 31, 23) should be 'object'"); +} + +if (new Date(1899, 11, 31, 23) === undefined) { + $ERROR("#1.2: new Date(1899, 11, 31, 23) should not be undefined"); +} + +var x13 = new Date(1899, 11, 31, 23); +if (typeof x13 !== "object") { + $ERROR("#1.3: typeof new Date(1899, 11, 31, 23) should be 'object'"); +} + +var x14 = new Date(1899, 11, 31, 23); +if (x14 === undefined) { + $ERROR("#1.4: new Date(1899, 11, 31, 23) should not be undefined"); +} + +if (typeof new Date(1899, 12, 1, 0) !== "object") { + $ERROR("#2.1: typeof new Date(1899, 12, 1, 0) should be 'object'"); +} + +if (new Date(1899, 12, 1, 0) === undefined) { + $ERROR("#2.2: new Date(1899, 12, 1, 0) should not be undefined"); +} + +var x23 = new Date(1899, 12, 1, 0); +if (typeof x23 !== "object") { + $ERROR("#2.3: typeof new Date(1899, 12, 1, 0) should be 'object'"); +} + +var x24 = new Date(1899, 12, 1, 0); +if (x24 === undefined) { + $ERROR("#2.4: new Date(1899, 12, 1, 0) should not be undefined"); +} + +if (typeof new Date(1900, 0, 1, 0) !== "object") { + $ERROR("#3.1: typeof new Date(1900, 0, 1, 0) should be 'object'"); +} + +if (new Date(1900, 0, 1, 0) === undefined) { + $ERROR("#3.2: new Date(1900, 0, 1, 0) should not be undefined"); +} + +var x33 = new Date(1900, 0, 1, 0); +if (typeof x33 !== "object") { + $ERROR("#3.3: typeof new Date(1900, 0, 1, 0) should be 'object'"); +} + +var x34 = new Date(1900, 0, 1, 0); +if (x34 === undefined) { + $ERROR("#3.4: new Date(1900, 0, 1, 0) should not be undefined"); +} + +if (typeof new Date(1969, 11, 31, 23) !== "object") { + $ERROR("#4.1: typeof new Date(1969, 11, 31, 23) should be 'object'"); +} + +if (new Date(1969, 11, 31, 23) === undefined) { + $ERROR("#4.2: new Date(1969, 11, 31, 23) should not be undefined"); +} + +var x43 = new Date(1969, 11, 31, 23); +if (typeof x43 !== "object") { + $ERROR("#4.3: typeof new Date(1969, 11, 31, 23) should be 'object'"); +} + +var x44 = new Date(1969, 11, 31, 23); +if (x44 === undefined) { + $ERROR("#4.4: new Date(1969, 11, 31, 23) should not be undefined"); +} + +if (typeof new Date(1969, 12, 1, 0) !== "object") { + $ERROR("#5.1: typeof new Date(1969, 12, 1, 0) should be 'object'"); +} + +if (new Date(1969, 12, 1, 0) === undefined) { + $ERROR("#5.2: new Date(1969, 12, 1, 0) should not be undefined"); +} + +var x53 = new Date(1969, 12, 1, 0); +if (typeof x53 !== "object") { + $ERROR("#5.3: typeof new Date(1969, 12, 1, 0) should be 'object'"); +} + +var x54 = new Date(1969, 12, 1, 0); +if (x54 === undefined) { + $ERROR("#5.4: new Date(1969, 12, 1, 0) should not be undefined"); +} + +if (typeof new Date(1970, 0, 1, 0) !== "object") { + $ERROR("#6.1: typeof new Date(1970, 0, 1, 0) should be 'object'"); +} + +if (new Date(1970, 0, 1, 0) === undefined) { + $ERROR("#6.2: new Date(1970, 0, 1, 0) should not be undefined"); +} + +var x63 = new Date(1970, 0, 1, 0); +if (typeof x63 !== "object") { + $ERROR("#6.3: typeof new Date(1970, 0, 1, 0) should be 'object'"); +} + +var x64 = new Date(1970, 0, 1, 0); +if (x64 === undefined) { + $ERROR("#6.4: new Date(1970, 0, 1, 0) should not be undefined"); +} + +if (typeof new Date(1999, 11, 31, 23) !== "object") { + $ERROR("#7.1: typeof new Date(1999, 11, 31, 23) should be 'object'"); +} + +if (new Date(1999, 11, 31, 23) === undefined) { + $ERROR("#7.2: new Date(1999, 11, 31, 23) should not be undefined"); +} + +var x73 = new Date(1999, 11, 31, 23); +if (typeof x73 !== "object") { + $ERROR("#7.3: typeof new Date(1999, 11, 31, 23) should be 'object'"); +} + +var x74 = new Date(1999, 11, 31, 23); +if (x74 === undefined) { + $ERROR("#7.4: new Date(1999, 11, 31, 23) should not be undefined"); +} + +if (typeof new Date(1999, 12, 1, 0) !== "object") { + $ERROR("#8.1: typeof new Date(1999, 12, 1, 0) should be 'object'"); +} + +if (new Date(1999, 12, 1, 0) === undefined) { + $ERROR("#8.2: new Date(1999, 12, 1, 0) should not be undefined"); +} + +var x83 = new Date(1999, 12, 1, 0); +if (typeof x83 !== "object") { + $ERROR("#8.3: typeof new Date(1999, 12, 1, 0) should be 'object'"); +} + +var x84 = new Date(1999, 12, 1, 0); +if (x84 === undefined) { + $ERROR("#8.4: new Date(1999, 12, 1, 0) should not be undefined"); +} + +if (typeof new Date(2000, 0, 1, 0) !== "object") { + $ERROR("#9.1: typeof new Date(2000, 0, 1, 0) should be 'object'"); +} + +if (new Date(2000, 0, 1, 0) === undefined) { + $ERROR("#9.2: new Date(2000, 0, 1, 0) should not be undefined"); +} + +var x93 = new Date(2000, 0, 1, 0); +if (typeof x93 !== "object") { + $ERROR("#9.3: typeof new Date(2000, 0, 1, 0) should be 'object'"); +} + +var x94 = new Date(2000, 0, 1, 0); +if (x94 === undefined) { + $ERROR("#9.4: new Date(2000, 0, 1, 0) should not be undefined"); +} + +if (typeof new Date(2099, 11, 31, 23) !== "object") { + $ERROR("#10.1: typeof new Date(2099, 11, 31, 23) should be 'object'"); +} + +if (new Date(2099, 11, 31, 23) === undefined) { + $ERROR("#10.2: new Date(2099, 11, 31, 23) should not be undefined"); +} + +var x103 = new Date(2099, 11, 31, 23); +if (typeof x103 !== "object") { + $ERROR("#10.3: typeof new Date(2099, 11, 31, 23) should be 'object'"); +} + +var x104 = new Date(2099, 11, 31, 23); +if (x104 === undefined) { + $ERROR("#10.4: new Date(2099, 11, 31, 23) should not be undefined"); +} + +if (typeof new Date(2099, 12, 1, 0) !== "object") { + $ERROR("#11.1: typeof new Date(2099, 12, 1, 0) should be 'object'"); +} + +if (new Date(2099, 12, 1, 0) === undefined) { + $ERROR("#11.2: new Date(2099, 12, 1, 0) should not be undefined"); +} + +var x113 = new Date(2099, 12, 1, 0); +if (typeof x113 !== "object") { + $ERROR("#11.3: typeof new Date(2099, 12, 1, 0) should be 'object'"); +} + +var x114 = new Date(2099, 12, 1, 0); +if (x114 === undefined) { + $ERROR("#11.4: new Date(2099, 12, 1, 0) should not be undefined"); +} + +if (typeof new Date(2100, 0, 1, 0) !== "object") { + $ERROR("#12.1: typeof new Date(2100, 0, 1, 0) should be 'object'"); +} + +if (new Date(2100, 0, 1, 0) === undefined) { + $ERROR("#12.2: new Date(2100, 0, 1, 0) should not be undefined"); +} + +var x123 = new Date(2100, 0, 1, 0); +if (typeof x123 !== "object") { + $ERROR("#12.3: typeof new Date(2100, 0, 1, 0) should be 'object'"); +} + +var x124 = new Date(2100, 0, 1, 0); +if (x124 === undefined) { + $ERROR("#12.4: new Date(2100, 0, 1, 0) should not be undefined"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T4.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T4.js new file mode 100644 index 0000000000..6857c3fc74 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T4.js @@ -0,0 +1,228 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Date is called as part of a new expression it is + a constructor: it initializes the newly created object +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 5 arguments, (year, month, date, hours, minutes) +---*/ + +if (typeof new Date(1899, 11, 31, 23, 59) !== "object") { + $ERROR("#1.1: typeof new Date(1899, 11, 31, 23, 59) should be 'object'"); +} + +if (new Date(1899, 11, 31, 23, 59) === undefined) { + $ERROR("#1.2: new Date(1899, 11, 31, 23, 59) should not be undefined"); +} + +var x13 = new Date(1899, 11, 31, 23, 59); +if (typeof x13 !== "object") { + $ERROR("#1.3: typeof new Date(1899, 11, 31, 23, 59) should be 'object'"); +} + +var x14 = new Date(1899, 11, 31, 23, 59); +if (x14 === undefined) { + $ERROR("#1.4: new Date(1899, 11, 31, 23, 59) should not be undefined"); +} + +if (typeof new Date(1899, 12, 1, 0, 0) !== "object") { + $ERROR("#2.1: typeof new Date(1899, 12, 1, 0, 0) should be 'object'"); +} + +if (new Date(1899, 12, 1, 0, 0) === undefined) { + $ERROR("#2.2: new Date(1899, 12, 1, 0, 0) should not be undefined"); +} + +var x23 = new Date(1899, 12, 1, 0, 0); +if (typeof x23 !== "object") { + $ERROR("#2.3: typeof new Date(1899, 12, 1, 0, 0) should be 'object'"); +} + +var x24 = new Date(1899, 12, 1, 0, 0); +if (x24 === undefined) { + $ERROR("#2.4: new Date(1899, 12, 1, 0, 0) should not be undefined"); +} + +if (typeof new Date(1900, 0, 1, 0, 0) !== "object") { + $ERROR("#3.1: typeof new Date(1900, 0, 1, 0, 0) should be 'object'"); +} + +if (new Date(1900, 0, 1, 0, 0) === undefined) { + $ERROR("#3.2: new Date(1900, 0, 1, 0, 0) should not be undefined"); +} + +var x33 = new Date(1900, 0, 1, 0, 0); +if (typeof x33 !== "object") { + $ERROR("#3.3: typeof new Date(1900, 0, 1, 0, 0) should be 'object'"); +} + +var x34 = new Date(1900, 0, 1, 0, 0); +if (x34 === undefined) { + $ERROR("#3.4: new Date(1900, 0, 1, 0, 0) should not be undefined"); +} + +if (typeof new Date(1969, 11, 31, 23, 59) !== "object") { + $ERROR("#4.1: typeof new Date(1969, 11, 31, 23, 59) should be 'object'"); +} + +if (new Date(1969, 11, 31, 23, 59) === undefined) { + $ERROR("#4.2: new Date(1969, 11, 31, 23, 59) should not be undefined"); +} + +var x43 = new Date(1969, 11, 31, 23, 59); +if (typeof x43 !== "object") { + $ERROR("#4.3: typeof new Date(1969, 11, 31, 23, 59) should be 'object'"); +} + +var x44 = new Date(1969, 11, 31, 23, 59); +if (x44 === undefined) { + $ERROR("#4.4: new Date(1969, 11, 31, 23, 59) should not be undefined"); +} + +if (typeof new Date(1969, 12, 1, 0, 0) !== "object") { + $ERROR("#5.1: typeof new Date(1969, 12, 1, 0, 0) should be 'object'"); +} + +if (new Date(1969, 12, 1, 0, 0) === undefined) { + $ERROR("#5.2: new Date(1969, 12, 1, 0, 0) should not be undefined"); +} + +var x53 = new Date(1969, 12, 1, 0, 0); +if (typeof x53 !== "object") { + $ERROR("#5.3: typeof new Date(1969, 12, 1, 0, 0) should be 'object'"); +} + +var x54 = new Date(1969, 12, 1, 0, 0); +if (x54 === undefined) { + $ERROR("#5.4: new Date(1969, 12, 1, 0, 0) should not be undefined"); +} + +if (typeof new Date(1970, 0, 1, 0, 0) !== "object") { + $ERROR("#6.1: typeof new Date(1970, 0, 1, 0, 0) should be 'object'"); +} + +if (new Date(1970, 0, 1, 0, 0) === undefined) { + $ERROR("#6.2: new Date(1970, 0, 1, 0, 0) should not be undefined"); +} + +var x63 = new Date(1970, 0, 1, 0, 0); +if (typeof x63 !== "object") { + $ERROR("#6.3: typeof new Date(1970, 0, 1, 0, 0) should be 'object'"); +} + +var x64 = new Date(1970, 0, 1, 0, 0); +if (x64 === undefined) { + $ERROR("#6.4: new Date(1970, 0, 1, 0, 0) should not be undefined"); +} + +if (typeof new Date(1999, 11, 31, 23, 59) !== "object") { + $ERROR("#7.1: typeof new Date(1999, 11, 31, 23, 59) should be 'object'"); +} + +if (new Date(1999, 11, 31, 23, 59) === undefined) { + $ERROR("#7.2: new Date(1999, 11, 31, 23, 59) should not be undefined"); +} + +var x73 = new Date(1999, 11, 31, 23, 59); +if (typeof x73 !== "object") { + $ERROR("#7.3: typeof new Date(1999, 11, 31, 23, 59) should be 'object'"); +} + +var x74 = new Date(1999, 11, 31, 23, 59); +if (x74 === undefined) { + $ERROR("#7.4: new Date(1999, 11, 31, 23, 59) should not be undefined"); +} + +if (typeof new Date(1999, 12, 1, 0, 0) !== "object") { + $ERROR("#8.1: typeof new Date(1999, 12, 1, 0, 0) should be 'object'"); +} + +if (new Date(1999, 12, 1, 0, 0) === undefined) { + $ERROR("#8.2: new Date(1999, 12, 1, 0, 0) should not be undefined"); +} + +var x83 = new Date(1999, 12, 1, 0, 0); +if (typeof x83 !== "object") { + $ERROR("#8.3: typeof new Date(1999, 12, 1, 0, 0) should be 'object'"); +} + +var x84 = new Date(1999, 12, 1, 0, 0); +if (x84 === undefined) { + $ERROR("#8.4: new Date(1999, 12, 1, 0, 0) should not be undefined"); +} + +if (typeof new Date(2000, 0, 1, 0, 0) !== "object") { + $ERROR("#9.1: typeof new Date(2000, 0, 1, 0, 0) should be 'object'"); +} + +if (new Date(2000, 0, 1, 0, 0) === undefined) { + $ERROR("#9.2: new Date(2000, 0, 1, 0, 0) should not be undefined"); +} + +var x93 = new Date(2000, 0, 1, 0, 0); +if (typeof x93 !== "object") { + $ERROR("#9.3: typeof new Date(2000, 0, 1, 0, 0) should be 'object'"); +} + +var x94 = new Date(2000, 0, 1, 0, 0); +if (x94 === undefined) { + $ERROR("#9.4: new Date(2000, 0, 1, 0, 0) should not be undefined"); +} + +if (typeof new Date(2099, 11, 31, 23, 59) !== "object") { + $ERROR("#10.1: typeof new Date(2099, 11, 31, 23, 59) should be 'object'"); +} + +if (new Date(2099, 11, 31, 23, 59) === undefined) { + $ERROR("#10.2: new Date(2099, 11, 31, 23, 59) should not be undefined"); +} + +var x103 = new Date(2099, 11, 31, 23, 59); +if (typeof x103 !== "object") { + $ERROR("#10.3: typeof new Date(2099, 11, 31, 23, 59) should be 'object'"); +} + +var x104 = new Date(2099, 11, 31, 23, 59); +if (x104 === undefined) { + $ERROR("#10.4: new Date(2099, 11, 31, 23, 59) should not be undefined"); +} + +if (typeof new Date(2099, 12, 1, 0, 0) !== "object") { + $ERROR("#11.1: typeof new Date(2099, 12, 1, 0, 0) should be 'object'"); +} + +if (new Date(2099, 12, 1, 0, 0) === undefined) { + $ERROR("#11.2: new Date(2099, 12, 1, 0, 0) should not be undefined"); +} + +var x113 = new Date(2099, 12, 1, 0, 0); +if (typeof x113 !== "object") { + $ERROR("#11.3: typeof new Date(2099, 12, 1, 0, 0) should be 'object'"); +} + +var x114 = new Date(2099, 12, 1, 0, 0); +if (x114 === undefined) { + $ERROR("#11.4: new Date(2099, 12, 1, 0, 0) should not be undefined"); +} + +if (typeof new Date(2100, 0, 1, 0, 0) !== "object") { + $ERROR("#12.1: typeof new Date(2100, 0, 1, 0, 0) should be 'object'"); +} + +if (new Date(2100, 0, 1, 0, 0) === undefined) { + $ERROR("#12.2: new Date(2100, 0, 1, 0, 0) should not be undefined"); +} + +var x123 = new Date(2100, 0, 1, 0, 0); +if (typeof x123 !== "object") { + $ERROR("#12.3: typeof new Date(2100, 0, 1, 0, 0) should be 'object'"); +} + +var x124 = new Date(2100, 0, 1, 0, 0); +if (x124 === undefined) { + $ERROR("#12.4: new Date(2100, 0, 1, 0, 0) should not be undefined"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T5.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T5.js new file mode 100644 index 0000000000..ee689ed36d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T5.js @@ -0,0 +1,228 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Date is called as part of a new expression it is + a constructor: it initializes the newly created object +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 6 arguments, (year, month, date, hours, minutes, seconds) +---*/ + +if (typeof new Date(1899, 11, 31, 23, 59, 59) !== "object") { + $ERROR("#1.1: typeof new Date(1899, 11, 31, 23, 59, 59) should be 'object'"); +} + +if (new Date(1899, 11, 31, 23, 59, 59) === undefined) { + $ERROR("#1.2: new Date(1899, 11, 31, 23, 59, 59) should not be undefined"); +} + +var x13 = new Date(1899, 11, 31, 23, 59, 59); +if (typeof x13 !== "object") { + $ERROR("#1.3: typeof new Date(1899, 11, 31, 23, 59, 59) should be 'object'"); +} + +var x14 = new Date(1899, 11, 31, 23, 59, 59); +if (x14 === undefined) { + $ERROR("#1.4: new Date(1899, 11, 31, 23, 59, 59) should not be undefined"); +} + +if (typeof new Date(1899, 12, 1, 0, 0, 0) !== "object") { + $ERROR("#2.1: typeof new Date(1899, 12, 1, 0, 0, 0) should be 'object'"); +} + +if (new Date(1899, 12, 1, 0, 0, 0) === undefined) { + $ERROR("#2.2: new Date(1899, 12, 1, 0, 0, 0) should not be undefined"); +} + +var x23 = new Date(1899, 12, 1, 0, 0, 0); +if (typeof x23 !== "object") { + $ERROR("#2.3: typeof new Date(1899, 12, 1, 0, 0, 0) should be 'object'"); +} + +var x24 = new Date(1899, 12, 1, 0, 0, 0); +if (x24 === undefined) { + $ERROR("#2.4: new Date(1899, 12, 1, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(1900, 0, 1, 0, 0, 0) !== "object") { + $ERROR("#3.1: typeof new Date(1900, 0, 1, 0, 0, 0) should be 'object'"); +} + +if (new Date(1900, 0, 1, 0, 0, 0) === undefined) { + $ERROR("#3.2: new Date(1900, 0, 1, 0, 0, 0) should not be undefined"); +} + +var x33 = new Date(1900, 0, 1, 0, 0, 0); +if (typeof x33 !== "object") { + $ERROR("#3.3: typeof new Date(1900, 0, 1, 0, 0, 0) should be 'object'"); +} + +var x34 = new Date(1900, 0, 1, 0, 0, 0); +if (x34 === undefined) { + $ERROR("#3.4: new Date(1900, 0, 1, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(1969, 11, 31, 23, 59, 59) !== "object") { + $ERROR("#4.1: typeof new Date(1969, 11, 31, 23, 59, 59) should be 'object'"); +} + +if (new Date(1969, 11, 31, 23, 59, 59) === undefined) { + $ERROR("#4.2: new Date(1969, 11, 31, 23, 59, 59) should not be undefined"); +} + +var x43 = new Date(1969, 11, 31, 23, 59, 59); +if (typeof x43 !== "object") { + $ERROR("#4.3: typeof new Date(1969, 11, 31, 23, 59, 59) should be 'object'"); +} + +var x44 = new Date(1969, 11, 31, 23, 59, 59); +if (x44 === undefined) { + $ERROR("#4.4: new Date(1969, 11, 31, 23, 59, 59) should not be undefined"); +} + +if (typeof new Date(1969, 12, 1, 0, 0, 0) !== "object") { + $ERROR("#5.1: typeof new Date(1969, 12, 1, 0, 0, 0) should be 'object'"); +} + +if (new Date(1969, 12, 1, 0, 0, 0) === undefined) { + $ERROR("#5.2: new Date(1969, 12, 1, 0, 0, 0) should not be undefined"); +} + +var x53 = new Date(1969, 12, 1, 0, 0, 0); +if (typeof x53 !== "object") { + $ERROR("#5.3: typeof new Date(1969, 12, 1, 0, 0, 0) should be 'object'"); +} + +var x54 = new Date(1969, 12, 1, 0, 0, 0); +if (x54 === undefined) { + $ERROR("#5.4: new Date(1969, 12, 1, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(1970, 0, 1, 0, 0, 0) !== "object") { + $ERROR("#6.1: typeof new Date(1970, 0, 1, 0, 0, 0) should be 'object'"); +} + +if (new Date(1970, 0, 1, 0, 0, 0) === undefined) { + $ERROR("#6.2: new Date(1970, 0, 1, 0, 0, 0) should not be undefined"); +} + +var x63 = new Date(1970, 0, 1, 0, 0, 0); +if (typeof x63 !== "object") { + $ERROR("#6.3: typeof new Date(1970, 0, 1, 0, 0, 0) should be 'object'"); +} + +var x64 = new Date(1970, 0, 1, 0, 0, 0); +if (x64 === undefined) { + $ERROR("#6.4: new Date(1970, 0, 1, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(1999, 11, 31, 23, 59, 59) !== "object") { + $ERROR("#7.1: typeof new Date(1999, 11, 31, 23, 59, 59) should be 'object'"); +} + +if (new Date(1999, 11, 31, 23, 59, 59) === undefined) { + $ERROR("#7.2: new Date(1999, 11, 31, 23, 59, 59) should not be undefined"); +} + +var x73 = new Date(1999, 11, 31, 23, 59, 59); +if (typeof x73 !== "object") { + $ERROR("#7.3: typeof new Date(1999, 11, 31, 23, 59, 59) should be 'object'"); +} + +var x74 = new Date(1999, 11, 31, 23, 59, 59); +if (x74 === undefined) { + $ERROR("#7.4: new Date(1999, 11, 31, 23, 59, 59) should not be undefined"); +} + +if (typeof new Date(1999, 12, 1, 0, 0, 0) !== "object") { + $ERROR("#8.1: typeof new Date(1999, 12, 1, 0, 0, 0) should be 'object'"); +} + +if (new Date(1999, 12, 1, 0, 0, 0) === undefined) { + $ERROR("#8.2: new Date(1999, 12, 1, 0, 0, 0) should not be undefined"); +} + +var x83 = new Date(1999, 12, 1, 0, 0, 0); +if (typeof x83 !== "object") { + $ERROR("#8.3: typeof new Date(1999, 12, 1, 0, 0, 0) should be 'object'"); +} + +var x84 = new Date(1999, 12, 1, 0, 0, 0); +if (x84 === undefined) { + $ERROR("#8.4: new Date(1999, 12, 1, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(2000, 0, 1, 0, 0, 0) !== "object") { + $ERROR("#9.1: typeof new Date(2000, 0, 1, 0, 0, 0) should be 'object'"); +} + +if (new Date(2000, 0, 1, 0, 0, 0) === undefined) { + $ERROR("#9.2: new Date(2000, 0, 1, 0, 0, 0) should not be undefined"); +} + +var x93 = new Date(2000, 0, 1, 0, 0, 0); +if (typeof x93 !== "object") { + $ERROR("#9.3: typeof new Date(2000, 0, 1, 0, 0, 0) should be 'object'"); +} + +var x94 = new Date(2000, 0, 1, 0, 0, 0); +if (x94 === undefined) { + $ERROR("#9.4: new Date(2000, 0, 1, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(2099, 11, 31, 23, 59, 59) !== "object") { + $ERROR("#10.1: typeof new Date(2099, 11, 31, 23, 59, 59) should be 'object'"); +} + +if (new Date(2099, 11, 31, 23, 59, 59) === undefined) { + $ERROR("#10.2: new Date(2099, 11, 31, 23, 59, 59) should not be undefined"); +} + +var x103 = new Date(2099, 11, 31, 23, 59, 59); +if (typeof x103 !== "object") { + $ERROR("#10.3: typeof new Date(2099, 11, 31, 23, 59, 59) should be 'object'"); +} + +var x104 = new Date(2099, 11, 31, 23, 59, 59); +if (x104 === undefined) { + $ERROR("#10.4: new Date(2099, 11, 31, 23, 59, 59) should not be undefined"); +} + +if (typeof new Date(2099, 12, 1, 0, 0, 0) !== "object") { + $ERROR("#11.1: typeof new Date(2099, 12, 1, 0, 0, 0) should be 'object'"); +} + +if (new Date(2099, 12, 1, 0, 0, 0) === undefined) { + $ERROR("#11.2: new Date(2099, 12, 1, 0, 0, 0) should not be undefined"); +} + +var x113 = new Date(2099, 12, 1, 0, 0, 0); +if (typeof x113 !== "object") { + $ERROR("#11.3: typeof new Date(2099, 12, 1, 0, 0, 0) should be 'object'"); +} + +var x114 = new Date(2099, 12, 1, 0, 0, 0); +if (x114 === undefined) { + $ERROR("#11.4: new Date(2099, 12, 1, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(2100, 0, 1, 0, 0, 0) !== "object") { + $ERROR("#12.1: typeof new Date(2100, 0, 1, 0, 0, 0) should be 'object'"); +} + +if (new Date(2100, 0, 1, 0, 0, 0) === undefined) { + $ERROR("#12.2: new Date(2100, 0, 1, 0, 0, 0) should not be undefined"); +} + +var x123 = new Date(2100, 0, 1, 0, 0, 0); +if (typeof x123 !== "object") { + $ERROR("#12.3: typeof new Date(2100, 0, 1, 0, 0, 0) should be 'object'"); +} + +var x124 = new Date(2100, 0, 1, 0, 0, 0); +if (x124 === undefined) { + $ERROR("#12.4: new Date(2100, 0, 1, 0, 0, 0) should not be undefined"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T6.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T6.js new file mode 100644 index 0000000000..8b53e441aa --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A1_T6.js @@ -0,0 +1,228 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Date is called as part of a new expression it is + a constructor: it initializes the newly created object +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 7 arguments, (year, month, date, hours, minutes, seconds, ms) +---*/ + +if (typeof new Date(1899, 11, 31, 23, 59, 59, 999) !== "object") { + $ERROR("#1.1: typeof new Date(1899, 11, 31, 23, 59, 59, 999) should be 'object'"); +} + +if (new Date(1899, 11, 31, 23, 59, 59, 999) === undefined) { + $ERROR("#1.2: new Date(1899, 11, 31, 23, 59, 59, 999) should not be undefined"); +} + +var x13 = new Date(1899, 11, 31, 23, 59, 59, 999); +if (typeof x13 !== "object") { + $ERROR("#1.3: typeof new Date(1899, 11, 31, 23, 59, 59, 999) should be 'object'"); +} + +var x14 = new Date(1899, 11, 31, 23, 59, 59, 999); +if (x14 === undefined) { + $ERROR("#1.4: new Date(1899, 11, 31, 23, 59, 59, 999) should not be undefined"); +} + +if (typeof new Date(1899, 12, 1, 0, 0, 0, 0) !== "object") { + $ERROR("#2.1: typeof new Date(1899, 12, 1, 0, 0, 0, 0) should be 'object'"); +} + +if (new Date(1899, 12, 1, 0, 0, 0, 0) === undefined) { + $ERROR("#2.2: new Date(1899, 12, 1, 0, 0, 0, 0) should not be undefined"); +} + +var x23 = new Date(1899, 12, 1, 0, 0, 0, 0); +if (typeof x23 !== "object") { + $ERROR("#2.3: typeof new Date(1899, 12, 1, 0, 0, 0, 0) should be 'object'"); +} + +var x24 = new Date(1899, 12, 1, 0, 0, 0, 0); +if (x24 === undefined) { + $ERROR("#2.4: new Date(1899, 12, 1, 0, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(1900, 0, 1, 0, 0, 0, 0) !== "object") { + $ERROR("#3.1: typeof new Date(1900, 0, 1, 0, 0, 0, 0) should be 'object'"); +} + +if (new Date(1900, 0, 1, 0, 0, 0, 0) === undefined) { + $ERROR("#3.2: new Date(1900, 0, 1, 0, 0, 0, 0) should not be undefined"); +} + +var x33 = new Date(1900, 0, 1, 0, 0, 0, 0); +if (typeof x33 !== "object") { + $ERROR("#3.3: typeof new Date(1900, 0, 1, 0, 0, 0, 0) should be 'object'"); +} + +var x34 = new Date(1900, 0, 1, 0, 0, 0, 0); +if (x34 === undefined) { + $ERROR("#3.4: new Date(1900, 0, 1, 0, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(1969, 11, 31, 23, 59, 59, 999) !== "object") { + $ERROR("#4.1: typeof new Date(1969, 11, 31, 23, 59, 59, 999) should be 'object'"); +} + +if (new Date(1969, 11, 31, 23, 59, 59, 999) === undefined) { + $ERROR("#4.2: new Date(1969, 11, 31, 23, 59, 59, 999) should not be undefined"); +} + +var x43 = new Date(1969, 11, 31, 23, 59, 59, 999); +if (typeof x43 !== "object") { + $ERROR("#4.3: typeof new Date(1969, 11, 31, 23, 59, 59, 999) should be 'object'"); +} + +var x44 = new Date(1969, 11, 31, 23, 59, 59, 999); +if (x44 === undefined) { + $ERROR("#4.4: new Date(1969, 11, 31, 23, 59, 59, 999) should not be undefined"); +} + +if (typeof new Date(1969, 12, 1, 0, 0, 0, 0) !== "object") { + $ERROR("#5.1: typeof new Date(1969, 12, 1, 0, 0, 0, 0) should be 'object'"); +} + +if (new Date(1969, 12, 1, 0, 0, 0, 0) === undefined) { + $ERROR("#5.2: new Date(1969, 12, 1, 0, 0, 0, 0) should not be undefined"); +} + +var x53 = new Date(1969, 12, 1, 0, 0, 0, 0); +if (typeof x53 !== "object") { + $ERROR("#5.3: typeof new Date(1969, 12, 1, 0, 0, 0, 0) should be 'object'"); +} + +var x54 = new Date(1969, 12, 1, 0, 0, 0, 0); +if (x54 === undefined) { + $ERROR("#5.4: new Date(1969, 12, 1, 0, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(1970, 0, 1, 0, 0, 0, 0) !== "object") { + $ERROR("#6.1: typeof new Date(1970, 0, 1, 0, 0, 0, 0) should be 'object'"); +} + +if (new Date(1970, 0, 1, 0, 0, 0, 0) === undefined) { + $ERROR("#6.2: new Date(1970, 0, 1, 0, 0, 0, 0) should not be undefined"); +} + +var x63 = new Date(1970, 0, 1, 0, 0, 0, 0); +if (typeof x63 !== "object") { + $ERROR("#6.3: typeof new Date(1970, 0, 1, 0, 0, 0, 0) should be 'object'"); +} + +var x64 = new Date(1970, 0, 1, 0, 0, 0, 0); +if (x64 === undefined) { + $ERROR("#6.4: new Date(1970, 0, 1, 0, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(1999, 11, 31, 23, 59, 59, 999) !== "object") { + $ERROR("#7.1: typeof new Date(1999, 11, 31, 23, 59, 59, 999) should be 'object'"); +} + +if (new Date(1999, 11, 31, 23, 59, 59, 999) === undefined) { + $ERROR("#7.2: new Date(1999, 11, 31, 23, 59, 59, 999) should not be undefined"); +} + +var x73 = new Date(1999, 11, 31, 23, 59, 59, 999); +if (typeof x73 !== "object") { + $ERROR("#7.3: typeof new Date(1999, 11, 31, 23, 59, 59, 999) should be 'object'"); +} + +var x74 = new Date(1999, 11, 31, 23, 59, 59, 999); +if (x74 === undefined) { + $ERROR("#7.4: new Date(1999, 11, 31, 23, 59, 59, 999) should not be undefined"); +} + +if (typeof new Date(1999, 12, 1, 0, 0, 0, 0) !== "object") { + $ERROR("#8.1: typeof new Date(1999, 12, 1, 0, 0, 0, 0) should be 'object'"); +} + +if (new Date(1999, 12, 1, 0, 0, 0, 0) === undefined) { + $ERROR("#8.2: new Date(1999, 12, 1, 0, 0, 0, 0) should not be undefined"); +} + +var x83 = new Date(1999, 12, 1, 0, 0, 0, 0); +if (typeof x83 !== "object") { + $ERROR("#8.3: typeof new Date(1999, 12, 1, 0, 0, 0, 0) should be 'object'"); +} + +var x84 = new Date(1999, 12, 1, 0, 0, 0, 0); +if (x84 === undefined) { + $ERROR("#8.4: new Date(1999, 12, 1, 0, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(2000, 0, 1, 0, 0, 0, 0) !== "object") { + $ERROR("#9.1: typeof new Date(2000, 0, 1, 0, 0, 0, 0) should be 'object'"); +} + +if (new Date(2000, 0, 1, 0, 0, 0, 0) === undefined) { + $ERROR("#9.2: new Date(2000, 0, 1, 0, 0, 0, 0) should not be undefined"); +} + +var x93 = new Date(2000, 0, 1, 0, 0, 0, 0); +if (typeof x93 !== "object") { + $ERROR("#9.3: typeof new Date(2000, 0, 1, 0, 0, 0, 0) should be 'object'"); +} + +var x94 = new Date(2000, 0, 1, 0, 0, 0, 0); +if (x94 === undefined) { + $ERROR("#9.4: new Date(2000, 0, 1, 0, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(2099, 11, 31, 23, 59, 59, 999) !== "object") { + $ERROR("#10.1: typeof new Date(2099, 11, 31, 23, 59, 59, 999) should be 'object'"); +} + +if (new Date(2099, 11, 31, 23, 59, 59, 999) === undefined) { + $ERROR("#10.2: new Date(2099, 11, 31, 23, 59, 59, 999) should not be undefined"); +} + +var x103 = new Date(2099, 11, 31, 23, 59, 59, 999); +if (typeof x103 !== "object") { + $ERROR("#10.3: typeof new Date(2099, 11, 31, 23, 59, 59, 999) should be 'object'"); +} + +var x104 = new Date(2099, 11, 31, 23, 59, 59, 999); +if (x104 === undefined) { + $ERROR("#10.4: new Date(2099, 11, 31, 23, 59, 59, 999) should not be undefined"); +} + +if (typeof new Date(2099, 12, 1, 0, 0, 0, 0) !== "object") { + $ERROR("#11.1: typeof new Date(2099, 12, 1, 0, 0, 0, 0) should be 'object'"); +} + +if (new Date(2099, 12, 1, 0, 0, 0, 0) === undefined) { + $ERROR("#11.2: new Date(2099, 12, 1, 0, 0, 0, 0) should not be undefined"); +} + +var x113 = new Date(2099, 12, 1, 0, 0, 0, 0); +if (typeof x113 !== "object") { + $ERROR("#11.3: typeof new Date(2099, 12, 1, 0, 0, 0, 0) should be 'object'"); +} + +var x114 = new Date(2099, 12, 1, 0, 0, 0, 0); +if (x114 === undefined) { + $ERROR("#11.4: new Date(2099, 12, 1, 0, 0, 0, 0) should not be undefined"); +} + +if (typeof new Date(2100, 0, 1, 0, 0, 0, 0) !== "object") { + $ERROR("#12.1: typeof new Date(2100, 0, 1, 0, 0, 0, 0) should be 'object'"); +} + +if (new Date(2100, 0, 1, 0, 0, 0, 0) === undefined) { + $ERROR("#12.2: new Date(2100, 0, 1, 0, 0, 0, 0) should not be undefined"); +} + +var x123 = new Date(2100, 0, 1, 0, 0, 0, 0); +if (typeof x123 !== "object") { + $ERROR("#12.3: typeof new Date(2100, 0, 1, 0, 0, 0, 0) should be 'object'"); +} + +var x124 = new Date(2100, 0, 1, 0, 0, 0, 0); +if (x124 === undefined) { + $ERROR("#12.4: new Date(2100, 0, 1, 0, 0, 0, 0) should not be undefined"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T1.js new file mode 100644 index 0000000000..068f5f1cc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T1.js @@ -0,0 +1,193 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Date prototype object, the one that is the + initial value of Date.prototype +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 2 arguments, (year, month) +---*/ + +var x11 = new Date(1899, 11); +if (typeof x11.constructor.prototype !== "object") { + $ERROR("#1.1: typeof x11.constructor.prototype === 'object'"); +} + +var x12 = new Date(1899, 11); +if (!Date.prototype.isPrototypeOf(x12)) { + $ERROR('#1.2: Date.prototype.isPrototypeOf(x12)'); +} + +var x13 = new Date(1899, 11); +if (Date.prototype !== x13.constructor.prototype) { + $ERROR("#1.3: Date.prototype === x13.constructor.prototype"); +} + +var x21 = new Date(1899, 12); +if (typeof x21.constructor.prototype !== "object") { + $ERROR("#2.1: typeof x11.constructor.prototype === 'object'"); +} + +var x22 = new Date(1899, 12); +if (!Date.prototype.isPrototypeOf(x22)) { + $ERROR('#2.2: Date.prototype.isPrototypeOf(x22)'); +} + +var x23 = new Date(1899, 12); +if (Date.prototype !== x23.constructor.prototype) { + $ERROR("#2.3: Date.prototype === x23.constructor.prototype"); +} + +var x31 = new Date(1900, 0); +if (typeof x31.constructor.prototype !== "object") { + $ERROR("#3.1: typeof x31.constructor.prototype === 'object'"); +} + +var x32 = new Date(1900, 0); +if (!Date.prototype.isPrototypeOf(x32)) { + $ERROR('#3.2: Date.prototype.isPrototypeOf(x32)'); +} + +var x33 = new Date(1900, 0); +if (Date.prototype !== x33.constructor.prototype) { + $ERROR("#3.3: Date.prototype === x33.constructor.prototype"); +} + +var x41 = new Date(1969, 11); +if (typeof x41.constructor.prototype !== "object") { + $ERROR("#4.1: typeof x41.constructor.prototype === 'object'"); +} + +var x42 = new Date(1969, 11); +if (!Date.prototype.isPrototypeOf(x42)) { + $ERROR('#4.2: Date.prototype.isPrototypeOf(x42)'); +} + +var x43 = new Date(1969, 11); +if (Date.prototype !== x43.constructor.prototype) { + $ERROR("#4.3: Date.prototype === x43.constructor.prototype"); +} + +var x51 = new Date(1969, 12); +if (typeof x51.constructor.prototype !== "object") { + $ERROR("#5.1: typeof x51.constructor.prototype === 'object'"); +} + +var x52 = new Date(1969, 12); +if (!Date.prototype.isPrototypeOf(x52)) { + $ERROR('#5.2: Date.prototype.isPrototypeOf(x52)'); +} + +var x53 = new Date(1969, 12); +if (Date.prototype !== x53.constructor.prototype) { + $ERROR("#5.3: Date.prototype === x53.constructor.prototype"); +} + +var x61 = new Date(1970, 0); +if (typeof x61.constructor.prototype !== "object") { + $ERROR("#6.1: typeof x61.constructor.prototype === 'object'"); +} + +var x62 = new Date(1970, 0); +if (!Date.prototype.isPrototypeOf(x62)) { + $ERROR('#6.2: Date.prototype.isPrototypeOf(x62)'); +} + +var x63 = new Date(1970, 0); +if (Date.prototype !== x63.constructor.prototype) { + $ERROR("#6.3: Date.prototype === x63.constructor.prototype"); +} + +var x71 = new Date(1999, 11); +if (typeof x71.constructor.prototype !== "object") { + $ERROR("#7.1: typeof x71.constructor.prototype === 'object'"); +} + +var x72 = new Date(1999, 11); +if (!Date.prototype.isPrototypeOf(x72)) { + $ERROR('#7.2: Date.prototype.isPrototypeOf(x72)'); +} + +var x73 = new Date(1999, 11); +if (Date.prototype !== x73.constructor.prototype) { + $ERROR("#7.3: Date.prototype === x73.constructor.prototype"); +} + +var x81 = new Date(1999, 12); +if (typeof x81.constructor.prototype !== "object") { + $ERROR("#8.1: typeof x81.constructor.prototype === 'object'"); +} + +var x82 = new Date(1999, 12); +if (!Date.prototype.isPrototypeOf(x82)) { + $ERROR('#8.2: Date.prototype.isPrototypeOf(x82)'); +} + +var x83 = new Date(1999, 12); +if (Date.prototype !== x83.constructor.prototype) { + $ERROR("#8.3: Date.prototype === x83.constructor.prototype"); +} + +var x91 = new Date(2000, 0); +if (typeof x91.constructor.prototype !== "object") { + $ERROR("#9.1: typeof x91.constructor.prototype === 'object'"); +} + +var x92 = new Date(2000, 0); +if (!Date.prototype.isPrototypeOf(x92)) { + $ERROR('#9.2: Date.prototype.isPrototypeOf(x92)'); +} + +var x93 = new Date(2000, 0); +if (Date.prototype !== x93.constructor.prototype) { + $ERROR("#9.3: Date.prototype === x93.constructor.prototype"); +} + +var x101 = new Date(2099, 11); +if (typeof x101.constructor.prototype !== "object") { + $ERROR("#10.1: typeof x101.constructor.prototype === 'object'"); +} + +var x102 = new Date(2099, 11); +if (!Date.prototype.isPrototypeOf(x102)) { + $ERROR('#10.2: Date.prototype.isPrototypeOf(x102)'); +} + +var x103 = new Date(2099, 11); +if (Date.prototype !== x103.constructor.prototype) { + $ERROR("#10.3: Date.prototype === x103.constructor.prototype"); +} + +var x111 = new Date(2099, 12); +if (typeof x111.constructor.prototype !== "object") { + $ERROR("#11.1: typeof x111.constructor.prototype === 'object'"); +} + +var x112 = new Date(2099, 12); +if (!Date.prototype.isPrototypeOf(x112)) { + $ERROR('#11.2: Date.prototype.isPrototypeOf(x112)'); +} + +var x113 = new Date(2099, 12); +if (Date.prototype !== x113.constructor.prototype) { + $ERROR("#11.3: Date.prototype === x113.constructor.prototype"); +} + +var x121 = new Date(2100, 0); +if (typeof x121.constructor.prototype !== "object") { + $ERROR("#12.1: typeof x121.constructor.prototype === 'object'"); +} + +var x122 = new Date(2100, 0); +if (!Date.prototype.isPrototypeOf(x122)) { + $ERROR('#12.2: Date.prototype.isPrototypeOf(x122)'); +} + +var x123 = new Date(2100, 0); +if (Date.prototype !== x123.constructor.prototype) { + $ERROR("#12.3: Date.prototype === x123.constructor.prototype"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T2.js new file mode 100644 index 0000000000..364a49b4e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T2.js @@ -0,0 +1,193 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Date prototype object, the one that is the + initial value of Date.prototype +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 3 arguments, (year, month, date) +---*/ + +var x11 = new Date(1899, 11, 31); +if (typeof x11.constructor.prototype !== "object") { + $ERROR("#1.1: typeof x11.constructor.prototype === 'object'"); +} + +var x12 = new Date(1899, 11, 31); +if (!Date.prototype.isPrototypeOf(x12)) { + $ERROR('#1.2: Date.prototype.isPrototypeOf(x12)'); +} + +var x13 = new Date(1899, 11, 31); +if (Date.prototype !== x13.constructor.prototype) { + $ERROR("#1.3: Date.prototype === x13.constructor.prototype"); +} + +var x21 = new Date(1899, 12, 1); +if (typeof x21.constructor.prototype !== "object") { + $ERROR("#2.1: typeof x21.constructor.prototype === 'object'"); +} + +var x22 = new Date(1899, 12, 1); +if (!Date.prototype.isPrototypeOf(x22)) { + $ERROR('#2.2: Date.prototype.isPrototypeOf(x22)'); +} + +var x23 = new Date(1899, 12, 1); +if (Date.prototype !== x23.constructor.prototype) { + $ERROR("#2.3: Date.prototype === x23.constructor.prototype"); +} + +var x31 = new Date(1900, 0, 1); +if (typeof x31.constructor.prototype !== "object") { + $ERROR("#3.1: typeof x31.constructor.prototype === 'object'"); +} + +var x32 = new Date(1900, 0, 1); +if (!Date.prototype.isPrototypeOf(x32)) { + $ERROR('#3.2: Date.prototype.isPrototypeOf(x32)'); +} + +var x33 = new Date(1900, 0, 1); +if (Date.prototype !== x33.constructor.prototype) { + $ERROR("#3.3: Date.prototype === x33.constructor.prototype"); +} + +var x41 = new Date(1969, 11, 31); +if (typeof x41.constructor.prototype !== "object") { + $ERROR("#4.1: typeof x41.constructor.prototype === 'object'"); +} + +var x42 = new Date(1969, 11, 31); +if (!Date.prototype.isPrototypeOf(x42)) { + $ERROR('#4.2: Date.prototype.isPrototypeOf(x42)'); +} + +var x43 = new Date(1969, 11, 31); +if (Date.prototype !== x43.constructor.prototype) { + $ERROR("#4.3: Date.prototype === x43.constructor.prototype"); +} + +var x51 = new Date(1969, 12, 1); +if (typeof x51.constructor.prototype !== "object") { + $ERROR("#5.1: typeof x51.constructor.prototype === 'object'"); +} + +var x52 = new Date(1969, 12, 1); +if (!Date.prototype.isPrototypeOf(x52)) { + $ERROR('#5.2: Date.prototype.isPrototypeOf(x52)'); +} + +var x53 = new Date(1969, 12, 1); +if (Date.prototype !== x53.constructor.prototype) { + $ERROR("#5.3: Date.prototype === x53.constructor.prototype"); +} + +var x61 = new Date(1970, 0, 1); +if (typeof x61.constructor.prototype !== "object") { + $ERROR("#6.1: typeof x61.constructor.prototype === 'object'"); +} + +var x62 = new Date(1970, 0, 1); +if (!Date.prototype.isPrototypeOf(x62)) { + $ERROR('#6.2: Date.prototype.isPrototypeOf(x62)'); +} + +var x63 = new Date(1970, 0, 1); +if (Date.prototype !== x63.constructor.prototype) { + $ERROR("#6.3: Date.prototype === x63.constructor.prototype"); +} + +var x71 = new Date(1999, 11, 31); +if (typeof x71.constructor.prototype !== "object") { + $ERROR("#7.1: typeof x71.constructor.prototype === 'object'"); +} + +var x72 = new Date(1999, 11, 31); +if (!Date.prototype.isPrototypeOf(x72)) { + $ERROR('#7.2: Date.prototype.isPrototypeOf(x72)'); +} + +var x73 = new Date(1999, 11, 31); +if (Date.prototype !== x73.constructor.prototype) { + $ERROR("#7.3: Date.prototype === x73.constructor.prototype"); +} + +var x81 = new Date(1999, 12, 1); +if (typeof x81.constructor.prototype !== "object") { + $ERROR("#8.1: typeof x81.constructor.prototype === 'object'"); +} + +var x82 = new Date(1999, 12, 1); +if (!Date.prototype.isPrototypeOf(x82)) { + $ERROR('#8.2: Date.prototype.isPrototypeOf(x82)'); +} + +var x83 = new Date(1999, 12, 1); +if (Date.prototype !== x83.constructor.prototype) { + $ERROR("#8.3: Date.prototype === x83.constructor.prototype"); +} + +var x91 = new Date(2000, 0, 1); +if (typeof x91.constructor.prototype !== "object") { + $ERROR("#9.1: typeof x91.constructor.prototype === 'object'"); +} + +var x92 = new Date(2000, 0, 1); +if (!Date.prototype.isPrototypeOf(x92)) { + $ERROR('#9.2: Date.prototype.isPrototypeOf(x92)'); +} + +var x93 = new Date(2000, 0, 1); +if (Date.prototype !== x93.constructor.prototype) { + $ERROR("#9.3: Date.prototype === x93.constructor.prototype"); +} + +var x101 = new Date(2099, 11, 31); +if (typeof x101.constructor.prototype !== "object") { + $ERROR("#10.1: typeof x101.constructor.prototype === 'object'"); +} + +var x102 = new Date(2099, 11, 31); +if (!Date.prototype.isPrototypeOf(x102)) { + $ERROR('#10.2: Date.prototype.isPrototypeOf(x102)'); +} + +var x103 = new Date(2099, 11, 31); +if (Date.prototype !== x103.constructor.prototype) { + $ERROR("#10.3: Date.prototype === x103.constructor.prototype"); +} + +var x111 = new Date(2099, 12, 1); +if (typeof x111.constructor.prototype !== "object") { + $ERROR("#11.1: typeof x111.constructor.prototype === 'object'"); +} + +var x112 = new Date(2099, 12, 1); +if (!Date.prototype.isPrototypeOf(x112)) { + $ERROR('#11.2: Date.prototype.isPrototypeOf(x112)'); +} + +var x113 = new Date(2099, 12, 1); +if (Date.prototype !== x113.constructor.prototype) { + $ERROR("#11.3: Date.prototype === x113.constructor.prototype"); +} + +var x121 = new Date(2100, 0, 1); +if (typeof x121.constructor.prototype !== "object") { + $ERROR("#12.1: typeof x121.constructor.prototype === 'object'"); +} + +var x122 = new Date(2100, 0, 1); +if (!Date.prototype.isPrototypeOf(x122)) { + $ERROR('#12.2: Date.prototype.isPrototypeOf(x122)'); +} + +var x123 = new Date(2100, 0, 1); +if (Date.prototype !== x123.constructor.prototype) { + $ERROR("#12.3: Date.prototype === x123.constructor.prototype"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T3.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T3.js new file mode 100644 index 0000000000..b01c1ddfd1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T3.js @@ -0,0 +1,193 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Date prototype object, the one that is the + initial value of Date.prototype +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 4 arguments, (year, month, date, hours) +---*/ + +var x11 = new Date(1899, 11, 31, 23); +if (typeof x11.constructor.prototype !== "object") { + $ERROR("#1.1: typeof x11.constructor.prototype === 'object'"); +} + +var x12 = new Date(1899, 11, 31, 23); +if (!Date.prototype.isPrototypeOf(x12)) { + $ERROR('#1.2: Date.prototype.isPrototypeOf(x12)'); +} + +var x13 = new Date(1899, 11, 31, 23); +if (Date.prototype !== x13.constructor.prototype) { + $ERROR("#1.3: Date.prototype === x13.constructor.prototype"); +} + +var x21 = new Date(1899, 12, 1, 0); +if (typeof x21.constructor.prototype !== "object") { + $ERROR("#2.1: typeof x21.constructor.prototype === 'object'"); +} + +var x22 = new Date(1899, 12, 1, 0); +if (!Date.prototype.isPrototypeOf(x22)) { + $ERROR('#2.2: Date.prototype.isPrototypeOf(x22)'); +} + +var x23 = new Date(1899, 12, 1, 0); +if (Date.prototype !== x23.constructor.prototype) { + $ERROR("#2.3: Date.prototype === x23.constructor.prototype"); +} + +var x31 = new Date(1900, 0, 1, 0); +if (typeof x31.constructor.prototype !== "object") { + $ERROR("#3.1: typeof x31.constructor.prototype === 'object'"); +} + +var x32 = new Date(1900, 0, 1, 0); +if (!Date.prototype.isPrototypeOf(x32)) { + $ERROR('#3.2: Date.prototype.isPrototypeOf(x32)'); +} + +var x33 = new Date(1900, 0, 1, 0); +if (Date.prototype !== x33.constructor.prototype) { + $ERROR("#3.3: Date.prototype === x33.constructor.prototype"); +} + +var x41 = new Date(1969, 11, 31, 23); +if (typeof x41.constructor.prototype !== "object") { + $ERROR("#4.1: typeof x41.constructor.prototype === 'object'"); +} + +var x42 = new Date(1969, 11, 31, 23); +if (!Date.prototype.isPrototypeOf(x42)) { + $ERROR('#4.2: Date.prototype.isPrototypeOf(x42)'); +} + +var x43 = new Date(1969, 11, 31, 23); +if (Date.prototype !== x43.constructor.prototype) { + $ERROR("#4.3: Date.prototype === x43.constructor.prototype"); +} + +var x51 = new Date(1969, 12, 1, 0); +if (typeof x51.constructor.prototype !== "object") { + $ERROR("#5.1: typeof x51.constructor.prototype === 'object'"); +} + +var x52 = new Date(1969, 12, 1, 0); +if (!Date.prototype.isPrototypeOf(x52)) { + $ERROR('#5.2: Date.prototype.isPrototypeOf(x52)'); +} + +var x53 = new Date(1969, 12, 1, 0); +if (Date.prototype !== x53.constructor.prototype) { + $ERROR("#5.3: Date.prototype === x53.constructor.prototype"); +} + +var x61 = new Date(1970, 0, 1, 0); +if (typeof x61.constructor.prototype !== "object") { + $ERROR("#6.1: typeof x61.constructor.prototype === 'object'"); +} + +var x62 = new Date(1970, 0, 1, 0); +if (!Date.prototype.isPrototypeOf(x62)) { + $ERROR('#6.2: Date.prototype.isPrototypeOf(x62)'); +} + +var x63 = new Date(1970, 0, 1, 0); +if (Date.prototype !== x63.constructor.prototype) { + $ERROR("#6.3: Date.prototype === x63.constructor.prototype"); +} + +var x71 = new Date(1999, 11, 31, 23); +if (typeof x71.constructor.prototype !== "object") { + $ERROR("#7.1: typeof x71.constructor.prototype === 'object'"); +} + +var x72 = new Date(1999, 11, 31, 23); +if (!Date.prototype.isPrototypeOf(x72)) { + $ERROR('#7.2: Date.prototype.isPrototypeOf(x72)'); +} + +var x73 = new Date(1999, 11, 31, 23); +if (Date.prototype !== x73.constructor.prototype) { + $ERROR("#7.3: Date.prototype === x73.constructor.prototype"); +} + +var x81 = new Date(1999, 12, 1, 0); +if (typeof x81.constructor.prototype !== "object") { + $ERROR("#8.1: typeof x81.constructor.prototype === 'object'"); +} + +var x82 = new Date(1999, 12, 1, 0); +if (!Date.prototype.isPrototypeOf(x82)) { + $ERROR('#8.2: Date.prototype.isPrototypeOf(x82)'); +} + +var x83 = new Date(1999, 12, 1, 0); +if (Date.prototype !== x83.constructor.prototype) { + $ERROR("#8.3: Date.prototype === x83.constructor.prototype"); +} + +var x91 = new Date(2000, 0, 1, 0); +if (typeof x91.constructor.prototype !== "object") { + $ERROR("#9.1: typeof x91.constructor.prototype === 'object'"); +} + +var x92 = new Date(2000, 0, 1, 0); +if (!Date.prototype.isPrototypeOf(x92)) { + $ERROR('#9.2: Date.prototype.isPrototypeOf(x92)'); +} + +var x93 = new Date(2000, 0, 1, 0); +if (Date.prototype !== x93.constructor.prototype) { + $ERROR("#9.3: Date.prototype === x93.constructor.prototype"); +} + +var x101 = new Date(2099, 11, 31, 23); +if (typeof x101.constructor.prototype !== "object") { + $ERROR("#10.1: typeof x101.constructor.prototype === 'object'"); +} + +var x102 = new Date(2099, 11, 31, 23); +if (!Date.prototype.isPrototypeOf(x102)) { + $ERROR('#10.2: Date.prototype.isPrototypeOf(x102)'); +} + +var x103 = new Date(2099, 11, 31, 23); +if (Date.prototype !== x103.constructor.prototype) { + $ERROR("#10.3: Date.prototype === x103.constructor.prototype"); +} + +var x111 = new Date(2099, 12, 1, 0); +if (typeof x111.constructor.prototype !== "object") { + $ERROR("#11.1: typeof x111.constructor.prototype === 'object'"); +} + +var x112 = new Date(2099, 12, 1, 0); +if (!Date.prototype.isPrototypeOf(x112)) { + $ERROR('#11.2: Date.prototype.isPrototypeOf(x112)'); +} + +var x113 = new Date(2099, 12, 1, 0); +if (Date.prototype !== x113.constructor.prototype) { + $ERROR("#11.3: Date.prototype === x113.constructor.prototype"); +} + +var x121 = new Date(2100, 0, 1, 0); +if (typeof x121.constructor.prototype !== "object") { + $ERROR("#12.1: typeof x121.constructor.prototype === 'object'"); +} + +var x122 = new Date(2100, 0, 1, 0); +if (!Date.prototype.isPrototypeOf(x122)) { + $ERROR('#12.2: Date.prototype.isPrototypeOf(x122)'); +} + +var x123 = new Date(2100, 0, 1, 0); +if (Date.prototype !== x123.constructor.prototype) { + $ERROR("#12.3: Date.prototype === x123.constructor.prototype"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T4.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T4.js new file mode 100644 index 0000000000..660d739fb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T4.js @@ -0,0 +1,193 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Date prototype object, the one that is the + initial value of Date.prototype +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 5 arguments, (year, month, date, hours, minutes) +---*/ + +var x11 = new Date(1899, 11, 31, 23, 59); +if (typeof x11.constructor.prototype !== "object") { + $ERROR("#1.1: typeof x11.constructor.prototype === 'object'"); +} + +var x12 = new Date(1899, 11, 31, 23, 59); +if (!Date.prototype.isPrototypeOf(x12)) { + $ERROR('#1.2: Date.prototype.isPrototypeOf(x12)'); +} + +var x13 = new Date(1899, 11, 31, 23, 59); +if (Date.prototype !== x13.constructor.prototype) { + $ERROR("#1.3: Date.prototype === x13.constructor.prototype"); +} + +var x21 = new Date(1899, 12, 1, 0, 0); +if (typeof x21.constructor.prototype !== "object") { + $ERROR("#2.1: typeof x21.constructor.prototype === 'object'"); +} + +var x22 = new Date(1899, 12, 1, 0, 0); +if (!Date.prototype.isPrototypeOf(x22)) { + $ERROR('#2.2: Date.prototype.isPrototypeOf(x22)'); +} + +var x23 = new Date(1899, 12, 1, 0, 0); +if (Date.prototype !== x23.constructor.prototype) { + $ERROR("#2.3: Date.prototype === x23.constructor.prototype"); +} + +var x31 = new Date(1900, 0, 1, 0, 0); +if (typeof x31.constructor.prototype !== "object") { + $ERROR("#3.1: typeof x31.constructor.prototype === 'object'"); +} + +var x32 = new Date(1900, 0, 1, 0, 0); +if (!Date.prototype.isPrototypeOf(x32)) { + $ERROR('#3.2: Date.prototype.isPrototypeOf(x32)'); +} + +var x33 = new Date(1900, 0, 1, 0, 0); +if (Date.prototype !== x33.constructor.prototype) { + $ERROR("#3.3: Date.prototype === x33.constructor.prototype"); +} + +var x41 = new Date(1969, 11, 31, 23, 59); +if (typeof x41.constructor.prototype !== "object") { + $ERROR("#4.1: typeof x41.constructor.prototype === 'object'"); +} + +var x42 = new Date(1969, 11, 31, 23, 59); +if (!Date.prototype.isPrototypeOf(x42)) { + $ERROR('#4.2: Date.prototype.isPrototypeOf(x42)'); +} + +var x43 = new Date(1969, 11, 31, 23, 59); +if (Date.prototype !== x43.constructor.prototype) { + $ERROR("#4.3: Date.prototype === x43.constructor.prototype"); +} + +var x51 = new Date(1969, 12, 1, 0, 0); +if (typeof x51.constructor.prototype !== "object") { + $ERROR("#5.1: typeof x51.constructor.prototype === 'object'"); +} + +var x52 = new Date(1969, 12, 1, 0, 0); +if (!Date.prototype.isPrototypeOf(x52)) { + $ERROR('#5.2: Date.prototype.isPrototypeOf(x52)'); +} + +var x53 = new Date(1969, 12, 1, 0, 0); +if (Date.prototype !== x53.constructor.prototype) { + $ERROR("#5.3: Date.prototype === x53.constructor.prototype"); +} + +var x61 = new Date(1970, 0, 1, 0, 0); +if (typeof x61.constructor.prototype !== "object") { + $ERROR("#6.1: typeof x61.constructor.prototype === 'object'"); +} + +var x62 = new Date(1970, 0, 1, 0, 0); +if (!Date.prototype.isPrototypeOf(x62)) { + $ERROR('#6.2: Date.prototype.isPrototypeOf(x62)'); +} + +var x63 = new Date(1970, 0, 1, 0, 0); +if (Date.prototype !== x63.constructor.prototype) { + $ERROR("#6.3: Date.prototype === x63.constructor.prototype"); +} + +var x71 = new Date(1999, 11, 31, 23, 59); +if (typeof x71.constructor.prototype !== "object") { + $ERROR("#7.1: typeof x71.constructor.prototype === 'object'"); +} + +var x72 = new Date(1999, 11, 31, 23, 59); +if (!Date.prototype.isPrototypeOf(x72)) { + $ERROR('#7.2: Date.prototype.isPrototypeOf(x72)'); +} + +var x73 = new Date(1999, 11, 31, 23, 59); +if (Date.prototype !== x73.constructor.prototype) { + $ERROR("#7.3: Date.prototype === x73.constructor.prototype"); +} + +var x81 = new Date(1999, 12, 1, 0, 0); +if (typeof x81.constructor.prototype !== "object") { + $ERROR("#8.1: typeof x81.constructor.prototype === 'object'"); +} + +var x82 = new Date(1999, 12, 1, 0, 0); +if (!Date.prototype.isPrototypeOf(x82)) { + $ERROR('#8.2: Date.prototype.isPrototypeOf(x82)'); +} + +var x83 = new Date(1999, 12, 1, 0, 0); +if (Date.prototype !== x83.constructor.prototype) { + $ERROR("#8.3: Date.prototype === x83.constructor.prototype"); +} + +var x91 = new Date(2000, 0, 1, 0, 0); +if (typeof x91.constructor.prototype !== "object") { + $ERROR("#9.1: typeof x91.constructor.prototype === 'object'"); +} + +var x92 = new Date(2000, 0, 1, 0, 0); +if (!Date.prototype.isPrototypeOf(x92)) { + $ERROR('#9.2: Date.prototype.isPrototypeOf(x92)'); +} + +var x93 = new Date(2000, 0, 1, 0, 0); +if (Date.prototype !== x93.constructor.prototype) { + $ERROR("#9.3: Date.prototype === x93.constructor.prototype"); +} + +var x101 = new Date(2099, 11, 31, 23, 59); +if (typeof x101.constructor.prototype !== "object") { + $ERROR("#10.1: typeof x101.constructor.prototype === 'object'"); +} + +var x102 = new Date(2099, 11, 31, 23, 59); +if (!Date.prototype.isPrototypeOf(x102)) { + $ERROR('#10.2: Date.prototype.isPrototypeOf(x102)'); +} + +var x103 = new Date(2099, 11, 31, 23, 59); +if (Date.prototype !== x103.constructor.prototype) { + $ERROR("#10.3: Date.prototype === x103.constructor.prototype"); +} + +var x111 = new Date(2099, 12, 1, 0, 0); +if (typeof x111.constructor.prototype !== "object") { + $ERROR("#11.1: typeof x111.constructor.prototype === 'object'"); +} + +var x112 = new Date(2099, 12, 1, 0, 0); +if (!Date.prototype.isPrototypeOf(x112)) { + $ERROR('#11.2: Date.prototype.isPrototypeOf(x112)'); +} + +var x113 = new Date(2099, 12, 1, 0, 0); +if (Date.prototype !== x113.constructor.prototype) { + $ERROR("#11.3: Date.prototype === x113.constructor.prototype"); +} + +var x121 = new Date(2100, 0, 1, 0, 0); +if (typeof x121.constructor.prototype !== "object") { + $ERROR("#12.1: typeof x121.constructor.prototype === 'object'"); +} + +var x122 = new Date(2100, 0, 1, 0, 0); +if (!Date.prototype.isPrototypeOf(x122)) { + $ERROR('#12.2: Date.prototype.isPrototypeOf(x122)'); +} + +var x123 = new Date(2100, 0, 1, 0, 0); +if (Date.prototype !== x123.constructor.prototype) { + $ERROR("#12.3: Date.prototype === x123.constructor.prototype"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T5.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T5.js new file mode 100644 index 0000000000..d5165185ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T5.js @@ -0,0 +1,193 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Date prototype object, the one that is the + initial value of Date.prototype +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 6 arguments, (year, month, date, hours, minutes, seconds) +---*/ + +var x11 = new Date(1899, 11, 31, 23, 59, 59); +if (typeof x11.constructor.prototype !== "object") { + $ERROR("#1.1: typeof x11.constructor.prototype === 'object'"); +} + +var x12 = new Date(1899, 11, 31, 23, 59, 59); +if (!Date.prototype.isPrototypeOf(x12)) { + $ERROR('#1.2: Date.prototype.isPrototypeOf(x12)'); +} + +var x13 = new Date(1899, 11, 31, 23, 59, 59); +if (Date.prototype !== x13.constructor.prototype) { + $ERROR("#1.3: Date.prototype === x13.constructor.prototype"); +} + +var x21 = new Date(1899, 12, 1, 0, 0, 0); +if (typeof x21.constructor.prototype !== "object") { + $ERROR("#2.1: typeof x21.constructor.prototype === 'object'"); +} + +var x22 = new Date(1899, 12, 1, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x22)) { + $ERROR('#2.2: Date.prototype.isPrototypeOf(x22)'); +} + +var x23 = new Date(1899, 12, 1, 0, 0, 0); +if (Date.prototype !== x23.constructor.prototype) { + $ERROR("#2.3: Date.prototype === x23.constructor.prototype"); +} + +var x31 = new Date(1900, 0, 1, 0, 0, 0); +if (typeof x31.constructor.prototype !== "object") { + $ERROR("#3.1: typeof x31.constructor.prototype === 'object'"); +} + +var x32 = new Date(1900, 0, 1, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x32)) { + $ERROR('#3.2: Date.prototype.isPrototypeOf(x32)'); +} + +var x33 = new Date(1900, 0, 1, 0, 0, 0); +if (Date.prototype !== x33.constructor.prototype) { + $ERROR("#3.3: Date.prototype === x33.constructor.prototype"); +} + +var x41 = new Date(1969, 11, 31, 23, 59, 59); +if (typeof x41.constructor.prototype !== "object") { + $ERROR("#4.1: typeof x41.constructor.prototype === 'object'"); +} + +var x42 = new Date(1969, 11, 31, 23, 59, 59); +if (!Date.prototype.isPrototypeOf(x42)) { + $ERROR('#4.2: Date.prototype.isPrototypeOf(x42)'); +} + +var x43 = new Date(1969, 11, 31, 23, 59, 59); +if (Date.prototype !== x43.constructor.prototype) { + $ERROR("#4.3: Date.prototype === x43.constructor.prototype"); +} + +var x51 = new Date(1969, 12, 1, 0, 0, 0); +if (typeof x51.constructor.prototype !== "object") { + $ERROR("#5.1: typeof x51.constructor.prototype === 'object'"); +} + +var x52 = new Date(1969, 12, 1, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x52)) { + $ERROR('#5.2: Date.prototype.isPrototypeOf(x52)'); +} + +var x53 = new Date(1969, 12, 1, 0, 0, 0); +if (Date.prototype !== x53.constructor.prototype) { + $ERROR("#5.3: Date.prototype === x53.constructor.prototype"); +} + +var x61 = new Date(1970, 0, 1, 0, 0, 0); +if (typeof x61.constructor.prototype !== "object") { + $ERROR("#6.1: typeof x61.constructor.prototype === 'object'"); +} + +var x62 = new Date(1970, 0, 1, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x62)) { + $ERROR('#6.2: Date.prototype.isPrototypeOf(x62)'); +} + +var x63 = new Date(1970, 0, 1, 0, 0, 0); +if (Date.prototype !== x63.constructor.prototype) { + $ERROR("#6.3: Date.prototype === x63.constructor.prototype"); +} + +var x71 = new Date(1999, 11, 31, 23, 59, 59); +if (typeof x71.constructor.prototype !== "object") { + $ERROR("#7.1: typeof x71.constructor.prototype === 'object'"); +} + +var x72 = new Date(1999, 11, 31, 23, 59, 59); +if (!Date.prototype.isPrototypeOf(x72)) { + $ERROR('#7.2: Date.prototype.isPrototypeOf(x72)'); +} + +var x73 = new Date(1999, 11, 31, 23, 59, 59); +if (Date.prototype !== x73.constructor.prototype) { + $ERROR("#7.3: Date.prototype === x73.constructor.prototype"); +} + +var x81 = new Date(1999, 12, 1, 0, 0, 0); +if (typeof x81.constructor.prototype !== "object") { + $ERROR("#8.1: typeof x81.constructor.prototype === 'object'"); +} + +var x82 = new Date(1999, 12, 1, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x82)) { + $ERROR('#8.2: Date.prototype.isPrototypeOf(x82)'); +} + +var x83 = new Date(1999, 12, 1, 0, 0, 0); +if (Date.prototype !== x83.constructor.prototype) { + $ERROR("#8.3: Date.prototype === x83.constructor.prototype"); +} + +var x91 = new Date(2000, 0, 1, 0, 0, 0); +if (typeof x91.constructor.prototype !== "object") { + $ERROR("#9.1: typeof x91.constructor.prototype === 'object'"); +} + +var x92 = new Date(2000, 0, 1, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x92)) { + $ERROR('#9.2: Date.prototype.isPrototypeOf(x92)'); +} + +var x93 = new Date(2000, 0, 1, 0, 0, 0); +if (Date.prototype !== x93.constructor.prototype) { + $ERROR("#9.3: Date.prototype === x93.constructor.prototype"); +} + +var x101 = new Date(2099, 11, 31, 23, 59, 59); +if (typeof x101.constructor.prototype !== "object") { + $ERROR("#10.1: typeof x101.constructor.prototype === 'object'"); +} + +var x102 = new Date(2099, 11, 31, 23, 59, 59); +if (!Date.prototype.isPrototypeOf(x102)) { + $ERROR('#10.2: Date.prototype.isPrototypeOf(x102)'); +} + +var x103 = new Date(2099, 11, 31, 23, 59, 59); +if (Date.prototype !== x103.constructor.prototype) { + $ERROR("#10.3: Date.prototype === x103.constructor.prototype"); +} + +var x111 = new Date(2099, 12, 1, 0, 0, 0); +if (typeof x111.constructor.prototype !== "object") { + $ERROR("#11.1: typeof x111.constructor.prototype === 'object'"); +} + +var x112 = new Date(2099, 12, 1, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x112)) { + $ERROR('#11.2: Date.prototype.isPrototypeOf(x112)'); +} + +var x113 = new Date(2099, 12, 1, 0, 0, 0); +if (Date.prototype !== x113.constructor.prototype) { + $ERROR("#11.3: Date.prototype === x113.constructor.prototype"); +} + +var x121 = new Date(2100, 0, 1, 0, 0, 0); +if (typeof x121.constructor.prototype !== "object") { + $ERROR("#12.1: typeof x121.constructor.prototype === 'object'"); +} + +var x122 = new Date(2100, 0, 1, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x122)) { + $ERROR('#12.2: Date.prototype.isPrototypeOf(x122)'); +} + +var x123 = new Date(2100, 0, 1, 0, 0, 0); +if (Date.prototype !== x123.constructor.prototype) { + $ERROR("#12.3: Date.prototype === x123.constructor.prototype"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T6.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T6.js new file mode 100644 index 0000000000..cd551eba55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A2_T6.js @@ -0,0 +1,193 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Date prototype object, the one that is the + initial value of Date.prototype +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 7 arguments, (year, month, date, hours, minutes, seconds, ms) +---*/ + +var x11 = new Date(1899, 11, 31, 23, 59, 59, 999); +if (typeof x11.constructor.prototype !== "object") { + $ERROR("#1.1: typeof x11.constructor.prototype === 'object'"); +} + +var x12 = new Date(1899, 11, 31, 23, 59, 59, 999); +if (!Date.prototype.isPrototypeOf(x12)) { + $ERROR('#1.2: Date.prototype.isPrototypeOf(x12)'); +} + +var x13 = new Date(1899, 11, 31, 23, 59, 59, 999); +if (Date.prototype !== x13.constructor.prototype) { + $ERROR("#1.3: Date.prototype === x13.constructor.prototype"); +} + +var x21 = new Date(1899, 12, 1, 0, 0, 0, 0); +if (typeof x21.constructor.prototype !== "object") { + $ERROR("#2.1: typeof x21.constructor.prototype === 'object'"); +} + +var x22 = new Date(1899, 12, 1, 0, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x22)) { + $ERROR('#2.2: Date.prototype.isPrototypeOf(x22)'); +} + +var x23 = new Date(1899, 12, 1, 0, 0, 0, 0); +if (Date.prototype !== x23.constructor.prototype) { + $ERROR("#2.3: Date.prototype === x23.constructor.prototype"); +} + +var x31 = new Date(1900, 0, 1, 0, 0, 0, 0); +if (typeof x31.constructor.prototype !== "object") { + $ERROR("#3.1: typeof x31.constructor.prototype === 'object'"); +} + +var x32 = new Date(1900, 0, 1, 0, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x32)) { + $ERROR('#3.2: Date.prototype.isPrototypeOf(x32)'); +} + +var x33 = new Date(1900, 0, 1, 0, 0, 0, 0); +if (Date.prototype !== x33.constructor.prototype) { + $ERROR("#3.3: Date.prototype === x33.constructor.prototype"); +} + +var x41 = new Date(1969, 11, 31, 23, 59, 59, 999); +if (typeof x41.constructor.prototype !== "object") { + $ERROR("#4.1: typeof x41.constructor.prototype === 'object'"); +} + +var x42 = new Date(1969, 11, 31, 23, 59, 59, 999); +if (!Date.prototype.isPrototypeOf(x42)) { + $ERROR('#4.2: Date.prototype.isPrototypeOf(x42)'); +} + +var x43 = new Date(1969, 11, 31, 23, 59, 59, 999); +if (Date.prototype !== x43.constructor.prototype) { + $ERROR("#4.3: Date.prototype === x43.constructor.prototype"); +} + +var x51 = new Date(1969, 12, 1, 0, 0, 0, 0); +if (typeof x51.constructor.prototype !== "object") { + $ERROR("#5.1: typeof x51.constructor.prototype === 'object'"); +} + +var x52 = new Date(1969, 12, 1, 0, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x52)) { + $ERROR('#5.2: Date.prototype.isPrototypeOf(x52)'); +} + +var x53 = new Date(1969, 12, 1, 0, 0, 0, 0); +if (Date.prototype !== x53.constructor.prototype) { + $ERROR("#5.3: Date.prototype === x53.constructor.prototype"); +} + +var x61 = new Date(1970, 0, 1, 0, 0, 0, 0); +if (typeof x61.constructor.prototype !== "object") { + $ERROR("#6.1: typeof x61.constructor.prototype === 'object'"); +} + +var x62 = new Date(1970, 0, 1, 0, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x62)) { + $ERROR('#6.2: Date.prototype.isPrototypeOf(x62)'); +} + +var x63 = new Date(1970, 0, 1, 0, 0, 0, 0); +if (Date.prototype !== x63.constructor.prototype) { + $ERROR("#6.3: Date.prototype === x63.constructor.prototype"); +} + +var x71 = new Date(1999, 11, 31, 23, 59, 59, 999); +if (typeof x71.constructor.prototype !== "object") { + $ERROR("#7.1: typeof x71.constructor.prototype === 'object'"); +} + +var x72 = new Date(1999, 11, 31, 23, 59, 59, 999); +if (!Date.prototype.isPrototypeOf(x72)) { + $ERROR('#7.2: Date.prototype.isPrototypeOf(x72)'); +} + +var x73 = new Date(1999, 11, 31, 23, 59, 59, 999); +if (Date.prototype !== x73.constructor.prototype) { + $ERROR("#7.3: Date.prototype === x73.constructor.prototype"); +} + +var x81 = new Date(1999, 12, 1, 0, 0, 0, 0); +if (typeof x81.constructor.prototype !== "object") { + $ERROR("#8.1: typeof x81.constructor.prototype === 'object'"); +} + +var x82 = new Date(1999, 12, 1, 0, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x82)) { + $ERROR('#8.2: Date.prototype.isPrototypeOf(x82)'); +} + +var x83 = new Date(1999, 12, 1, 0, 0, 0, 0); +if (Date.prototype !== x83.constructor.prototype) { + $ERROR("#8.3: Date.prototype === x83.constructor.prototype"); +} + +var x91 = new Date(2000, 0, 1, 0, 0, 0, 0); +if (typeof x91.constructor.prototype !== "object") { + $ERROR("#9.1: typeof x91.constructor.prototype === 'object'"); +} + +var x92 = new Date(2000, 0, 1, 0, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x92)) { + $ERROR('#9.2: Date.prototype.isPrototypeOf(x92)'); +} + +var x93 = new Date(2000, 0, 1, 0, 0, 0, 0); +if (Date.prototype !== x93.constructor.prototype) { + $ERROR("#9.3: Date.prototype === x93.constructor.prototype"); +} + +var x101 = new Date(2099, 11, 31, 23, 59, 59, 999); +if (typeof x101.constructor.prototype !== "object") { + $ERROR("#10.1: typeof x101.constructor.prototype === 'object'"); +} + +var x102 = new Date(2099, 11, 31, 23, 59, 59, 999); +if (!Date.prototype.isPrototypeOf(x102)) { + $ERROR('#10.2: Date.prototype.isPrototypeOf(x102)'); +} + +var x103 = new Date(2099, 11, 31, 23, 59, 59, 999); +if (Date.prototype !== x103.constructor.prototype) { + $ERROR("#10.3: Date.prototype === x103.constructor.prototype"); +} + +var x111 = new Date(2099, 12, 1, 0, 0, 0, 0); +if (typeof x111.constructor.prototype !== "object") { + $ERROR("#11.1: typeof x111.constructor.prototype === 'object'"); +} + +var x112 = new Date(2099, 12, 1, 0, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x112)) { + $ERROR('#11.2: Date.prototype.isPrototypeOf(x112)'); +} + +var x113 = new Date(2099, 12, 1, 0, 0, 0, 0); +if (Date.prototype !== x113.constructor.prototype) { + $ERROR("#11.3: Date.prototype === x113.constructor.prototype"); +} + +var x121 = new Date(2100, 0, 1, 0, 0, 0, 0); +if (typeof x121.constructor.prototype !== "object") { + $ERROR("#12.1: typeof x121.constructor.prototype === 'object'"); +} + +var x122 = new Date(2100, 0, 1, 0, 0, 0, 0); +if (!Date.prototype.isPrototypeOf(x122)) { + $ERROR('#12.2: Date.prototype.isPrototypeOf(x122)'); +} + +var x123 = new Date(2100, 0, 1, 0, 0, 0, 0); +if (Date.prototype !== x123.constructor.prototype) { + $ERROR("#12.3: Date.prototype === x123.constructor.prototype"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T1.1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T1.1.js new file mode 100644 index 0000000000..9a8c7f0ad3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T1.1.js @@ -0,0 +1,74 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: > + Test based on delete prototype.toString - 2 arguments, (year, + month) +---*/ + +var x1 = new Date(1899, 11); +if (Object.prototype.toString.call(x1) !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12); +if (Object.prototype.toString.call(x2) !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0); +if (Object.prototype.toString.call(x3) !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11); +if (Object.prototype.toString.call(x4) !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12); +if (Object.prototype.toString.call(x5) !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0); +if (Object.prototype.toString.call(x6) !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11); +if (Object.prototype.toString.call(x7) !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12); +if (Object.prototype.toString.call(x8) !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0); +if (Object.prototype.toString.call(x9) !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11); +if (Object.prototype.toString.call(x10) !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12); +if (Object.prototype.toString.call(x11) !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0); +if (Object.prototype.toString.call(x12) !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T1.2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T1.2.js new file mode 100644 index 0000000000..52a5802410 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T1.2.js @@ -0,0 +1,76 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: > + Test based on overwriting prototype.toString - 2 arguments, (year, + month) +---*/ + +Date.prototype.toString = Object.prototype.toString; + +var x1 = new Date(1899, 11); +if (x1.toString() !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12); +if (x2.toString() !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0); +if (x3.toString() !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11); +if (x4.toString() !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12); +if (x5.toString() !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0); +if (x6.toString() !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11); +if (x7.toString() !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12); +if (x8.toString() !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0); +if (x9.toString() !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11); +if (x10.toString() !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12); +if (x11.toString() !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0); +if (x12.toString() !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T2.1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T2.1.js new file mode 100644 index 0000000000..8928638c25 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T2.1.js @@ -0,0 +1,74 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: > + Test based on delete prototype.toString - 3 arguments, (year, + month, date) +---*/ + +var x1 = new Date(1899, 11, 31); +if (Object.prototype.toString.call(x1) !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12, 1); +if (Object.prototype.toString.call(x2) !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0, 1); +if (Object.prototype.toString.call(x3) !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11, 31); +if (Object.prototype.toString.call(x4) !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12, 1); +if (Object.prototype.toString.call(x5) !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0, 1); +if (Object.prototype.toString.call(x6) !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11, 31); +if (Object.prototype.toString.call(x7) !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12, 1); +if (Object.prototype.toString.call(x8) !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0, 1); +if (Object.prototype.toString.call(x9) !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11, 31); +if (Object.prototype.toString.call(x10) !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12, 1); +if (Object.prototype.toString.call(x11) !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0, 1); +if (Object.prototype.toString.call(x12) !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T2.2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T2.2.js new file mode 100644 index 0000000000..9a40dcb260 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T2.2.js @@ -0,0 +1,76 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: > + Test based on overwriting prototype.toString - 3 arguments, (year, + month, date) +---*/ + +Date.prototype.toString = Object.prototype.toString; + +var x1 = new Date(1899, 11, 31); +if (x1.toString() !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12, 1); +if (x2.toString() !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0, 1); +if (x3.toString() !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11, 31); +if (x4.toString() !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12, 1); +if (x5.toString() !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0, 1); +if (x6.toString() !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11, 31); +if (x7.toString() !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12, 1); +if (x8.toString() !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0, 1); +if (x9.toString() !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11, 31); +if (x10.toString() !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12, 1); +if (x11.toString() !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0, 1); +if (x12.toString() !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T3.1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T3.1.js new file mode 100644 index 0000000000..6948a0cc5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T3.1.js @@ -0,0 +1,74 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: > + Test based on delete prototype.toString - 4 arguments, (year, + month, date, hours) +---*/ + +var x1 = new Date(1899, 11, 31, 23); +if (Object.prototype.toString.call(x1) !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12, 1, 0); +if (Object.prototype.toString.call(x2) !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0, 1, 0); +if (Object.prototype.toString.call(x3) !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11, 31, 23); +if (Object.prototype.toString.call(x4) !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12, 1, 0); +if (Object.prototype.toString.call(x5) !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0, 1, 0); +if (Object.prototype.toString.call(x6) !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11, 31, 23); +if (Object.prototype.toString.call(x7) !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12, 1, 0); +if (Object.prototype.toString.call(x8) !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0, 1, 0); +if (Object.prototype.toString.call(x9) !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11, 31, 23); +if (Object.prototype.toString.call(x10) !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12, 1, 0); +if (Object.prototype.toString.call(x11) !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0, 1, 0); +if (Object.prototype.toString.call(x12) !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T3.2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T3.2.js new file mode 100644 index 0000000000..a8c7b40edc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T3.2.js @@ -0,0 +1,76 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: > + Test based on overwriting prototype.toString - 4 arguments, (year, + month, date, hours) +---*/ + +Date.prototype.toString = Object.prototype.toString; + +var x1 = new Date(1899, 11, 31, 23); +if (x1.toString() !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12, 1, 0); +if (x2.toString() !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0, 1, 0); +if (x3.toString() !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11, 31, 23); +if (x4.toString() !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12, 1, 0); +if (x5.toString() !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0, 1, 0); +if (x6.toString() !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11, 31, 23); +if (x7.toString() !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12, 1, 0); +if (x8.toString() !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0, 1, 0); +if (x9.toString() !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11, 31, 23); +if (x10.toString() !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12, 1, 0); +if (x11.toString() !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0, 1, 0); +if (x12.toString() !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T4.1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T4.1.js new file mode 100644 index 0000000000..8c95552d19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T4.1.js @@ -0,0 +1,74 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: > + Test based on delete prototype.toString - 5 arguments, (year, + month, date, hours, minutes) +---*/ + +var x1 = new Date(1899, 11, 31, 23, 59); +if (Object.prototype.toString.call(x1) !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12, 1, 0, 0); +if (Object.prototype.toString.call(x2) !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0, 1, 0, 0); +if (Object.prototype.toString.call(x3) !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11, 31, 23, 59); +if (Object.prototype.toString.call(x4) !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12, 1, 0, 0); +if (Object.prototype.toString.call(x5) !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0, 1, 0, 0); +if (Object.prototype.toString.call(x6) !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11, 31, 23, 59); +if (Object.prototype.toString.call(x7) !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12, 1, 0, 0); +if (Object.prototype.toString.call(x8) !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0, 1, 0, 0); +if (Object.prototype.toString.call(x9) !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11, 31, 23, 59); +if (Object.prototype.toString.call(x10) !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12, 1, 0, 0); +if (Object.prototype.toString.call(x11) !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0, 1, 0, 0); +if (Object.prototype.toString.call(x12) !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T4.2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T4.2.js new file mode 100644 index 0000000000..7bd3750ff8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T4.2.js @@ -0,0 +1,76 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: > + Test based on overwriting prototype.toString - 5 arguments, (year, + month, date, hours, minutes) +---*/ + +Date.prototype.toString = Object.prototype.toString; + +var x1 = new Date(1899, 11, 31, 23, 59); +if (x1.toString() !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12, 1, 0, 0); +if (x2.toString() !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0, 1, 0, 0); +if (x3.toString() !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11, 31, 23, 59); +if (x4.toString() !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12, 1, 0, 0); +if (x5.toString() !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0, 1, 0, 0); +if (x6.toString() !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11, 31, 23, 59); +if (x7.toString() !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12, 1, 0, 0); +if (x8.toString() !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0, 1, 0, 0); +if (x9.toString() !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11, 31, 23, 59); +if (x10.toString() !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12, 1, 0, 0); +if (x11.toString() !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0, 1, 0, 0); +if (x12.toString() !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T5.1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T5.1.js new file mode 100644 index 0000000000..712c288693 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T5.1.js @@ -0,0 +1,72 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 6 arguments, (year, month, date, hours, minutes, seconds) +---*/ + +var x1 = new Date(1899, 11, 31, 23, 59, 59); +if (Object.prototype.toString.call(x1) !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12, 1, 0, 0, 0); +if (Object.prototype.toString.call(x2) !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0, 1, 0, 0, 0); +if (Object.prototype.toString.call(x3) !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11, 31, 23, 59, 59); +if (Object.prototype.toString.call(x4) !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12, 1, 0, 0, 0); +if (Object.prototype.toString.call(x5) !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0, 1, 0, 0, 0); +if (Object.prototype.toString.call(x6) !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11, 31, 23, 59, 59); +if (Object.prototype.toString.call(x7) !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12, 1, 0, 0, 0); +if (Object.prototype.toString.call(x8) !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0, 1, 0, 0, 0); +if (Object.prototype.toString.call(x9) !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11, 31, 23, 59, 59); +if (Object.prototype.toString.call(x10) !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12, 1, 0, 0, 0); +if (Object.prototype.toString.call(x11) !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0, 1, 0, 0, 0); +if (Object.prototype.toString.call(x12) !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T5.2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T5.2.js new file mode 100644 index 0000000000..a563decb4b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T5.2.js @@ -0,0 +1,76 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: > + Test based on overwriting prototype.toString - 6 arguments, (year, + month, date, hours, minutes, seconds) +---*/ + +Date.prototype.toString = Object.prototype.toString; + +var x1 = new Date(1899, 11, 31, 23, 59, 59); +if (x1.toString() !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12, 1, 0, 0, 0); +if (x2.toString() !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0, 1, 0, 0, 0); +if (x3.toString() !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11, 31, 23, 59, 59); +if (x4.toString() !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12, 1, 0, 0, 0); +if (x5.toString() !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0, 1, 0, 0, 0); +if (x6.toString() !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11, 31, 23, 59, 59); +if (x7.toString() !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12, 1, 0, 0, 0); +if (x8.toString() !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0, 1, 0, 0, 0); +if (x9.toString() !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11, 31, 23, 59, 59); +if (x10.toString() !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12, 1, 0, 0, 0); +if (x11.toString() !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0, 1, 0, 0, 0); +if (x12.toString() !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T6.1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T6.1.js new file mode 100644 index 0000000000..ba6938f207 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T6.1.js @@ -0,0 +1,72 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 7 arguments, (year, month, date, hours, minutes, seconds, ms) +---*/ + +var x1 = new Date(1899, 11, 31, 23, 59, 59, 999); +if (Object.prototype.toString.call(x1) !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12, 1, 0, 0, 0, 0); +if (Object.prototype.toString.call(x2) !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0, 1, 0, 0, 0, 0); +if (Object.prototype.toString.call(x3) !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11, 31, 23, 59, 59, 999); +if (Object.prototype.toString.call(x4) !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12, 1, 0, 0, 0, 0); +if (Object.prototype.toString.call(x5) !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0, 1, 0, 0, 0, 0); +if (Object.prototype.toString.call(x6) !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11, 31, 23, 59, 59, 999); +if (Object.prototype.toString.call(x7) !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12, 1, 0, 0, 0, 0); +if (Object.prototype.toString.call(x8) !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0, 1, 0, 0, 0, 0); +if (Object.prototype.toString.call(x9) !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11, 31, 23, 59, 59, 999); +if (Object.prototype.toString.call(x10) !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12, 1, 0, 0, 0, 0); +if (Object.prototype.toString.call(x11) !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0, 1, 0, 0, 0, 0); +if (Object.prototype.toString.call(x12) !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T6.2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T6.2.js new file mode 100644 index 0000000000..c8f002a805 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A3_T6.2.js @@ -0,0 +1,76 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: > + Test based on overwriting prototype.toString - 7 arguments, (year, + month, date, hours, minutes, seconds, ms) +---*/ + +Date.prototype.toString = Object.prototype.toString; + +var x1 = new Date(1899, 11, 31, 23, 59, 59, 999); +if (x1.toString() !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(1899, 12, 1, 0, 0, 0, 0); +if (x2.toString() !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(1900, 0, 1, 0, 0, 0, 0); +if (x3.toString() !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(1969, 11, 31, 23, 59, 59, 999); +if (x4.toString() !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(1969, 12, 1, 0, 0, 0, 0); +if (x5.toString() !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(1970, 0, 1, 0, 0, 0, 0); +if (x6.toString() !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(1999, 11, 31, 23, 59, 59, 999); +if (x7.toString() !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(1999, 12, 1, 0, 0, 0, 0); +if (x8.toString() !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x9 = new Date(2000, 0, 1, 0, 0, 0, 0); +if (x9.toString() !== "[object Date]") { + $ERROR("#9: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x10 = new Date(2099, 11, 31, 23, 59, 59, 999); +if (x10.toString() !== "[object Date]") { + $ERROR("#10: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x11 = new Date(2099, 12, 1, 0, 0, 0, 0); +if (x11.toString() !== "[object Date]") { + $ERROR("#11: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x12 = new Date(2100, 0, 1, 0, 0, 0, 0); +if (x12.toString() !== "[object Date]") { + $ERROR("#12: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T1.js new file mode 100644 index 0000000000..b4d30a39cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T1.js @@ -0,0 +1,51 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. If date is supplied use ToNumber(date) + 4. If hours is supplied use ToNumber(hours) + 5. If minutes is supplied use ToNumber(minutes) + 6. If seconds is supplied use ToNumber(seconds) + 7. If ms is supplied use ToNumber(ms) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 2 arguments, (year, month) +---*/ + +var myObj = function(val) { + this.value = val; + this.valueOf = function() { + throw "valueOf-" + this.value; + }; + this.toString = function() { + throw "toString-" + this.value; + }; +}; + +//CHECK#1 +try { + var x1 = new Date(new myObj(1), new myObj(2)); + $ERROR("#1: The 1st step is calling ToNumber(year)"); +} +catch (e) { + if (e !== "valueOf-1") { + $ERROR("#1: The 1st step is calling ToNumber(year)"); + } +} + +//CHECK#2 +try { + var x2 = new Date(1, new myObj(2)); + $ERROR("#2: The 2nd step is calling ToNumber(month)"); +} +catch (e) { + if (e !== "valueOf-2") { + $ERROR("#2: The 2nd step is calling ToNumber(month)"); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T2.js new file mode 100644 index 0000000000..837ddaee6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T2.js @@ -0,0 +1,62 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. If date is supplied use ToNumber(date) + 4. If hours is supplied use ToNumber(hours) + 5. If minutes is supplied use ToNumber(minutes) + 6. If seconds is supplied use ToNumber(seconds) + 7. If ms is supplied use ToNumber(ms) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 3 arguments, (year, month, date) +---*/ + +var myObj = function(val) { + this.value = val; + this.valueOf = function() { + throw "valueOf-" + this.value; + }; + this.toString = function() { + throw "toString-" + this.value; + }; +}; + +//CHECK#1 +try { + var x1 = new Date(new myObj(1), new myObj(2), new myObj(3)); + $ERROR("#1: The 1st step is calling ToNumber(year)"); +} +catch (e) { + if (e !== "valueOf-1") { + $ERROR("#1: The 1st step is calling ToNumber(year)"); + } +} + +//CHECK#2 +try { + var x2 = new Date(1, new myObj(2), new myObj(3)); + $ERROR("#2: The 2nd step is calling ToNumber(month)"); +} +catch (e) { + if (e !== "valueOf-2") { + $ERROR("#2: The 2nd step is calling ToNumber(month)"); + } +} + +//CHECK#3 +try { + var x3 = new Date(1, 2, new myObj(3)); + $ERROR("#3: The 3rd step is calling ToNumber(date)"); +} +catch (e) { + if (e !== "valueOf-3") { + $ERROR("#3: The 3rd step is calling ToNumber(date)"); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T3.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T3.js new file mode 100644 index 0000000000..7be9ef40f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T3.js @@ -0,0 +1,73 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. If date is supplied use ToNumber(date) + 4. If hours is supplied use ToNumber(hours) + 5. If minutes is supplied use ToNumber(minutes) + 6. If seconds is supplied use ToNumber(seconds) + 7. If ms is supplied use ToNumber(ms) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 4 arguments, (year, month, date, hours) +---*/ + +var myObj = function(val) { + this.value = val; + this.valueOf = function() { + throw "valueOf-" + this.value; + }; + this.toString = function() { + throw "toString-" + this.value; + }; +}; + +//CHECK#1 +try { + var x1 = new Date(new myObj(1), new myObj(2), new myObj(3), new myObj(4)); + $ERROR("#1: The 1st step is calling ToNumber(year)"); +} +catch (e) { + if (e !== "valueOf-1") { + $ERROR("#1: The 1st step is calling ToNumber(year)"); + } +} + +//CHECK#2 +try { + var x2 = new Date(1, new myObj(2), new myObj(3), new myObj(4)); + $ERROR("#2: The 2nd step is calling ToNumber(month)"); +} +catch (e) { + if (e !== "valueOf-2") { + $ERROR("#2: The 2nd step is calling ToNumber(month)"); + } +} + +//CHECK#3 +try { + var x3 = new Date(1, 2, new myObj(3), new myObj(4)); + $ERROR("#3: The 3rd step is calling ToNumber(date)"); +} +catch (e) { + if (e !== "valueOf-3") { + $ERROR("#3: The 3rd step is calling ToNumber(date)"); + } +} + +//CHECK#4 +try { + var x4 = new Date(1, 2, 3, new myObj(4)); + $ERROR("#4: The 4th step is calling ToNumber(hours)"); +} +catch (e) { + if (e !== "valueOf-4") { + $ERROR("#4: The 4th step is calling ToNumber(hours)"); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T4.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T4.js new file mode 100644 index 0000000000..37d092a096 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T4.js @@ -0,0 +1,84 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. If date is supplied use ToNumber(date) + 4. If hours is supplied use ToNumber(hours) + 5. If minutes is supplied use ToNumber(minutes) + 6. If seconds is supplied use ToNumber(seconds) + 7. If ms is supplied use ToNumber(ms) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 5 arguments, (year, month, date, hours, minutes) +---*/ + +var myObj = function(val) { + this.value = val; + this.valueOf = function() { + throw "valueOf-" + this.value; + }; + this.toString = function() { + throw "toString-" + this.value; + }; +}; + +//CHECK#1 +try { + var x1 = new Date(new myObj(1), new myObj(2), new myObj(3), new myObj(4), new myObj(5)); + $ERROR("#1: The 1st step is calling ToNumber(year)"); +} +catch (e) { + if (e !== "valueOf-1") { + $ERROR("#1: The 1st step is calling ToNumber(year)"); + } +} + +//CHECK#2 +try { + var x2 = new Date(1, new myObj(2), new myObj(3), new myObj(4), new myObj(5)); + $ERROR("#2: The 2nd step is calling ToNumber(month)"); +} +catch (e) { + if (e !== "valueOf-2") { + $ERROR("#2: The 2nd step is calling ToNumber(month)"); + } +} + +//CHECK#3 +try { + var x3 = new Date(1, 2, new myObj(3), new myObj(4), new myObj(5)); + $ERROR("#3: The 3rd step is calling ToNumber(date)"); +} +catch (e) { + if (e !== "valueOf-3") { + $ERROR("#3: The 3rd step is calling ToNumber(date)"); + } +} + +//CHECK#4 +try { + var x4 = new Date(1, 2, 3, new myObj(4), new myObj(5)); + $ERROR("#4: The 4th step is calling ToNumber(hours)"); +} +catch (e) { + if (e !== "valueOf-4") { + $ERROR("#4: The 4th step is calling ToNumber(hours)"); + } +} + +//CHECK#5 +try { + var x5 = new Date(1, 2, 3, 4, new myObj(5)); + $ERROR("#5: The 5th step is calling ToNumber(minutes)"); +} +catch (e) { + if (e !== "valueOf-5") { + $ERROR("#5: The 5th step is calling ToNumber(minutes)"); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T5.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T5.js new file mode 100644 index 0000000000..97c9a85393 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T5.js @@ -0,0 +1,95 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. If date is supplied use ToNumber(date) + 4. If hours is supplied use ToNumber(hours) + 5. If minutes is supplied use ToNumber(minutes) + 6. If seconds is supplied use ToNumber(seconds) + 7. If ms is supplied use ToNumber(ms) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 6 arguments, (year, month, date, hours, minutes, seconds) +---*/ + +var myObj = function(val) { + this.value = val; + this.valueOf = function() { + throw "valueOf-" + this.value; + }; + this.toString = function() { + throw "toString-" + this.value; + }; +}; + +//CHECK#1 +try { + var x1 = new Date(new myObj(1), new myObj(2), new myObj(3), new myObj(4), new myObj(5), new myObj(6)); + $ERROR("#1: The 1st step is calling ToNumber(year)"); +} +catch (e) { + if (e !== "valueOf-1") { + $ERROR("#1: The 1st step is calling ToNumber(year)"); + } +} + +//CHECK#2 +try { + var x2 = new Date(1, new myObj(2), new myObj(3), new myObj(4), new myObj(5), new myObj(6)); + $ERROR("#2: The 2nd step is calling ToNumber(month)"); +} +catch (e) { + if (e !== "valueOf-2") { + $ERROR("#2: The 2nd step is calling ToNumber(month)"); + } +} + +//CHECK#3 +try { + var x3 = new Date(1, 2, new myObj(3), new myObj(4), new myObj(5), new myObj(6)); + $ERROR("#3: The 3rd step is calling ToNumber(date)"); +} +catch (e) { + if (e !== "valueOf-3") { + $ERROR("#3: The 3rd step is calling ToNumber(date)"); + } +} + +//CHECK#4 +try { + var x4 = new Date(1, 2, 3, new myObj(4), new myObj(5), new myObj(6)); + $ERROR("#4: The 4th step is calling ToNumber(hours)"); +} +catch (e) { + if (e !== "valueOf-4") { + $ERROR("#4: The 4th step is calling ToNumber(hours)"); + } +} + +//CHECK#5 +try { + var x5 = new Date(1, 2, 3, 4, new myObj(5), new myObj(6)); + $ERROR("#5: The 5th step is calling ToNumber(minutes)"); +} +catch (e) { + if (e !== "valueOf-5") { + $ERROR("#5: The 5th step is calling ToNumber(minutes)"); + } +} + +//CHECK#6 +try { + var x6 = new Date(1, 2, 3, 4, 5, new myObj(6)); + $ERROR("#6: The 6th step is calling ToNumber(seconds)"); +} +catch (e) { + if (e !== "valueOf-6") { + $ERROR("#6: The 6th step is calling ToNumber(seconds)"); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T6.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T6.js new file mode 100644 index 0000000000..d4769b0ff9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A4_T6.js @@ -0,0 +1,106 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. If date is supplied use ToNumber(date) + 4. If hours is supplied use ToNumber(hours) + 5. If minutes is supplied use ToNumber(minutes) + 6. If seconds is supplied use ToNumber(seconds) + 7. If ms is supplied use ToNumber(ms) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 7 arguments, (year, month, date, hours, minutes, seconds, ms) +---*/ + +var myObj = function(val) { + this.value = val; + this.valueOf = function() { + throw "valueOf-" + this.value; + }; + this.toString = function() { + throw "toString-" + this.value; + }; +}; + +//CHECK#1 +try { + var x1 = new Date(new myObj(1), new myObj(2), new myObj(3), new myObj(4), new myObj(5), new myObj(6), new myObj(7)); + $ERROR("#1: The 1st step is calling ToNumber(year)"); +} +catch (e) { + if (e !== "valueOf-1") { + $ERROR("#1: The 1st step is calling ToNumber(year)"); + } +} + +//CHECK#2 +try { + var x2 = new Date(1, new myObj(2), new myObj(3), new myObj(4), new myObj(5), new myObj(6), new myObj(7)); + $ERROR("#2: The 2nd step is calling ToNumber(month)"); +} +catch (e) { + if (e !== "valueOf-2") { + $ERROR("#2: The 2nd step is calling ToNumber(month)"); + } +} + +//CHECK#3 +try { + var x3 = new Date(1, 2, new myObj(3), new myObj(4), new myObj(5), new myObj(6), new myObj(7)); + $ERROR("#3: The 3rd step is calling ToNumber(date)"); +} +catch (e) { + if (e !== "valueOf-3") { + $ERROR("#3: The 3rd step is calling ToNumber(date)"); + } +} + +//CHECK#4 +try { + var x4 = new Date(1, 2, 3, new myObj(4), new myObj(5), new myObj(6), new myObj(7)); + $ERROR("#4: The 4th step is calling ToNumber(hours)"); +} +catch (e) { + if (e !== "valueOf-4") { + $ERROR("#4: The 4th step is calling ToNumber(hours)"); + } +} + +//CHECK#5 +try { + var x5 = new Date(1, 2, 3, 4, new myObj(5), new myObj(6), new myObj(7)); + $ERROR("#5: The 5th step is calling ToNumber(minutes)"); +} +catch (e) { + if (e !== "valueOf-5") { + $ERROR("#5: The 5th step is calling ToNumber(minutes)"); + } +} + +//CHECK#6 +try { + var x6 = new Date(1, 2, 3, 4, 5, new myObj(6), new myObj(7)); + $ERROR("#6: The 6th step is calling ToNumber(seconds)"); +} +catch (e) { + if (e !== "valueOf-6") { + $ERROR("#6: The 6th step is calling ToNumber(seconds)"); + } +} + +//CHECK#7 +try { + var x7 = new Date(1, 2, 3, 4, 5, 6, new myObj(7)); + $ERROR("#7: The 7th step is calling ToNumber(ms)"); +} +catch (e) { + if (e !== "valueOf-7") { + $ERROR("#7: The 7th step is calling ToNumber(ms)"); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T1.js new file mode 100644 index 0000000000..029fabd7e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T1.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 8. If Result(1) is not NaN and 0 <= ToInteger(Result(1)) <= 99, Result(8) is + 1900+ToInteger(Result(1)); otherwise, Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3)) + 10. Compute MakeTime(Result(4), Result(5), Result(6), Result(7)) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed object to + TimeClip(UTC(Result(11))) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 2 arguments, (year, month) +includes: [assertRelativeDateMs.js] +---*/ + +assertRelativeDateMs(new Date(1899, 11), -2211667200000); + +assertRelativeDateMs(new Date(1899, 12), -2208988800000); + +assertRelativeDateMs(new Date(1900, 0), -2208988800000); + +assertRelativeDateMs(new Date(1969, 11), -2678400000); + +assertRelativeDateMs(new Date(1969, 12), 0); + +assertRelativeDateMs(new Date(1970, 0), 0); + +assertRelativeDateMs(new Date(1999, 11), 944006400000); + +assertRelativeDateMs(new Date(1999, 12), 946684800000); + +assertRelativeDateMs(new Date(2000, 0), 946684800000); + +assertRelativeDateMs(new Date(2099, 11), 4099766400000); + +assertRelativeDateMs(new Date(2099, 12), 4102444800000); + +assertRelativeDateMs(new Date(2100, 0), 4102444800000); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T2.js new file mode 100644 index 0000000000..0b0cb5d23e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T2.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 8. If Result(1) is not NaN and 0 <= ToInteger(Result(1)) <= 99, Result(8) is + 1900+ToInteger(Result(1)); otherwise, Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3)) + 10. Compute MakeTime(Result(4), Result(5), Result(6), Result(7)) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed object to + TimeClip(UTC(Result(11))) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 3 arguments, (year, month, date) +includes: [assertRelativeDateMs.js] +---*/ + +assertRelativeDateMs(new Date(1899, 11, 31), -2209075200000); + +assertRelativeDateMs(new Date(1899, 12, 1), -2208988800000); + +assertRelativeDateMs(new Date(1900, 0, 1), -2208988800000); + +assertRelativeDateMs(new Date(1969, 11, 31), -86400000); + +assertRelativeDateMs(new Date(1969, 12, 1), 0); + +assertRelativeDateMs(new Date(1970, 0, 1), 0); + +assertRelativeDateMs(new Date(1999, 11, 31), 946598400000); + +assertRelativeDateMs(new Date(1999, 12, 1), 946684800000); + +assertRelativeDateMs(new Date(2000, 0, 1), 946684800000); + +assertRelativeDateMs(new Date(2099, 11, 31), 4102358400000); + +assertRelativeDateMs(new Date(2099, 12, 1), 4102444800000); + +assertRelativeDateMs(new Date(2100, 0, 1), 4102444800000); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T3.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T3.js new file mode 100644 index 0000000000..91aeac8582 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T3.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 8. If Result(1) is not NaN and 0 <= ToInteger(Result(1)) <= 99, Result(8) is + 1900+ToInteger(Result(1)); otherwise, Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3)) + 10. Compute MakeTime(Result(4), Result(5), Result(6), Result(7)) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed object to + TimeClip(UTC(Result(11))) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 4 arguments, (year, month, date, hours) +includes: [assertRelativeDateMs.js] +---*/ + +assertRelativeDateMs(new Date(1899, 11, 31, 23), -2208992400000); + +assertRelativeDateMs(new Date(1899, 12, 1, 0), -2208988800000); + +assertRelativeDateMs(new Date(1900, 0, 1, 0), -2208988800000); + +assertRelativeDateMs(new Date(1969, 11, 31, 23), -3600000); + +assertRelativeDateMs(new Date(1969, 12, 1, 0), 0); + +assertRelativeDateMs(new Date(1970, 0, 1, 0), 0); + +assertRelativeDateMs(new Date(1999, 11, 31, 23), 946681200000); + +assertRelativeDateMs(new Date(1999, 12, 1, 0), 946684800000); + +assertRelativeDateMs(new Date(2000, 0, 1, 0), 946684800000); + +assertRelativeDateMs(new Date(2099, 11, 31, 23), 4102441200000); + +assertRelativeDateMs(new Date(2099, 12, 1, 0), 4102444800000); + +assertRelativeDateMs(new Date(2100, 0, 1, 0), 4102444800000); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T4.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T4.js new file mode 100644 index 0000000000..dd68ecc5ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T4.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 8. If Result(1) is not NaN and 0 <= ToInteger(Result(1)) <= 99, Result(8) is + 1900+ToInteger(Result(1)); otherwise, Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3)) + 10. Compute MakeTime(Result(4), Result(5), Result(6), Result(7)) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed object to + TimeClip(UTC(Result(11))) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 5 arguments, (year, month, date, hours, minutes) +includes: [assertRelativeDateMs.js] +---*/ + +assertRelativeDateMs(new Date(1899, 11, 31, 23, 59), -2208988860000); + +assertRelativeDateMs(new Date(1899, 12, 1, 0, 0), -2208988800000); + +assertRelativeDateMs(new Date(1900, 0, 1, 0, 0), -2208988800000); + +assertRelativeDateMs(new Date(1969, 11, 31, 23, 59), -60000); + +assertRelativeDateMs(new Date(1969, 12, 1, 0, 0), 0); + +assertRelativeDateMs(new Date(1970, 0, 1, 0, 0), 0); + +assertRelativeDateMs(new Date(1999, 11, 31, 23, 59), 946684740000); + +assertRelativeDateMs(new Date(1999, 12, 1, 0, 0), 946684800000); + +assertRelativeDateMs(new Date(2000, 0, 1, 0, 0), 946684800000); + +assertRelativeDateMs(new Date(2099, 11, 31, 23, 59), 4102444740000); + +assertRelativeDateMs(new Date(2099, 12, 1, 0, 0), 4102444800000); + +assertRelativeDateMs(new Date(2100, 0, 1, 0, 0), 4102444800000); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T5.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T5.js new file mode 100644 index 0000000000..8565f3c9bf --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T5.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 8. If Result(1) is not NaN and 0 <= ToInteger(Result(1)) <= 99, Result(8) is + 1900+ToInteger(Result(1)); otherwise, Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3)) + 10. Compute MakeTime(Result(4), Result(5), Result(6), Result(7)) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed object to + TimeClip(UTC(Result(11))) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 6 arguments, (year, month, date, hours, minutes, seconds) +includes: [assertRelativeDateMs.js] +---*/ + +assertRelativeDateMs(new Date(1899, 11, 31, 23, 59, 59), -2208988801000); + +assertRelativeDateMs(new Date(1899, 12, 1, 0, 0, 0), -2208988800000); + +assertRelativeDateMs(new Date(1900, 0, 1, 0, 0, 0), -2208988800000); + +assertRelativeDateMs(new Date(1969, 11, 31, 23, 59, 59), -1000); + +assertRelativeDateMs(new Date(1969, 12, 1, 0, 0, 0), 0); + +assertRelativeDateMs(new Date(1970, 0, 1, 0, 0, 0), 0); + +assertRelativeDateMs(new Date(1999, 11, 31, 23, 59, 59), 946684799000); + +assertRelativeDateMs(new Date(1999, 12, 1, 0, 0, 0), 946684800000); + +assertRelativeDateMs(new Date(2000, 0, 1, 0, 0, 0), 946684800000); + +assertRelativeDateMs(new Date(2099, 11, 31, 23, 59, 59), 4102444799000); + +assertRelativeDateMs(new Date(2099, 12, 1, 0, 0, 0), 4102444800000); + +assertRelativeDateMs(new Date(2100, 0, 1, 0, 0, 0), 4102444800000); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T6.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T6.js new file mode 100644 index 0000000000..3c60cfe520 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A5_T6.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +info: | + The [[Value]] property of the newly constructed object + is set by following steps: + 8. If Result(1) is not NaN and 0 <= ToInteger(Result(1)) <= 99, Result(8) is + 1900+ToInteger(Result(1)); otherwise, Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3)) + 10. Compute MakeTime(Result(4), Result(5), Result(6), Result(7)) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed object to + TimeClip(UTC(Result(11))) +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 7 arguments, (year, month, date, hours, minutes, seconds, ms) +includes: [assertRelativeDateMs.js] +---*/ + +assertRelativeDateMs(new Date(1899, 11, 31, 23, 59, 59, 999), -2208988800001); + +assertRelativeDateMs(new Date(1899, 12, 1, 0, 0, 0, 0), -2208988800000); + +assertRelativeDateMs(new Date(1900, 0, 1, 0, 0, 0, 0), -2208988800000); + +assertRelativeDateMs(new Date(1969, 11, 31, 23, 59, 59, 999), -1); + +assertRelativeDateMs(new Date(1969, 12, 1, 0, 0, 0, 0), 0); + +assertRelativeDateMs(new Date(1970, 0, 1, 0, 0, 0, 0), 0); + +assertRelativeDateMs(new Date(1999, 11, 31, 23, 59, 59, 999), 946684799999); + +assertRelativeDateMs(new Date(1999, 12, 1, 0, 0, 0, 0), 946684800000); + +assertRelativeDateMs(new Date(2000, 0, 1, 0, 0, 0, 0), 946684800000); + +assertRelativeDateMs(new Date(2099, 11, 31, 23, 59, 59, 999), 4102444799999); + +assertRelativeDateMs(new Date(2099, 12, 1, 0, 0, 0, 0), 4102444800000); + +assertRelativeDateMs(new Date(2100, 0, 1, 0, 0, 0, 0), 4102444800000); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T1.js new file mode 100644 index 0000000000..580277d79b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T1.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + with supplied "undefined" argument should be NaN +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 2 arguments, (year, month) +---*/ + +function DateValue(year, month, date, hours, minutes, seconds, ms) { + return new Date(year, month, date, hours, minutes, seconds, ms).valueOf(); +} + +var x; +x = DateValue(1899, 11); +assert.sameValue(x, NaN, "(1899, 11)"); + +x = DateValue(1899, 12); +assert.sameValue(x, NaN, "(1899, 12)"); + +x = DateValue(1900, 0); +assert.sameValue(x, NaN, "(1900, 0)"); + +x = DateValue(1969, 11); +assert.sameValue(x, NaN, "(1969, 11)"); + +x = DateValue(1969, 12); +assert.sameValue(x, NaN, "(1969, 12)"); + +x = DateValue(1970, 0); +assert.sameValue(x, NaN, "(1970, 0)"); + +x = DateValue(1999, 11); +assert.sameValue(x, NaN, "(1999, 11)"); + +x = DateValue(1999, 12); +assert.sameValue(x, NaN, "(1999, 12)"); + +x = DateValue(2000, 0); +assert.sameValue(x, NaN, "(2000, 0)"); + +x = DateValue(2099, 11); +assert.sameValue(x, NaN, "(2099, 11)"); + +x = DateValue(2099, 12); +assert.sameValue(x, NaN, "(2099, 12)"); + +x = DateValue(2100, 0); +assert.sameValue(x, NaN, "(2100, 0)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T2.js new file mode 100644 index 0000000000..57400f61bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T2.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + with supplied "undefined" argument should be NaN +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 3 arguments, (year, month, date) +---*/ + +function DateValue(year, month, date, hours, minutes, seconds, ms) { + return new Date(year, month, date, hours, minutes, seconds, ms).valueOf(); +} + +var x; +x = DateValue(1899, 11, 31); +assert.sameValue(x, NaN, "(1899, 11, 31)"); + +x = DateValue(1899, 12, 1); +assert.sameValue(x, NaN, "(1899, 12, 1)"); + +x = DateValue(1900, 0, 1); +assert.sameValue(x, NaN, "(1900, 0, 1)"); + +x = DateValue(1969, 11, 31); +assert.sameValue(x, NaN, "(1969, 11, 31)"); + +x = DateValue(1969, 12, 1); +assert.sameValue(x, NaN, "(1969, 12, 1)"); + +x = DateValue(1970, 0, 1); +assert.sameValue(x, NaN, "(1970, 0, 1)"); + +x = DateValue(1999, 11, 31); +assert.sameValue(x, NaN, "(1999, 11, 31)"); + +x = DateValue(1999, 12, 1); +assert.sameValue(x, NaN, "(1999, 12, 1)"); + +x = DateValue(2000, 0, 1); +assert.sameValue(x, NaN, "(2000, 0, 1)"); + +x = DateValue(2099, 11, 31); +assert.sameValue(x, NaN, "(2099, 11, 31)"); + +x = DateValue(2099, 12, 1); +assert.sameValue(x, NaN, "(2099, 12, 1)"); + +x = DateValue(2100, 0, 1); +assert.sameValue(x, NaN, "(2100, 0, 1)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T3.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T3.js new file mode 100644 index 0000000000..fa91428df6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T3.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + with supplied "undefined" argument should be NaN +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 4 arguments, (year, month, date, hours) +---*/ + +function DateValue(year, month, date, hours, minutes, seconds, ms) { + return new Date(year, month, date, hours, minutes, seconds, ms).valueOf(); +} + +var x; +x = DateValue(1899, 11, 31, 23); +assert.sameValue(x, NaN, "(1899, 11, 31, 23)"); + +x = DateValue(1899, 12, 1, 0); +assert.sameValue(x, NaN, "(1899, 12, 1, 0)"); + +x = DateValue(1900, 0, 1, 0); +assert.sameValue(x, NaN, "(1900, 0, 1, 0)"); + +x = DateValue(1969, 11, 31, 23); +assert.sameValue(x, NaN, "(1969, 11, 31, 23)"); + +x = DateValue(1969, 12, 1, 0); +assert.sameValue(x, NaN, "(1969, 12, 1, 0)"); + +x = DateValue(1970, 0, 1, 0); +assert.sameValue(x, NaN, "(1970, 0, 1, 0)"); + +x = DateValue(1999, 11, 31, 23); +assert.sameValue(x, NaN, "(1999, 11, 31, 23)"); + +x = DateValue(1999, 12, 1, 0); +assert.sameValue(x, NaN, "(1999, 12, 1, 0)"); + +x = DateValue(2000, 0, 1, 0); +assert.sameValue(x, NaN, "(2000, 0, 1, 0)"); + +x = DateValue(2099, 11, 31, 23); +assert.sameValue(x, NaN, "(2099, 11, 31, 23)"); + +x = DateValue(2099, 12, 1, 0); +assert.sameValue(x, NaN, "(2099, 12, 1, 0)"); + +x = DateValue(2100, 0, 1, 0); +assert.sameValue(x, NaN, "(2100, 0, 1, 0)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T4.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T4.js new file mode 100644 index 0000000000..11535a5f44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T4.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + with supplied "undefined" argument should be NaN +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 5 arguments, (year, month, date, hours, minutes) +---*/ + +function DateValue(year, month, date, hours, minutes, seconds, ms) { + return new Date(year, month, date, hours, minutes, seconds, ms).valueOf(); +} + +var x; +x = DateValue(1899, 11, 31, 23, 59); +assert.sameValue(x, NaN, "(1899, 11, 31, 23, 59)"); + +x = DateValue(1899, 12, 1, 0, 0); +assert.sameValue(x, NaN, "(1899, 12, 1, 0, 0)"); + +x = DateValue(1900, 0, 1, 0, 0); +assert.sameValue(x, NaN, "(1900, 0, 1, 0, 0)"); + +x = DateValue(1969, 11, 31, 23, 59); +assert.sameValue(x, NaN, "(1969, 11, 31, 23, 59)"); + +x = DateValue(1969, 12, 1, 0, 0); +assert.sameValue(x, NaN, "(1969, 12, 1, 0, 0)"); + +x = DateValue(1970, 0, 1, 0, 0); +assert.sameValue(x, NaN, "(1970, 0, 1, 0, 0)"); + +x = DateValue(1999, 11, 31, 23, 59); +assert.sameValue(x, NaN, "(1999, 11, 31, 23, 59)"); + +x = DateValue(1999, 12, 1, 0, 0); +assert.sameValue(x, NaN, "(1999, 12, 1, 0, 0)"); + +x = DateValue(2000, 0, 1, 0, 0); +assert.sameValue(x, NaN, "(2000, 0, 1, 0, 0)"); + +x = DateValue(2099, 11, 31, 23, 59); +assert.sameValue(x, NaN, "(2099, 11, 31, 23, 59)"); + +x = DateValue(2099, 12, 1, 0, 0); +assert.sameValue(x, NaN, "(2099, 12, 1, 0, 0)"); + +x = DateValue(2100, 0, 1, 0, 0); +assert.sameValue(x, NaN, "(2100, 0, 1, 0, 0)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T5.js b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T5.js new file mode 100644 index 0000000000..825174b761 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.1_A6_T5.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Value]] property of the newly constructed object + with supplied "undefined" argument should be NaN +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: 6 arguments, (year, month, date, hours, minutes, seconds) +---*/ + +function DateValue(year, month, date, hours, minutes, seconds, ms) { + return new Date(year, month, date, hours, minutes, seconds, ms).valueOf(); +} + +var x; +x = DateValue(1899, 11, 31, 23, 59, 59); +assert.sameValue(x, NaN, "(1899, 11, 31, 23, 59, 59)"); + +x = DateValue(1899, 12, 1, 0, 0, 0); +assert.sameValue(x, NaN, "(1899, 12, 1, 0, 0, 0)"); + +x = DateValue(1900, 0, 1, 0, 0, 0); +assert.sameValue(x, NaN, "(1900, 0, 1, 0, 0, 0)"); + +x = DateValue(1969, 11, 31, 23, 59, 59); +assert.sameValue(x, NaN, "(1969, 11, 31, 23, 59, 59)"); + +x = DateValue(1969, 12, 1, 0, 0, 0); +assert.sameValue(x, NaN, "(1969, 12, 1, 0, 0, 0)"); + +x = DateValue(1970, 0, 1, 0, 0, 0); +assert.sameValue(x, NaN, "(1970, 0, 1, 0, 0, 0)"); + +x = DateValue(1999, 11, 31, 23, 59, 59); +assert.sameValue(x, NaN, "(1999, 11, 31, 23, 59, 59)"); + +x = DateValue(1999, 12, 1, 0, 0, 0); +assert.sameValue(x, NaN, "(1999, 12, 1, 0, 0, 0)"); + +x = DateValue(2000, 0, 1, 0, 0, 0); +assert.sameValue(x, NaN, "(2000, 0, 1, 0, 0, 0)"); + +x = DateValue(2099, 11, 31, 23, 59, 59); +assert.sameValue(x, NaN, "(2099, 11, 31, 23, 59, 59)"); + +x = DateValue(2099, 12, 1, 0, 0, 0); +assert.sameValue(x, NaN, "(2099, 12, 1, 0, 0, 0)"); + +x = DateValue(2100, 0, 1, 0, 0, 0); +assert.sameValue(x, NaN, "(2100, 0, 1, 0, 0, 0)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.2_A1_T1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.2_A1_T1.js new file mode 100644 index 0000000000..ca487afc38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.2_A1_T1.js @@ -0,0 +1,157 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When Date is called as part of a new expression it is + a constructor: it initialises the newly created object +esid: sec-date-value +description: Checking types of newly created objects and it values +includes: [dateConstants.js] +---*/ + +if (typeof new Date(date_1899_end) !== "object") { + $ERROR("#1.1: typeof new Date(date_1899_end) === 'object'"); +} + +if (new Date(date_1899_end) === undefined) { + $ERROR("#1.2: new Date(date_1899_end) === undefined"); +} + +var x13 = new Date(date_1899_end); +if (typeof x13 !== "object") { + $ERROR("#1.3: typeof new Date(date_1899_end) !== 'object'"); +} + +var x14 = new Date(date_1899_end); +if (x14 === undefined) { + $ERROR("#1.4: new Date(date_1899_end) !== undefined"); +} + +if (typeof new Date(date_1900_start) !== "object") { + $ERROR("#2.1: typeof new Date(date_1900_start) === 'object'"); +} + +if (new Date(date_1900_start) === undefined) { + $ERROR("#2.2: new Date(date_1900_start) === undefined"); +} + +var x23 = new Date(date_1900_start); +if (typeof x23 !== "object") { + $ERROR("#2.3: typeof new Date(date_1900_start) !== 'object'"); +} + +var x24 = new Date(date_1900_start); +if (x24 === undefined) { + $ERROR("#2.4: new Date(date_1900_start) !== undefined"); +} + +if (typeof new Date(date_1969_end) !== "object") { + $ERROR("#3.1: typeof new Date(date_1969_end) === 'object'"); +} + +if (new Date(date_1969_end) === undefined) { + $ERROR("#3.2: new Date(date_1969_end) === undefined"); +} + +var x33 = new Date(date_1969_end); +if (typeof x33 !== "object") { + $ERROR("#3.3: typeof new Date(date_1969_end) !== 'object'"); +} + +var x34 = new Date(date_1969_end); +if (x34 === undefined) { + $ERROR("#3.4: new Date(date_1969_end) !== undefined"); +} + +if (typeof new Date(date_1970_start) !== "object") { + $ERROR("#4.1: typeof new Date(date_1970_start) === 'object'"); +} + +if (new Date(date_1970_start) === undefined) { + $ERROR("#4.2: new Date(date_1970_start) === undefined"); +} + +var x43 = new Date(date_1970_start); +if (typeof x43 !== "object") { + $ERROR("#4.3: typeof new Date(date_1970_start) !== 'object'"); +} + +var x44 = new Date(date_1970_start); +if (x44 === undefined) { + $ERROR("#4.4: new Date(date_1970_start) !== undefined"); +} + +if (typeof new Date(date_1999_end) !== "object") { + $ERROR("#5.1: typeof new Date(date_1999_end) === 'object'"); +} + +if (new Date(date_1999_end) === undefined) { + $ERROR("#5.2: new Date(date_1999_end) === undefined"); +} + +var x53 = new Date(date_1999_end); +if (typeof x53 !== "object") { + $ERROR("#5.3: typeof new Date(date_1999_end) !== 'object'"); +} + +var x54 = new Date(date_1999_end); +if (x54 === undefined) { + $ERROR("#5.4: new Date(date_1999_end) !== undefined"); +} + +if (typeof new Date(date_2000_start) !== "object") { + $ERROR("#6.1: typeof new Date(date_2000_start) === 'object'"); +} + +if (new Date(date_2000_start) === undefined) { + $ERROR("#6.2: new Date(date_2000_start) === undefined"); +} + +var x63 = new Date(date_2000_start); +if (typeof x63 !== "object") { + $ERROR("#6.3: typeof new Date(date_2000_start) !== 'object'"); +} + +var x64 = new Date(date_2000_start); +if (x64 === undefined) { + $ERROR("#6.4: new Date(date_2000_start) !== undefined"); +} + +if (typeof new Date(date_2099_end) !== "object") { + $ERROR("#7.1: typeof new Date(date_2099_end) === 'object'"); +} + +if (new Date(date_2099_end) === undefined) { + $ERROR("#7.2: new Date(date_2099_end) === undefined"); +} + +var x73 = new Date(date_2099_end); +if (typeof x73 !== "object") { + $ERROR("#7.3: typeof new Date(date_2099_end) !== 'object'"); +} + +var x74 = new Date(date_2099_end); +if (x74 === undefined) { + $ERROR("#7.4: new Date(date_2099_end) !== undefined"); +} + +if (typeof new Date(date_2100_start) !== "object") { + $ERROR("#8.1: typeof new Date(date_2100_start) === 'object'"); +} + +if (new Date(date_2100_start) === undefined) { + $ERROR("#8.2: new Date(date_2100_start) === undefined"); +} + +var x83 = new Date(date_2100_start); +if (typeof x83 !== "object") { + $ERROR("#8.3: typeof new Date(date_2100_start) !== 'object'"); +} + +var x84 = new Date(date_2100_start); +if (x84 === undefined) { + $ERROR("#8.4: new Date(date_2100_start) !== undefined"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.2_A2_T1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.2_A2_T1.js new file mode 100644 index 0000000000..9065f2f81d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.2_A2_T1.js @@ -0,0 +1,134 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Date prototype object, the one that is the + initial value of Date.prototype +esid: sec-date-value +description: Checking Date.prototype property of newly constructed objects +includes: [dateConstants.js] +---*/ + +var x11 = new Date(date_1899_end); +if (typeof x11.constructor.prototype !== "object") { + $ERROR("#1.1: typeof x11.constructor.prototype === 'object'"); +} + +var x12 = new Date(date_1899_end); +if (!Date.prototype.isPrototypeOf(x12)) { + $ERROR('#1.2: Date.prototype.isPrototypeOf(x12)'); +} + +var x13 = new Date(date_1899_end); +if (Date.prototype !== x13.constructor.prototype) { + $ERROR("#1.3: Date.prototype !== x13.constructor.prototype"); +} + +var x21 = new Date(date_1900_start); +if (typeof x21.constructor.prototype !== "object") { + $ERROR("#2.1: typeof x21.constructor.prototype === 'object'"); +} + +var x22 = new Date(date_1900_start); +if (!Date.prototype.isPrototypeOf(x22)) { + $ERROR('#2.2: Date.prototype.isPrototypeOf(x22)'); +} + +var x23 = new Date(date_1900_start); +if (Date.prototype !== x23.constructor.prototype) { + $ERROR("#2.3: Date.prototype !== x23.constructor.prototype"); +} + +var x31 = new Date(date_1969_end); +if (typeof x31.constructor.prototype !== "object") { + $ERROR("#3.1: typeof x31.constructor.prototype === 'object'"); +} + +var x32 = new Date(date_1969_end); +if (!Date.prototype.isPrototypeOf(x32)) { + $ERROR('#3.2: Date.prototype.isPrototypeOf(x32)'); +} + +var x33 = new Date(date_1969_end); +if (Date.prototype !== x33.constructor.prototype) { + $ERROR("#3.3: Date.prototype !== x33.constructor.prototype"); +} + +var x41 = new Date(date_1970_start); +if (typeof x41.constructor.prototype !== "object") { + $ERROR("#4.1: typeof x11.constructor.prototype === 'object'"); +} + +var x42 = new Date(date_1970_start); +if (!Date.prototype.isPrototypeOf(x42)) { + $ERROR('#4.2: Date.prototype.isPrototypeOf(x42)'); +} + +var x43 = new Date(date_1970_start); +if (Date.prototype !== x43.constructor.prototype) { + $ERROR("#4.3: Date.prototype !== x43.constructor.prototype"); +} + +var x51 = new Date(date_1999_end); +if (typeof x51.constructor.prototype !== "object") { + $ERROR("#5.1: typeof x51.constructor.prototype === 'object'"); +} + +var x52 = new Date(date_1999_end); +if (!Date.prototype.isPrototypeOf(x52)) { + $ERROR('#5.2: Date.prototype.isPrototypeOf(x52)'); +} + +var x53 = new Date(date_1999_end); +if (Date.prototype !== x53.constructor.prototype) { + $ERROR("#5.3: Date.prototype !== x53.constructor.prototype"); +} + +var x61 = new Date(date_2000_start); +if (typeof x61.constructor.prototype !== "object") { + $ERROR("#6.1: typeof x61.constructor.prototype === 'object'"); +} + +var x62 = new Date(date_2000_start); +if (!Date.prototype.isPrototypeOf(x62)) { + $ERROR('#6.2: Date.prototype.isPrototypeOf(x62)'); +} + +var x63 = new Date(date_2000_start); +if (Date.prototype !== x63.constructor.prototype) { + $ERROR("#6.3: Date.prototype !== x63.constructor.prototype"); +} + +var x71 = new Date(date_2099_end); +if (typeof x71.constructor.prototype !== "object") { + $ERROR("#7.1: typeof x71.constructor.prototype === 'object'"); +} + +var x72 = new Date(date_2099_end); +if (!Date.prototype.isPrototypeOf(x72)) { + $ERROR('#7.2: Date.prototype.isPrototypeOf(x72)'); +} + +var x73 = new Date(date_2099_end); +if (Date.prototype !== x73.constructor.prototype) { + $ERROR("#7.3: Date.prototype !== x73.constructor.prototype"); +} + +var x81 = new Date(date_2100_start); +if (typeof x81.constructor.prototype !== "object") { + $ERROR("#8.1: typeof x81.constructor.prototype === 'object'"); +} + +var x82 = new Date(date_2100_start); +if (!Date.prototype.isPrototypeOf(x82)) { + $ERROR('#8.2: Date.prototype.isPrototypeOf(x82)'); +} + +var x83 = new Date(date_2100_start); +if (Date.prototype !== x83.constructor.prototype) { + $ERROR("#8.3: Date.prototype !== x83.constructor.prototype"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.2_A3_T1.1.js b/js/src/tests/test262/built-ins/Date/S15.9.3.2_A3_T1.1.js new file mode 100644 index 0000000000..78718796d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.2_A3_T1.1.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-value +description: Test based on delete prototype.toString +includes: [dateConstants.js] +---*/ + +var x1 = new Date(date_1899_end); +if (Object.prototype.toString.call(x1) !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(date_1900_start); +if (Object.prototype.toString.call(x2) !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(date_1969_end); +if (Object.prototype.toString.call(x3) !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(date_1970_start); +if (Object.prototype.toString.call(x4) !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(date_1999_end); +if (Object.prototype.toString.call(x5) !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(date_2000_start); +if (Object.prototype.toString.call(x6) !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(date_2099_end); +if (Object.prototype.toString.call(x7) !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(date_2100_start); +if (Object.prototype.toString.call(x8) !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.3.2_A3_T1.2.js b/js/src/tests/test262/built-ins/Date/S15.9.3.2_A3_T1.2.js new file mode 100644 index 0000000000..36e29720ba --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.3.2_A3_T1.2.js @@ -0,0 +1,55 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Class]] property of the newly constructed object + is set to "Date" +esid: sec-date-value +description: Test based on overwriting prototype.toString +includes: [dateConstants.js] +---*/ + +Date.prototype.toString = Object.prototype.toString; + +var x1 = new Date(date_1899_end); +if (x1.toString() !== "[object Date]") { + $ERROR("#1: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x2 = new Date(date_1900_start); +if (x2.toString() !== "[object Date]") { + $ERROR("#2: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x3 = new Date(date_1969_end); +if (x3.toString() !== "[object Date]") { + $ERROR("#3: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x4 = new Date(date_1970_start); +if (x4.toString() !== "[object Date]") { + $ERROR("#4: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x5 = new Date(date_1999_end); +if (x5.toString() !== "[object Date]") { + $ERROR("#5: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x6 = new Date(date_2000_start); +if (x6.toString() !== "[object Date]") { + $ERROR("#6: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x7 = new Date(date_2099_end); +if (x7.toString() !== "[object Date]") { + $ERROR("#7: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +var x8 = new Date(date_2100_start); +if (x8.toString() !== "[object Date]") { + $ERROR("#8: The [[Class]] property of the newly constructed object is set to 'Date'"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.4_A1.js b/js/src/tests/test262/built-ins/Date/S15.9.4_A1.js new file mode 100644 index 0000000000..42df72ae45 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.4_A1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date constructor has the property "prototype" +esid: sec-date-constructor +description: Checking existence of the property "prototype" +---*/ + +if (!Date.hasOwnProperty("prototype")) { + $ERROR('#1: The Date constructor has the property "prototype"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.4_A2.js b/js/src/tests/test262/built-ins/Date/S15.9.4_A2.js new file mode 100644 index 0000000000..85d954e7dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.4_A2.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date constructor has the property "parse" +esid: sec-date-constructor +description: Checking existence of the property "parse" +---*/ + +if (!Date.hasOwnProperty("parse")) { + $ERROR('#1: The Date constructor has the property "parse"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.4_A3.js b/js/src/tests/test262/built-ins/Date/S15.9.4_A3.js new file mode 100644 index 0000000000..c3f0d7273e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.4_A3.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date constructor has the property "UTC" +esid: sec-date-constructor +description: Checking existence of the property "UTC" +---*/ + +if (!Date.hasOwnProperty("UTC")) { + $ERROR('#1: The Date constructor has the property "UTC"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.4_A4.js b/js/src/tests/test262/built-ins/Date/S15.9.4_A4.js new file mode 100644 index 0000000000..8e38fda067 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.4_A4.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of the Date + constructor is the Function prototype object +esid: sec-date-constructor +description: Checking Function.prototype.isPrototypeOf(Date) +---*/ + +//CHECK#1 +if (!(Function.prototype.isPrototypeOf(Date))) { + $ERROR('#1: the value of the internal [[Prototype]] property of the Date constructor is the Function prototype object.'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/S15.9.4_A5.js b/js/src/tests/test262/built-ins/Date/S15.9.4_A5.js new file mode 100644 index 0000000000..7da56ee4ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/S15.9.4_A5.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Date constructor has length property whose value is 7 +esid: sec-date-constructor +description: Checking Date.length property +---*/ + +//CHECK#1 +if (!Date.hasOwnProperty("length")) { + $ERROR('#1: Date constructor has length property'); +} + +//CHECK#2 +if (Date.length !== 7) { + $ERROR('#2: Date constructor length property value should be 7'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/TimeClip_negative_zero.js b/js/src/tests/test262/built-ins/Date/TimeClip_negative_zero.js new file mode 100644 index 0000000000..9d1645d482 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/TimeClip_negative_zero.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-timeclip +description: TimeClip converts negative zero to positive zero +info: | + 20.3.1.15 TimeClip (time) + + ... + 3. Return ToInteger(time) + (+0). (Adding a positive zero converts -0 to +0.) +es6id: 20.3.1.15 +---*/ + +var date = new Date(-0); + +assert.sameValue(date.getTime(), +0, "TimeClip does not return negative zero"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T1.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T1.js new file mode 100644 index 0000000000..b3910a5645 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.utc +info: The Date property "UTC" has { DontEnum } attributes +es5id: 15.9.4.3_A1_T1 +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.UTC; +if (x === 1) + Date.UTC = 2; +else + Date.UTC = 1; +if (Date.UTC === x) { + $ERROR('#1: The Date.UTC has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T2.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T2.js new file mode 100644 index 0000000000..d380cffbdd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.utc +info: The Date property "UTC" has { DontEnum } attributes +es5id: 15.9.4.3_A1_T2 +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.UTC === false) { + $ERROR('#1: The Date.UTC property has not the attributes DontDelete'); +} + +if (Date.hasOwnProperty('UTC')) { + $ERROR('#2: The Date.UTC property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T3.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T3.js new file mode 100644 index 0000000000..3a6fa77be2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.utc +info: The Date property "UTC" has { DontEnum } attributes +es5id: 15.9.4.3_A1_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.propertyIsEnumerable('UTC')) { + $ERROR('#1: The Date.UTC property has the attribute DontEnum'); +} + +for (var x in Date) { + if (x === "UTC") { + $ERROR('#2: The Date.UTC has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A2_T1.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A2_T1.js new file mode 100644 index 0000000000..449eaef333 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A2_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.utc +info: The "length" property of the "UTC" is 7 +es5id: 15.9.4.3_A2_T1 +description: The "length" property of the "UTC" is 7 +---*/ + +if (Date.UTC.hasOwnProperty("length") !== true) { + $ERROR('#1: The UTC has a "length" property'); +} + +if (Date.UTC.length !== 7) { + $ERROR('#2: The "length" property of the UTC is 7'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T1.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T1.js new file mode 100644 index 0000000000..778ba8a4e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.utc +info: | + The Date.UTC property "length" has { ReadOnly, DontDelete, DontEnum } + attributes +es5id: 15.9.4.3_A3_T1 +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.UTC.length; +verifyNotWritable(Date.UTC, "length", null, 1); +if (Date.UTC.length !== x) { + $ERROR('#1: The Date.UTC.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T2.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T2.js new file mode 100644 index 0000000000..f5c00fffcd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.utc +info: | + The Date.UTC property "length" has { ReadOnly, ! DontDelete, DontEnum } + attributes +es5id: 15.9.4.3_A3_T2 +description: Checking DontDelete attribute +---*/ + +if (delete Date.UTC.length !== true) { + $ERROR('#1: The Date.UTC.length property does not have the attributes DontDelete'); +} + +if (Date.UTC.hasOwnProperty('length')) { + $ERROR('#2: The Date.UTC.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T3.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T3.js new file mode 100644 index 0000000000..fe8f7b646d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.utc +info: | + The Date.UTC property "length" has { ReadOnly, DontDelete, DontEnum } + attributes +es5id: 15.9.4.3_A3_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.UTC.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.UTC.length property has the attribute DontEnum'); +} + +for (var x in Date.UTC) { + if (x === "length") { + $ERROR('#2: The Date.UTC.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/browser.js b/js/src/tests/test262/built-ins/Date/UTC/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/browser.js diff --git a/js/src/tests/test262/built-ins/Date/UTC/coercion-errors.js b/js/src/tests/test262/built-ins/Date/UTC/coercion-errors.js new file mode 100644 index 0000000000..7271172c12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/coercion-errors.js @@ -0,0 +1,61 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: Abrupt completions from coercing input values +info: | + 1. Let y be ? ToNumber(year). + 2. Let m be ? ToNumber(month). + 3. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + 4. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + 5. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + 6. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + 7. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +var thrower = { toString: function() { throw new Test262Error(); } }; +var counter = { toString: function() { callCount += 1; } }; +var callCount = 0; + +assert.throws(Test262Error, function() { + Date.UTC(thrower, counter); +}, 'year'); +assert.sameValue(callCount, 0, 'coercion halts following error from "year"'); + +assert.throws(Test262Error, function() { + Date.UTC(0, thrower, counter); +}, 'month'); +assert.sameValue(callCount, 0, 'coercion halts following error from "month"'); + +assert.throws(Test262Error, function() { + Date.UTC(0, 0, thrower, counter); +}, 'date'); +assert.sameValue(callCount, 0, 'coercion halts following error from "date"'); + +assert.throws(Test262Error, function() { + Date.UTC(0, 0, 1, thrower, counter); +}, 'hours'); +assert.sameValue(callCount, 0, 'coercion halts following error from "hours"'); + +assert.throws(Test262Error, function() { + Date.UTC(0, 0, 1, 0, thrower, counter); +}, 'minutes'); +assert.sameValue( + callCount, 0, 'coercion halts following error from "minutes"' +); + +assert.throws(Test262Error, function() { + Date.UTC(0, 0, 1, 0, 0, thrower, counter); +}, 'seconds'); +assert.sameValue( + callCount, 0, 'coercion halts following error from "seconds"' +); + +assert.throws(Test262Error, function() { + Date.UTC(0, 0, 1, 0, 0, 0, thrower); +}, 'ms'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/coercion-order.js b/js/src/tests/test262/built-ins/Date/UTC/coercion-order.js new file mode 100644 index 0000000000..96d9cd6ad2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/coercion-order.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: Order of input coercion +info: | + 1. Let y be ? ToNumber(year). + 2. Let m be ? ToNumber(month). + 3. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + 4. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + 5. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + 6. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + 7. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +var log = ''; +var year = { toString: function() { log += 'year'; return 0; } }; +var month = { toString: function() { log += 'month'; return 0; } }; +var date = { toString: function() { log += 'date'; return 1; } }; +var hours = { toString: function() { log += 'hours'; return 0; } }; +var minutes = { toString: function() { log += 'minutes'; return 0; } }; +var seconds = { toString: function() { log += 'seconds'; return 0; } }; +var ms = { toString: function() { log += 'ms'; return 0; } }; + +Date.UTC(year, month, date, hours,minutes, seconds, ms); + +assert.sameValue(log, 'yearmonthdatehoursminutessecondsms'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/fp-evaluation-order.js b/js/src/tests/test262/built-ins/Date/UTC/fp-evaluation-order.js new file mode 100644 index 0000000000..57d9ec6800 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/fp-evaluation-order.js @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: arithmetic in Date is done on floating-point numbers +info: | + [...] + Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + #sec-maketime + + Let _t_ be ((_h_ `*` msPerHour `+` _m_ `*` msPerMinute) `+` _s_ `*` msPerSecond) `+` _milli_, performing the arithmetic according to IEEE 754-2019 rules (that is, as if using the ECMAScript operators `*` and `+`). + + #sec-makedate + + Return day × msPerDay + time. +---*/ + +assert.sameValue(Date.UTC(1970, 0, 1, 80063993375, 29, 1, -288230376151711740), 29312, 'order of operations / precision in MakeTime'); +assert.sameValue(Date.UTC(1970, 0, 213503982336, 0, 0, 0, -18446744073709552000), 34447360, 'precision in MakeDate'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/infinity-make-day.js b/js/src/tests/test262/built-ins/Date/UTC/infinity-make-day.js new file mode 100644 index 0000000000..e4acdd5e3e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/infinity-make-day.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: Infinite values specified to MakeDay produce NaN +info: | + [...] + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + MakeDay (year, month, date) + + 1. If year is not finite or month is not finite or date is not finite, return + NaN. +---*/ + +assert.sameValue(Date.UTC(Infinity), NaN, 'year: Infinity - single arg'); +assert.sameValue(Date.UTC(-Infinity), NaN, 'year: -Infinity - single arg'); + +assert.sameValue(Date.UTC(Infinity, 0), NaN, 'year: Infinity'); +assert.sameValue(Date.UTC(-Infinity, 0), NaN, 'year: -Infinity'); + +assert.sameValue(Date.UTC(0, Infinity), NaN, 'month: Infinity'); +assert.sameValue(Date.UTC(0, -Infinity), NaN, 'month: -Infinity'); + +assert.sameValue(Date.UTC(0, 0, Infinity), NaN, 'date: Infinity'); +assert.sameValue(Date.UTC(0, 0, -Infinity), NaN, 'date: -Infinity'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/infinity-make-time.js b/js/src/tests/test262/built-ins/Date/UTC/infinity-make-time.js new file mode 100644 index 0000000000..b54dc3fb87 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/infinity-make-time.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: Infinite values specified to MakeTime produce NaN +info: | + [...] + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + MakeTime (hour, min, sec, ms) + + 1. If hour is not finite or min is not finite or sec is not finite or ms is + not finite, return NaN. +---*/ + +assert.sameValue(Date.UTC(0, 0, 1, Infinity), NaN, 'hour: Infinity'); +assert.sameValue(Date.UTC(0, 0, 1, -Infinity), NaN, 'hour: -Infinity'); + +assert.sameValue(Date.UTC(0, 0, 1, 0, Infinity), NaN, 'minute: Infinity'); +assert.sameValue(Date.UTC(0, 0, 1, 0, -Infinity), NaN, 'minute: -Infinity'); + +assert.sameValue(Date.UTC(0, 0, 1, 0, 0, Infinity), NaN, 'second: Infinity'); +assert.sameValue(Date.UTC(0, 0, 1, 0, 0, -Infinity), NaN, 'second: -Infinity'); + +assert.sameValue(Date.UTC(0, 0, 1, 0, 0, 0, Infinity), NaN, 'ms: Infinity'); +assert.sameValue(Date.UTC(0, 0, 1, 0, 0, 0, -Infinity), NaN, 'ms: -Infinity'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/name.js b/js/src/tests/test262/built-ins/Date/UTC/name.js new file mode 100644 index 0000000000..3310708e58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.utc +description: > + Date.UTC.name is "UTC". +info: | + Date.UTC ( year, month [ , date [ , hours [ , minutes [ , seconds [ , ms ] ] ] ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.UTC.name, "UTC"); + +verifyNotEnumerable(Date.UTC, "name"); +verifyNotWritable(Date.UTC, "name"); +verifyConfigurable(Date.UTC, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/nans.js b/js/src/tests/test262/built-ins/Date/UTC/nans.js new file mode 100644 index 0000000000..bb34f493f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/nans.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: NaN value handling +info: | + 1. Let y be ? ToNumber(year). + 2. Let m be ? ToNumber(month). + 3. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + 4. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + 5. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + 6. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + 7. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +assert.sameValue(Date.UTC(NaN), NaN, 'year'); +assert.sameValue(Date.UTC(NaN, 0), NaN, 'year'); +assert.sameValue(Date.UTC(1970, NaN), NaN, 'month'); +assert.sameValue(Date.UTC(1970, 0, NaN), NaN, 'date'); +assert.sameValue(Date.UTC(1970, 0, 1, NaN), NaN, 'hours'); +assert.sameValue(Date.UTC(1970, 0, 1, 0, NaN), NaN, 'minutes'); +assert.sameValue(Date.UTC(1970, 0, 1, 0, 0, NaN), NaN, 'seconds'); +assert.sameValue(Date.UTC(1970, 0, 1, 0, 0, 0, NaN), NaN, 'ms'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/no-arg.js b/js/src/tests/test262/built-ins/Date/UTC/no-arg.js new file mode 100644 index 0000000000..b9a98a4f1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/no-arg.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: Tests for non optional arguments +info: | + 1. Let y be ? ToNumber(year). + 2. Let m be ? ToNumber(month). + 3. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + 4. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + 5. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + 6. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + 7. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +assert.sameValue(Date.UTC(), NaN, 'missing non-optional year argument'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/non-integer-values.js b/js/src/tests/test262/built-ins/Date/UTC/non-integer-values.js new file mode 100644 index 0000000000..998d0c2182 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/non-integer-values.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 Viktor Mukhachev. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: non-integer values are converted to integers using `ToInteger` +info: | + [...] + Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + #sec-timeclip + + Let clippedTime be ! ToInteger(time). + + #sec-makeday + + Let y be ! ToInteger(year). + Let m be ! ToInteger(month). + Let dt be ! ToInteger(date). + + #sec-maketime + + Let h be ! ToInteger(hour). + Let m be ! ToInteger(min). + Let s be ! ToInteger(sec). + Let milli be ! ToInteger(ms). +---*/ + +assert.sameValue(Date.UTC(1970.9, 0.9, 1.9, 0.9, 0.9, 0.9, 0.9), 0, 'positive non-integer values'); +assert.sameValue(Date.UTC(-1970.9, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9), -124334438400000, 'negative non-integer values'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/UTC/not-a-constructor.js new file mode 100644 index 0000000000..b655948879 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.UTC does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(Date.UTC), false, 'isConstructor(Date.UTC) must return false'); + +assert.throws(TypeError, () => { + new Date.UTC(); +}, '`new Date.UTC()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/overflow-make-day.js b/js/src/tests/test262/built-ins/Date/UTC/overflow-make-day.js new file mode 100644 index 0000000000..8aa640d1a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/overflow-make-day.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: Values specified to MakeDay exceed their calendar boundaries +info: | + [...] + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + MakeDay (year, month, date) + + [...] + 5. Let ym be y + floor(m / 12). + [...] + 7. Find a value t such that YearFromTime(t) is ym and MonthFromTime(t) is mn + and DateFromTime(t) is 1; but if this is not possible (because some + argument is out of range), return NaN. + 8. Return Day(t) + dt - 1. +---*/ + +assert.sameValue(Date.UTC(2016, 12), 1483228800000, 'month: 12'); +assert.sameValue(Date.UTC(2016, 13), 1485907200000, 'month: 13'); +assert.sameValue(Date.UTC(2016, 144), 1830297600000, 'month: 144'); + +assert.sameValue(Date.UTC(2016, 0, 33), 1454371200000, 'day greater than month'); +assert.sameValue(Date.UTC(2016, 2, -27), 1454371200000, 'day negative value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/overflow-make-time.js b/js/src/tests/test262/built-ins/Date/UTC/overflow-make-time.js new file mode 100644 index 0000000000..db975cd160 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/overflow-make-time.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: Values specified to MakeTime exceed their time boundaries +info: | + [...] + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + MakeTime (hour, min, sec, ms) + + 1. If hour is not finite or min is not finite or sec is not finite or ms is + not finite, return NaN. + 2. Let h be ToInteger(hour). + 3. Let m be ToInteger(min). + 4. Let s be ToInteger(sec). + 5. Let milli be ToInteger(ms). + 6. Let t be h * msPerHour + m * msPerMinute + s * msPerSecond + milli, + performing the arithmetic according to IEEE 754-2008 rules (that is, as if + using the ECMAScript operators * and +). + 7. Return t. +---*/ + +assert.sameValue(Date.UTC(2016, 6, 5, -1), 1467673200000, 'hour: -1'); +assert.sameValue(Date.UTC(2016, 6, 5, 24), 1467763200000, 'hour: 24'); +assert.sameValue(Date.UTC(2016, 6, 5, 0, -1), 1467676740000, 'minute: -1'); +assert.sameValue(Date.UTC(2016, 6, 5, 0, 60), 1467680400000, 'minute: 60'); +assert.sameValue(Date.UTC(2016, 6, 5, 0, 0, -1), 1467676799000, 'second: -1'); +assert.sameValue(Date.UTC(2016, 6, 5, 0, 0, 60), 1467676860000, 'second: 60'); +assert.sameValue( + Date.UTC(2016, 6, 5, 0, 0, 0, -1), 1467676799999, 'millisecond: -1' +); +assert.sameValue( + Date.UTC(2016, 6, 5, 0, 0, 0, 1000), 1467676801000, 'millisecond: 1000' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/return-value.js b/js/src/tests/test262/built-ins/Date/UTC/return-value.js new file mode 100644 index 0000000000..1564c94b55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/return-value.js @@ -0,0 +1,57 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: Return value of `Date.UTC` +info: | + 1. Let y be ? ToNumber(year). + 2. Let m be ? ToNumber(month). + 3. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + 4. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + 5. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + 6. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + 7. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +assert.sameValue(Date.UTC(1970), 0, '1970'); + +assert.sameValue(Date.UTC(1970, 0), 0, '1970, 0'); +assert.sameValue(Date.UTC(2016, 0), 1451606400000, '2016, 0'); +assert.sameValue(Date.UTC(2016, 6), 1467331200000, '2016, 6'); + +assert.sameValue(Date.UTC(2016, 6, 1), 1467331200000, '2016, 6, 1'); +assert.sameValue(Date.UTC(2016, 6, 5), 1467676800000, '2016, 6, 5'); + +assert.sameValue(Date.UTC(2016, 6, 5, 0), 1467676800000, '2016, 6, 5, 0'); +assert.sameValue(Date.UTC(2016, 6, 5, 15), 1467730800000, '2016, 6, 5, 15'); + +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 0), 1467730800000, '2016, 6, 5, 15, 0' +); +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 34), 1467732840000, '2016, 6, 5, 15, 34' +); + +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 34, 0), 1467732840000, '2016, 6, 5, 15, 34, 0' +); +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 34, 45), 1467732885000, '2016, 6, 5, 15, 34, 45' +); + + +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 34, 45, 0), + 1467732885000, + '2016, 6, 5, 15, 34, 45, 0' +); +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 34, 45, 876), + 1467732885876, + '2016, 6, 5, 15, 34, 45, 0' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/shell.js b/js/src/tests/test262/built-ins/Date/UTC/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/shell.js diff --git a/js/src/tests/test262/built-ins/Date/UTC/time-clip.js b/js/src/tests/test262/built-ins/Date/UTC/time-clip.js new file mode 100644 index 0000000000..5641b3d316 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/time-clip.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: Time clipping +info: | + [...] + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +assert.notSameValue(Date.UTC(275760, 8, 13, 0, 0, 0, 0), NaN); +assert.sameValue(Date.UTC(275760, 8, 13, 0, 0, 0, 1), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/year-offset.js b/js/src/tests/test262/built-ins/Date/UTC/year-offset.js new file mode 100644 index 0000000000..cea354ea4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/year-offset.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: Conditional offset of provided `year` value +info: | + 1. Let y be ? ToNumber(year). + [...] + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +assert.sameValue(Date.UTC(-1, 0), -62198755200000, '-1 (no offset)'); + +assert.sameValue(Date.UTC(0, 0), -2208988800000, '+0'); +assert.sameValue(Date.UTC(-0, 0), -2208988800000, '-0'); +assert.sameValue(Date.UTC(-0.999999, 0), -2208988800000, '-0.999999'); + +assert.sameValue(Date.UTC(70, 0), 0, '70'); +assert.sameValue(Date.UTC(70, 0), 0, '70.999999'); + +assert.sameValue(Date.UTC(99, 0), 915148800000, '99'); +assert.sameValue(Date.UTC(99.999999, 0), 915148800000, '99.999999'); + +assert.sameValue(Date.UTC(100, 0), -59011459200000, '100 (no offset)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/browser.js b/js/src/tests/test262/built-ins/Date/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/browser.js diff --git a/js/src/tests/test262/built-ins/Date/coercion-errors.js b/js/src/tests/test262/built-ins/Date/coercion-errors.js new file mode 100644 index 0000000000..5540298f58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/coercion-errors.js @@ -0,0 +1,66 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: Abrupt completions from coercing input values +info: | + 3. If NewTarget is not undefined, then + a. Let y be ? ToNumber(year). + b. Let m be ? ToNumber(month). + c. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + d. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + e. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + f. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + g. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + h. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); otherwise, + let yr be y. + i. Let finalDate be MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)). + j. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DatePrototype%", « [[DateValue]] »). + k. Set O.[[DateValue]] to TimeClip(UTC(finalDate)). + l. Return O. +---*/ + +var thrower = { toString: function() { throw new Test262Error(); } }; +var counter = { toString: function() { callCount += 1; } }; +var callCount = 0; + +assert.throws(Test262Error, function() { + new Date(thrower, counter); +}, 'year'); +assert.sameValue(callCount, 0, 'coercion halts following error from "year"'); + +assert.throws(Test262Error, function() { + new Date(0, thrower, counter); +}, 'month'); +assert.sameValue(callCount, 0, 'coercion halts following error from "month"'); + +assert.throws(Test262Error, function() { + new Date(0, 0, thrower, counter); +}, 'date'); +assert.sameValue(callCount, 0, 'coercion halts following error from "date"'); + +assert.throws(Test262Error, function() { + new Date(0, 0, 1, thrower, counter); +}, 'hours'); +assert.sameValue(callCount, 0, 'coercion halts following error from "hours"'); + +assert.throws(Test262Error, function() { + new Date(0, 0, 1, 0, thrower, counter); +}, 'minutes'); +assert.sameValue( + callCount, 0, 'coercion halts following error from "minutes"' +); + +assert.throws(Test262Error, function() { + new Date(0, 0, 1, 0, 0, thrower, counter); +}, 'seconds'); +assert.sameValue( + callCount, 0, 'coercion halts following error from "seconds"' +); + +assert.throws(Test262Error, function() { + new Date(0, 0, 1, 0, 0, 0, thrower); +}, 'ms'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/coercion-order.js b/js/src/tests/test262/built-ins/Date/coercion-order.js new file mode 100644 index 0000000000..7abcfe8d9d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/coercion-order.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: Order of input coercion +info: | + 3. If NewTarget is not undefined, then + a. Let y be ? ToNumber(year). + b. Let m be ? ToNumber(month). + c. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + d. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + e. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + f. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + g. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + h. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); otherwise, + let yr be y. + i. Let finalDate be MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)). + j. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DatePrototype%", « [[DateValue]] »). + k. Set O.[[DateValue]] to TimeClip(UTC(finalDate)). + l. Return O. +---*/ + +var log = ''; +var year = { toString: function() { log += 'year'; return 0; } }; +var month = { toString: function() { log += 'month'; return 0; } }; +var date = { toString: function() { log += 'date'; return 1; } }; +var hours = { toString: function() { log += 'hours'; return 0; } }; +var minutes = { toString: function() { log += 'minutes'; return 0; } }; +var seconds = { toString: function() { log += 'seconds'; return 0; } }; +var ms = { toString: function() { log += 'ms'; return 0; } }; + +new Date(year, month, date, hours,minutes, seconds, ms); + +assert.sameValue(log, 'yearmonthdatehoursminutessecondsms'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/construct_with_date.js b/js/src/tests/test262/built-ins/Date/construct_with_date.js new file mode 100644 index 0000000000..10566da476 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/construct_with_date.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date-value +description: Date constructor called with Date object +info: | + 20.3.2.2 Date ( value ) + + ... + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, then + i. Let tv be thisTimeValue(value). +es6id: 20.3.2.2 +---*/ + +var dateValue = 1438560000000; + +var oldDate = new Date(dateValue); +oldDate.toString = function() { + $ERROR("toString() method called"); +}; +oldDate.valueOf = function() { + $ERROR("valueOf() method called"); +}; + +var newDate = new Date(oldDate); + +assert.sameValue(newDate.getTime(), dateValue, "Same date value"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/is-a-constructor.js b/js/src/tests/test262/built-ins/Date/is-a-constructor.js new file mode 100644 index 0000000000..174ac0070d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/is-a-constructor.js @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + The Date constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(isConstructor(Date), true, 'isConstructor(Date) must return true'); +new Date(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/name.js b/js/src/tests/test262/built-ins/Date/name.js new file mode 100644 index 0000000000..29e869ec72 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/name.js @@ -0,0 +1,25 @@ +// Copyright (c) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-constructor +description: Constructor "name" property descriptor +info: | + 17 ECMAScript Standard Built-in Objects: + + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value is a + String. + + Unless otherwise specified, the name property of a built-in Function object, + if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.name, "Date"); + +verifyNotEnumerable(Date, "name"); +verifyNotWritable(Date, "name"); +verifyConfigurable(Date, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-1.js b/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-1.js new file mode 100644 index 0000000000..b345e3a85e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-1.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.now +description: Date.now must exist as a function +---*/ + +assert.sameValue(typeof Date.now, "function", 'typeof Date.now'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-2.js b/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-2.js new file mode 100644 index 0000000000..63799dc55a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-2.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.now +description: Date.now must exist as a function taking 0 parameters +---*/ + +assert.sameValue(Date.now.length, 0, 'Date.now.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-3.js b/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-3.js new file mode 100644 index 0000000000..8325417626 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.now +description: Date.now must exist as a function +---*/ + +var fun = Date.now; + +assert.sameValue(typeof(fun), "function", 'typeof (fun)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-4.js b/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-4.js new file mode 100644 index 0000000000..7f17a75fb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/now/15.9.4.4-0-4.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.now +description: Date.now - returns number +---*/ + +assert.sameValue(typeof Date.now(), "number", 'typeof Date.now()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/now/browser.js b/js/src/tests/test262/built-ins/Date/now/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/now/browser.js diff --git a/js/src/tests/test262/built-ins/Date/now/name.js b/js/src/tests/test262/built-ins/Date/now/name.js new file mode 100644 index 0000000000..4189f1f4e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/now/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.now +description: > + Date.now.name is "now". +info: | + Date.now ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.now.name, "now"); + +verifyNotEnumerable(Date.now, "name"); +verifyNotWritable(Date.now, "name"); +verifyConfigurable(Date.now, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/now/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/now/not-a-constructor.js new file mode 100644 index 0000000000..d6a7cf0555 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/now/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.now does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(Date.now), false, 'isConstructor(Date.now) must return false'); + +assert.throws(TypeError, () => { + new Date.now(); +}, '`new Date.now()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/now/shell.js b/js/src/tests/test262/built-ins/Date/now/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/now/shell.js diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T1.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T1.js new file mode 100644 index 0000000000..eb110ddee3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date property "parse" has { DontEnum } attributes +esid: sec-date.parse +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.parse; +if (x === 1) + Date.parse = 2; +else + Date.parse = 1; +if (Date.parse === x) { + $ERROR('#1: The Date.parse has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T2.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T2.js new file mode 100644 index 0000000000..c1e1597569 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date property "parse" has { DontEnum } attributes +esid: sec-date.parse +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.parse === false) { + $ERROR('#1: The Date.parse property has not the attributes DontDelete'); +} + +if (Date.hasOwnProperty('parse')) { + $ERROR('#2: The Date.parse property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T3.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T3.js new file mode 100644 index 0000000000..67a747d8c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date property "parse" has { DontEnum } attributes +esid: sec-date.parse +description: Checking DontEnum attribute +---*/ + +if (Date.propertyIsEnumerable('parse')) { + $ERROR('#1: The Date.parse property has the attribute DontEnum'); +} + +for (var x in Date) { + if (x === "parse") { + $ERROR('#2: The Date.parse has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A2_T1.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A2_T1.js new file mode 100644 index 0000000000..c33f7de9bf --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "parse" is 1 +esid: sec-date.parse +description: The "length" property of the "parse" is 1 +---*/ + +if (Date.parse.hasOwnProperty("length") !== true) { + $ERROR('#1: The parse has a "length" property'); +} + +if (Date.parse.length !== 1) { + $ERROR('#2: The "length" property of the parse is 1'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T1.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T1.js new file mode 100644 index 0000000000..d6d8acc734 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.parse property "length" has { ReadOnly, DontDelete, DontEnum } + attributes +esid: sec-date.parse +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.parse.length; +verifyNotWritable(Date.parse, "length", null, 1); +if (Date.parse.length !== x) { + $ERROR('#1: The Date.parse.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T2.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T2.js new file mode 100644 index 0000000000..27b3840717 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.parse property "length" has { ReadOnly, ! DontDelete, DontEnum } + attributes +esid: sec-date.parse +description: Checking DontDelete attribute +---*/ + +if (delete Date.parse.length !== true) { + $ERROR('#1: The Date.parse.length property does not have the attributes DontDelete'); +} + +if (Date.parse.hasOwnProperty('length')) { + $ERROR('#2: The Date.parse.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T3.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T3.js new file mode 100644 index 0000000000..079a42e7bf --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.parse property "length" has { ReadOnly, DontDelete, DontEnum } + attributes +esid: sec-date.parse +description: Checking DontEnum attribute +---*/ + +if (Date.parse.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.parse.length property has the attribute DontEnum'); +} + +for (var x in Date.parse) { + if (x === "length") { + $ERROR('#2: The Date.parse.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/browser.js b/js/src/tests/test262/built-ins/Date/parse/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/browser.js diff --git a/js/src/tests/test262/built-ins/Date/parse/name.js b/js/src/tests/test262/built-ins/Date/parse/name.js new file mode 100644 index 0000000000..79595c22f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.parse +description: > + Date.parse.name is "parse". +info: | + Date.parse ( string ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.parse.name, "parse"); + +verifyNotEnumerable(Date.parse, "name"); +verifyNotWritable(Date.parse, "name"); +verifyConfigurable(Date.parse, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js new file mode 100644 index 0000000000..01551a621c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.parse does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue(isConstructor(Date.parse), false, 'isConstructor(Date.parse) must return false'); + +assert.throws(TypeError, () => { + new Date.parse(); +}, '`new Date.parse()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/shell.js b/js/src/tests/test262/built-ins/Date/parse/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/shell.js diff --git a/js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js b/js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js new file mode 100644 index 0000000000..9dffe30587 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js @@ -0,0 +1,41 @@ +// Copyright (C) 2018 Andrew Paprocki. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.parse +description: > + Date.parse return value is limited to specified time value maximum range +info: | + Date.parse ( string ) + + parse interprets the resulting String as a date and time; it returns a + Number, the UTC time value corresponding to the date and time. + + A Date object contains a Number indicating a particular instant in time to + within a millisecond. Such a Number is called a time value. + + The actual range of times supported by ECMAScript Date objects is slightly + smaller: exactly -100,000,000 days to 100,000,000 days measured relative to + midnight at the beginning of 01 January, 1970 UTC. This gives a range of + 8,640,000,000,000,000 milliseconds to either side of 01 January, 1970 UTC. +---*/ + +const minDateStr = "-271821-04-20T00:00:00.000Z"; +const minDate = new Date(-8640000000000000); + +assert.sameValue(minDate.toISOString(), minDateStr, "minDateStr"); +assert.sameValue(Date.parse(minDateStr), minDate.valueOf(), "parse minDateStr"); + +const maxDateStr = "+275760-09-13T00:00:00.000Z"; +const maxDate = new Date(8640000000000000); + +assert.sameValue(maxDate.toISOString(), maxDateStr, "maxDateStr"); +assert.sameValue(Date.parse(maxDateStr), maxDate.valueOf(), "parse maxDateStr"); + +const belowRange = "-271821-04-19T23:59:59.999Z"; +const aboveRange = "+275760-09-13T00:00:00.001Z"; + +assert.sameValue(Date.parse(belowRange), NaN, "parse below minimum time value"); +assert.sameValue(Date.parse(aboveRange), NaN, "parse above maximum time value"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/without-utc-offset.js b/js/src/tests/test262/built-ins/Date/parse/without-utc-offset.js new file mode 100644 index 0000000000..dbe0fbab7c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/without-utc-offset.js @@ -0,0 +1,19 @@ +// Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.parse +description: > + Offsetless date-time strings are local time, offsetless date-only strings are UTC time +info: | + Date.parse ( string ) + + When the UTC offset representation is absent, date-only forms are interpreted + as a UTC time and date-time forms are interpreted as a local time. +---*/ + +const timezoneOffsetMS = new Date(0).getTimezoneOffset() * 60000; + +assert.sameValue(Date.parse('1970-01-01T00:00:00'), timezoneOffsetMS); +assert.sameValue(Date.parse('1970-01-01'), 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/parse/zero.js b/js/src/tests/test262/built-ins/Date/parse/zero.js new file mode 100644 index 0000000000..5e7e7c0e87 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/parse/zero.js @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Andrew Paprocki. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.parse +description: > + Date.parse of toString/toUTCString/toISOString of zero value is zero +info: | + Date.parse ( string ) + + If x is any Date object whose milliseconds amount is zero within a + particular implementation of ECMAScript, then all of the following + expressions should produce the same numeric value in that + implementation, if all the properties referenced have their initial + values: + + x.valueOf() + Date.parse(x.toString()) + Date.parse(x.toUTCString()) + Date.parse(x.toISOString()) +---*/ + +const zero = new Date(0); + +assert.sameValue(zero.valueOf(), Date.parse(zero.toString()), + "Date.parse(zeroDate.toString())"); +assert.sameValue(zero.valueOf(), Date.parse(zero.toUTCString()), + "Date.parse(zeroDate.toUTCString())"); +assert.sameValue(zero.valueOf(), Date.parse(zero.toISOString()), + "Date.parse(zeroDate.toISOString())"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prop-desc.js b/js/src/tests/test262/built-ins/Date/prop-desc.js new file mode 100644 index 0000000000..7666035e12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-date +description: Property descriptor for Date +info: | + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "Date"); +verifyWritable(this, "Date"); +verifyConfigurable(this, "Date"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/proto-from-ctor-realm-one.js b/js/src/tests/test262/built-ins/Date/proto-from-ctor-realm-one.js new file mode 100644 index 0000000000..49cfd0c3a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/proto-from-ctor-realm-one.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 3. If NewTarget is not undefined, then + [...] + c. Let O be ? OrdinaryCreateFromConstructor(NewTarget, + "%DatePrototype%", « [[DateValue]] »). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(Date, [0], C); + +assert.sameValue(Object.getPrototypeOf(o), other.Date.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/proto-from-ctor-realm-two.js b/js/src/tests/test262/built-ins/Date/proto-from-ctor-realm-two.js new file mode 100644 index 0000000000..1db84ea5f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/proto-from-ctor-realm-two.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-year-month-date-hours-minutes-seconds-ms +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 3. If NewTarget is not undefined, then + [...] + j. Let O be ? OrdinaryCreateFromConstructor(NewTarget, + "%DatePrototype%", « [[DateValue]] »). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(Date, [1970, 0], C); + +assert.sameValue(Object.getPrototypeOf(o), other.Date.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/proto-from-ctor-realm-zero.js b/js/src/tests/test262/built-ins/Date/proto-from-ctor-realm-zero.js new file mode 100644 index 0000000000..9bf495fa90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/proto-from-ctor-realm-zero.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-constructor-date +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 3. If NewTarget is not undefined, then + a. Let O be ? OrdinaryCreateFromConstructor(NewTarget, + "%DatePrototype%", « [[DateValue]] »). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(Date, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.Date.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.4.1_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.4.1_A1_T1.js new file mode 100644 index 0000000000..da70fd4568 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.4.1_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date property "prototype" has { DontEnum, DontDelete, ReadOnly } + attributes +esid: sec-date.prototype +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype; +verifyNotWritable(Date, "prototype", null, 1); +if (Date.prototype !== x) { + $ERROR('#1: The Date.prototype has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.4.1_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.4.1_A1_T2.js new file mode 100644 index 0000000000..396c3cb643 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.4.1_A1_T2.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date property "prototype" has { DontEnum, DontDelete, ReadOnly } + attributes +esid: sec-date.prototype +description: Checking DontDelete attribute +includes: [propertyHelper.js] +---*/ + +verifyNotConfigurable(Date, "prototype"); + +try { + if (delete Date.prototype !== false) { + $ERROR('#1: The Date.prototype property has the attributes DontDelete'); + } +} catch (e) { + if (e instanceof Test262Error) throw e; + assert(e instanceof TypeError); +} + +if (!Date.hasOwnProperty('prototype')) { + $ERROR('#2: The Date.prototype property has the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.4.1_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.4.1_A1_T3.js new file mode 100644 index 0000000000..c19d973fe7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.4.1_A1_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date property "prototype" has { DontEnum, DontDelete, ReadOnly } + attributes +esid: sec-date.prototype +description: Checking DontEnum attribute +---*/ + +if (Date.propertyIsEnumerable('prototype')) { + $ERROR('#1: The Date.prototype property has the attribute DontEnum'); +} + +for (var x in Date) { + if (x === "prototype") { + $ERROR('#2: The Date.prototype has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A01_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A01_T1.js new file mode 100644 index 0000000000..2399e84aba --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A01_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "constructor" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "constructor" +---*/ + +if (Date.prototype.hasOwnProperty("constructor") !== true) { + $ERROR('#1: The Date.prototype has the property "constructor"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A02_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A02_T1.js new file mode 100644 index 0000000000..d95263e754 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A02_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "toString" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "toString" +---*/ + +if (Date.prototype.hasOwnProperty("toString") !== true) { + $ERROR('#1: The Date.prototype has the property "toString"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A03_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A03_T1.js new file mode 100644 index 0000000000..304a39ad9b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A03_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "toDateString" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "toDateString" +---*/ + +if (Date.prototype.hasOwnProperty("toDateString") !== true) { + $ERROR('#1: The Date.prototype has the property "toDateString"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A04_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A04_T1.js new file mode 100644 index 0000000000..34ff1535db --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A04_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "toTimeString" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "toTimeString" +---*/ + +if (Date.prototype.hasOwnProperty("toTimeString") !== true) { + $ERROR('#1: The Date.prototype has the property "toTimeString"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A05_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A05_T1.js new file mode 100644 index 0000000000..aadf2492b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A05_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "toLocaleString" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "toLocaleString" +---*/ + +if (Date.prototype.hasOwnProperty("toLocaleString") !== true) { + $ERROR('#1: The Date.prototype has the property "toLocaleString"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A06_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A06_T1.js new file mode 100644 index 0000000000..180c03dd29 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A06_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "toLocaleDateString" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "toLocaleDateString" +---*/ + +if (Date.prototype.hasOwnProperty("toLocaleDateString") !== true) { + $ERROR('#1: The Date.prototype has the property "toLocaleDateString"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A07_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A07_T1.js new file mode 100644 index 0000000000..059f58cf46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A07_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "toLocaleTimeString" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "toLocaleTimeString" +---*/ + +if (Date.prototype.hasOwnProperty("toLocaleTimeString") !== true) { + $ERROR('#1: The Date.prototype has the property "toLocaleTimeString"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A08_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A08_T1.js new file mode 100644 index 0000000000..d7dd440f47 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A08_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "valueOf" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "valueOf" +---*/ + +if (Date.prototype.hasOwnProperty("valueOf") !== true) { + $ERROR('#1: The Date.prototype has the property "valueOf"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A09_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A09_T1.js new file mode 100644 index 0000000000..e862f819c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A09_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getTime" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getTime" +---*/ + +if (Date.prototype.hasOwnProperty("getTime") !== true) { + $ERROR('#1: The Date.prototype has the property "getTime"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A10_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A10_T1.js new file mode 100644 index 0000000000..938974aa6c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A10_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getFullYear" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getFullYear" +---*/ + +if (Date.prototype.hasOwnProperty("getFullYear") !== true) { + $ERROR('#1: The Date.prototype has the property "getFullYear"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A11_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A11_T1.js new file mode 100644 index 0000000000..fabee4f966 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A11_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getUTCFullYear" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getUTCFullYear" +---*/ + +if (Date.prototype.hasOwnProperty("getUTCFullYear") !== true) { + $ERROR('#1: The Date.prototype has the property "getUTCFullYear"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A12_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A12_T1.js new file mode 100644 index 0000000000..88df66ae4c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A12_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getMonth" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getMonth" +---*/ + +if (Date.prototype.hasOwnProperty("getMonth") !== true) { + $ERROR('#1: The Date.prototype has the property "getMonth"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A13_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A13_T1.js new file mode 100644 index 0000000000..6f6dc7348a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A13_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getUTCMonth" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getUTCMonth" +---*/ + +if (Date.prototype.hasOwnProperty("getUTCMonth") !== true) { + $ERROR('#1: The Date.prototype has the property "getUTCMonth"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A14_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A14_T1.js new file mode 100644 index 0000000000..de424bf243 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A14_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getDate" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getDate" +---*/ + +if (Date.prototype.hasOwnProperty("getDate") !== true) { + $ERROR('#1: The Date.prototype has the property "getDate"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A15_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A15_T1.js new file mode 100644 index 0000000000..d21595581a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A15_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getUTCDate" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getUTCDate" +---*/ + +if (Date.prototype.hasOwnProperty("getUTCDate") !== true) { + $ERROR('#1: The Date.prototype has the property "getUTCDate"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A16_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A16_T1.js new file mode 100644 index 0000000000..3f31a3d2ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A16_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getDay" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getDay" +---*/ + +if (Date.prototype.hasOwnProperty("getDay") !== true) { + $ERROR('#1: The Date.prototype has the property "getDay"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A17_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A17_T1.js new file mode 100644 index 0000000000..c1566ba6eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A17_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getUTCDay" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getUTCDay" +---*/ + +if (Date.prototype.hasOwnProperty("getUTCDay") !== true) { + $ERROR('#1: The Date.prototype has the property "getUTCDay"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A18_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A18_T1.js new file mode 100644 index 0000000000..be47e96356 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A18_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getHours" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getHours" +---*/ + +if (Date.prototype.hasOwnProperty("getHours") !== true) { + $ERROR('#1: The Date.prototype has the property "getHours"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A19_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A19_T1.js new file mode 100644 index 0000000000..da60962453 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A19_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getUTCHours" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getUTCHours" +---*/ + +if (Date.prototype.hasOwnProperty("getUTCHours") !== true) { + $ERROR('#1: The Date.prototype has the property "getUTCHours"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A20_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A20_T1.js new file mode 100644 index 0000000000..3790fa8c5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A20_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getMinutes" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getMinutes" +---*/ + +if (Date.prototype.hasOwnProperty("getMinutes") !== true) { + $ERROR('#1: The Date.prototype has the property "getMinutes"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A21_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A21_T1.js new file mode 100644 index 0000000000..12bae63ce4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A21_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getUTCMinutes" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getUTCMinutes" +---*/ + +if (Date.prototype.hasOwnProperty("getUTCMinutes") !== true) { + $ERROR('#1: The Date.prototype has the property "getUTCMinutes"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A22_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A22_T1.js new file mode 100644 index 0000000000..65057d4556 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A22_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getSeconds" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getSeconds" +---*/ + +if (Date.prototype.hasOwnProperty("getSeconds") !== true) { + $ERROR('#1: The Date.prototype has the property "getSeconds"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A23_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A23_T1.js new file mode 100644 index 0000000000..92b7bec3f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A23_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getUTCSeconds" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getUTCSeconds" +---*/ + +if (Date.prototype.hasOwnProperty("getUTCSeconds") !== true) { + $ERROR('#1: The Date.prototype has the property "getUTCSeconds"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A24_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A24_T1.js new file mode 100644 index 0000000000..9afa21487b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A24_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getMilliseconds" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getMilliseconds" +---*/ + +if (Date.prototype.hasOwnProperty("getMilliseconds") !== true) { + $ERROR('#1: The Date.prototype has the property "getMilliseconds"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A25_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A25_T1.js new file mode 100644 index 0000000000..1971e85fcc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A25_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getUTCMilliseconds" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getUTCMilliseconds" +---*/ + +if (Date.prototype.hasOwnProperty("getUTCMilliseconds") !== true) { + $ERROR('#1: The Date.prototype has the property "getUTCMilliseconds"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A26_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A26_T1.js new file mode 100644 index 0000000000..dfc817f6ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A26_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "getTimezoneOffset" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "getTimezoneOffset" +---*/ + +if (Date.prototype.hasOwnProperty("getTimezoneOffset") !== true) { + $ERROR('#1: The Date.prototype has the property "getTimezoneOffset"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A27_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A27_T1.js new file mode 100644 index 0000000000..d3d5188241 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A27_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setTime" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setTime" +---*/ + +if (Date.prototype.hasOwnProperty("setTime") !== true) { + $ERROR('#1: The Date.prototype has the property "setTime"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A28_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A28_T1.js new file mode 100644 index 0000000000..2a04d2491f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A28_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setMilliseconds" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setMilliseconds" +---*/ + +if (Date.prototype.hasOwnProperty("setMilliseconds") !== true) { + $ERROR('#1: The Date.prototype has the property "setMilliseconds"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A29_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A29_T1.js new file mode 100644 index 0000000000..05f1790765 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A29_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setUTCMilliseconds" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setUTCMilliseconds" +---*/ + +if (Date.prototype.hasOwnProperty("setUTCMilliseconds") !== true) { + $ERROR('#1: The Date.prototype has the property "setUTCMilliseconds"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A30_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A30_T1.js new file mode 100644 index 0000000000..f03bdb4d5e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A30_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setSeconds" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setSeconds" +---*/ + +if (Date.prototype.hasOwnProperty("setSeconds") !== true) { + $ERROR('#1: The Date.prototype has the property "setSeconds"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A31_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A31_T1.js new file mode 100644 index 0000000000..df65757b17 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A31_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setUTCSeconds" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setUTCSeconds" +---*/ + +if (Date.prototype.hasOwnProperty("setUTCSeconds") !== true) { + $ERROR('#1: The Date.prototype has the property "setUTCSeconds"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A32_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A32_T1.js new file mode 100644 index 0000000000..59839e9faf --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A32_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setMinutes" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setMinutes" +---*/ + +if (Date.prototype.hasOwnProperty("setMinutes") !== true) { + $ERROR('#1: The Date.prototype has the property "setMinutes"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A33_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A33_T1.js new file mode 100644 index 0000000000..914f85140e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A33_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setUTCMinutes" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setUTCMinutes" +---*/ + +if (Date.prototype.hasOwnProperty("setUTCMinutes") !== true) { + $ERROR('#1: The Date.prototype has the property "setUTCMinutes"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A34_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A34_T1.js new file mode 100644 index 0000000000..b3e1bf29c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A34_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setHours" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setHours" +---*/ + +if (Date.prototype.hasOwnProperty("setHours") !== true) { + $ERROR('#1: The Date.prototype has the property "setHours"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A35_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A35_T1.js new file mode 100644 index 0000000000..80a5da47d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A35_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setUTCHours" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setUTCHours" +---*/ + +if (Date.prototype.hasOwnProperty("setUTCHours") !== true) { + $ERROR('#1: The Date.prototype has the property "setUTCHours"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A36_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A36_T1.js new file mode 100644 index 0000000000..1c7663f868 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A36_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setDate" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setDate" +---*/ + +if (Date.prototype.hasOwnProperty("setDate") !== true) { + $ERROR('#1: The Date.prototype has the property "setDate"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A37_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A37_T1.js new file mode 100644 index 0000000000..dde9c1df18 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A37_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setUTCDate" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setUTCDate" +---*/ + +if (Date.prototype.hasOwnProperty("setUTCDate") !== true) { + $ERROR('#1: The Date.prototype has the property "setUTCDate"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A38_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A38_T1.js new file mode 100644 index 0000000000..96ea0d6bd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A38_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setMonth" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setMonth" +---*/ + +if (Date.prototype.hasOwnProperty("setMonth") !== true) { + $ERROR('#1: The Date.prototype has the property "setMonth"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A39_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A39_T1.js new file mode 100644 index 0000000000..68e07f2618 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A39_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setUTCMonth" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setUTCMonth" +---*/ + +if (Date.prototype.hasOwnProperty("setUTCMonth") !== true) { + $ERROR('#1: The Date.prototype has the property "setUTCMonth"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A40_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A40_T1.js new file mode 100644 index 0000000000..171266f82c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A40_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setFullYear" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setFullYear" +---*/ + +if (Date.prototype.hasOwnProperty("setFullYear") !== true) { + $ERROR('#1: The Date.prototype has the property "setFullYear"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A41_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A41_T1.js new file mode 100644 index 0000000000..da7d93b95d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A41_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "setUTCFullYear" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "setUTCFullYear" +---*/ + +if (Date.prototype.hasOwnProperty("setUTCFullYear") !== true) { + $ERROR('#1: The Date.prototype has the property "setUTCFullYear"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A42_T1.js b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A42_T1.js new file mode 100644 index 0000000000..32550ee073 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/S15.9.5_A42_T1.js @@ -0,0 +1,14 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype has the property "toUTCString" +esid: sec-properties-of-the-date-prototype-object +description: The Date.prototype has the property "toUTCString" +---*/ + +if (Date.prototype.hasOwnProperty("toUTCString") !== true) { + $ERROR('#1: The Date.prototype has the property "toUTCString"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/browser.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/called-as-function.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/called-as-function.js new file mode 100644 index 0000000000..fcdf27ee65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/called-as-function.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + `this` value is resolved using strict mode semantics, + throwing TypeError if called as top-level function. +info: | + Date.prototype [ @@toPrimitive ] ( hint ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + + ToObject ( argument ) + + Argument Type: Undefined + Result: Throw a TypeError exception. +features: [Symbol, Symbol.toPrimitive] +---*/ + +["toString", "valueOf"].forEach(function(key) { + Object.defineProperty(this, key, { + get: function() { + throw new Test262Error(key + " lookup should not be performed"); + }, + }); +}, this); + +var toPrimitive = Date.prototype[Symbol.toPrimitive]; +assert.throws(TypeError, function() { + toPrimitive("default"); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-invalid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-invalid.js new file mode 100644 index 0000000000..5d17cdd87d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-invalid.js @@ -0,0 +1,40 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "default" and first try returns an invalid value +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var voCallCount = 0; +var tsCallCount = 0; +var obj = { + valueOf: function() { + voCallCount += 1; + return 'valueOf test262'; + }, + toString: function() { + tsCallCount += 1; + return {}; + } +}; + +assert.sameValue( + Date.prototype[Symbol.toPrimitive].call(obj, 'default'), + 'valueOf test262', + '`valueOf` is used as a fallback when `toString` returns an object' +); +assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once'); +assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-non-callable.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-non-callable.js new file mode 100644 index 0000000000..16a7430b84 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-non-callable.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "default" and first try is not callable +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var voCallCount = 0; +var obj = { + valueOf: function() { + voCallCount += 1; + return 'valueOf test262'; + }, + toString: null +}; + +assert.sameValue( + Date.prototype[Symbol.toPrimitive].call(obj, 'default'), + 'valueOf test262', + '`valueOf` is used as a fallback when `toString` is not callable' +); +assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-valid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-valid.js new file mode 100644 index 0000000000..3512ecb52d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-valid.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "default" and first try returns a valid value +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var voAccessCount = 0; +var tsCallCount = 0;; +var obj = { + get valueOf() { + voAccessCount += 1; + }, + toString: function() { + tsCallCount += 1; + return 'toString test262'; + } +}; + +assert.sameValue( + Date.prototype[Symbol.toPrimitive].call(obj, 'default'), + 'toString test262' +); +assert.sameValue(voAccessCount, 0, '`valueOf` method was not referenced'); +assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-no-callables.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-no-callables.js new file mode 100644 index 0000000000..7950211228 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-no-callables.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "default" and neither first nor second try are callable. +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var obj = { + valueOf: null, + toString: null +}; + +assert.throws(TypeError, function() { + Date.prototype[Symbol.toPrimitive].call(obj, 'default'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-invalid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-invalid.js new file mode 100644 index 0000000000..243a4ef206 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-invalid.js @@ -0,0 +1,57 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: Behavior when an invalid `hint` argument is specified +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. +features: [Symbol.toPrimitive] +---*/ + +var d = new Date(); + +assert.sameValue(typeof d[Symbol.toPrimitive], 'function'); + +assert.throws(TypeError, function() { + d[Symbol.toPrimitive](); +}); + +assert.throws(TypeError, function() { + d[Symbol.toPrimitive](undefined); +}); + +assert.throws(TypeError, function() { + d[Symbol.toPrimitive](null); +}); + +assert.throws(TypeError, function() { + d[Symbol.toPrimitive](''); +}); + +assert.throws(TypeError, function() { + d[Symbol.toPrimitive]('String'); +}); + +assert.throws(TypeError, function() { + d[Symbol.toPrimitive]('defaultnumber'); +}); + +assert.throws(TypeError, function() { + d[Symbol.toPrimitive](new String('number')); +}); + +assert.throws(TypeError, function() { + d[Symbol.toPrimitive]({ + toString: function() { + 'number'; + } + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-invalid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-invalid.js new file mode 100644 index 0000000000..d151a2cbec --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-invalid.js @@ -0,0 +1,40 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "number" and first try returns an invalid value +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var voCallCount = 0; +var tsCallCount = 0; +var obj = { + valueOf: function() { + voCallCount += 1; + return {}; + }, + toString: function() { + tsCallCount += 1; + return 'toString test262'; + } +}; + +assert.sameValue( + Date.prototype[Symbol.toPrimitive].call(obj, 'number'), + 'toString test262', + '`toString` is used as a fallback when `valueOf` returns an object' +); +assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once'); +assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-non-callable.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-non-callable.js new file mode 100644 index 0000000000..a4071061e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-non-callable.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "number" and first try is not callable +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var tsCallCount = 0; +var obj = { + valueOf: null, + toString: function() { + tsCallCount += 1; + return 'toString test262'; + } +}; + +assert.sameValue( + Date.prototype[Symbol.toPrimitive].call(obj, 'number'), + 'toString test262', + '`toString` is used as a fallback when `valueOf` is not callable' +); +assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-valid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-valid.js new file mode 100644 index 0000000000..249e9e5bf9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-valid.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "number" and first try returns a valid value +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var voCallCount = 0; +var tsAccessCount = 0; +var obj = { + valueOf: function() { + voCallCount += 1; + return 'valueOf test262'; + }, + get toString() { + tsAccessCount += 1; + } +}; + +assert.sameValue( + Date.prototype[Symbol.toPrimitive].call(obj, 'number'), + 'valueOf test262' +); +assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once'); +assert.sameValue(tsAccessCount, 0, '`toString` method was not referenced'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-no-callables.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-no-callables.js new file mode 100644 index 0000000000..c2eaba27ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-no-callables.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "number" and neither first nor second try are callable. +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var obj = { + valueOf: null, + toString: null +}; + +assert.throws(TypeError, function() { + Date.prototype[Symbol.toPrimitive].call(obj, 'number'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-invalid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-invalid.js new file mode 100644 index 0000000000..714410b032 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-invalid.js @@ -0,0 +1,40 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "string" and first try returns an invalid value +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var voCallCount = 0; +var tsCallCount = 0; +var obj = { + valueOf: function() { + voCallCount += 1; + return 'valueOf test262'; + }, + toString: function() { + tsCallCount += 1; + return {}; + } +}; + +assert.sameValue( + Date.prototype[Symbol.toPrimitive].call(obj, 'string'), + 'valueOf test262', + '`valueOf` is used as a fallback when `toString` returns an object' +); +assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once'); +assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-non-callable.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-non-callable.js new file mode 100644 index 0000000000..2619af0be7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-non-callable.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "string" and first try is not callable +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var voCallCount = 0; +var obj = { + valueOf: function() { + voCallCount += 1; + return 'valueOf test262'; + }, + toString: null +}; + +assert.sameValue( + Date.prototype[Symbol.toPrimitive].call(obj, 'string'), + 'valueOf test262', + '`valueOf` is used as a fallback when `toString` is not callable' +); +assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-valid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-valid.js new file mode 100644 index 0000000000..dee4c72897 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-valid.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "string" and first try returns a valid value +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var voAccessCount = 0; +var tsCallCount = 0; +var obj = { + get valueOf() { + voAccessCount += 1; + }, + toString: function() { + tsCallCount += 1; + return 'toString test262'; + } +}; + +assert.sameValue( + Date.prototype[Symbol.toPrimitive].call(obj, 'string'), + 'toString test262' +); +assert.sameValue(voAccessCount, 0, '`valueOf` method was not referenced'); +assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-no-callables.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-no-callables.js new file mode 100644 index 0000000000..3ff8fb1bf6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-no-callables.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: > + Behavior when `hint` is "string" and neither first nor second try are callable. +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If hint is the String value "string" or the String value "default", then + a. Let tryFirst be "string". + 4. Else if hint is the String value "number", then + a. Let tryFirst be "number". + 5. Else, throw a TypeError exception. + 6. Return OrdinaryToPrimitive(O, tryFirst). +features: [Symbol.toPrimitive] +---*/ + +var obj = { + valueOf: null, + toString: null +}; + +assert.throws(TypeError, function() { + Date.prototype[Symbol.toPrimitive].call(obj, 'string'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js new file mode 100644 index 0000000000..1e46f05120 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: Date.prototype[Symbol.toPrimitive] `length` property +info: | + ES6 section 17: + + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this value + is equal to the largest number of named arguments shown in the subclause + headings for the function description, including optional parameters. + + [...] + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +features: [Symbol.toPrimitive] +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype[Symbol.toPrimitive].length, 1); + +verifyNotEnumerable(Date.prototype[Symbol.toPrimitive], 'length'); +verifyNotWritable(Date.prototype[Symbol.toPrimitive], 'length'); +verifyConfigurable(Date.prototype[Symbol.toPrimitive], 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js new file mode 100644 index 0000000000..e1e40be0fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: Date.prototype[Symbol.toPrimitive] `name` property +info: | + The value of the name property of this function is "[Symbol.toPrimitive]". + + ES6 Section 17: + + [...] + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +features: [Symbol.toPrimitive] +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Date.prototype[Symbol.toPrimitive].name, '[Symbol.toPrimitive]' +); + +verifyNotEnumerable(Date.prototype[Symbol.toPrimitive], 'name'); +verifyNotWritable(Date.prototype[Symbol.toPrimitive], 'name'); +verifyConfigurable(Date.prototype[Symbol.toPrimitive], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/prop-desc.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/prop-desc.js new file mode 100644 index 0000000000..88fa1fffc5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype-@@toprimitive +description: Date.prototype[Symbol.toPrimitive] property descriptor +info: | + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toPrimitive] +---*/ + +verifyNotEnumerable(Date.prototype, Symbol.toPrimitive); +verifyNotWritable(Date.prototype, Symbol.toPrimitive); +verifyConfigurable(Date.prototype, Symbol.toPrimitive); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/shell.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/this-val-non-obj.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/this-val-non-obj.js new file mode 100644 index 0000000000..ae8cc55b6a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/this-val-non-obj.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype-@@toprimitive +description: Behavior when `this` value is not an Object +info: | + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. +features: [Symbol.toPrimitive] +---*/ + +assert.sameValue(typeof Date.prototype[Symbol.toPrimitive], 'function'); + +assert.throws(TypeError, function() { + Date.prototype[Symbol.toPrimitive].call(undefined, 'string'); +}); + +assert.throws(TypeError, function() { + Date.prototype[Symbol.toPrimitive].call(null, 'string'); +}); + +assert.throws(TypeError, function() { + Date.prototype[Symbol.toPrimitive].call(86, 'string'); +}); + +assert.throws(TypeError, function() { + Date.prototype[Symbol.toPrimitive].call('', 'string'); +}); + +assert.throws(TypeError, function() { + Date.prototype[Symbol.toPrimitive].call(true, 'string'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/browser.js b/js/src/tests/test262/built-ins/Date/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A1_T1.js new file mode 100644 index 0000000000..3a714c1dc9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "constructor" has { DontEnum } attributes +esid: sec-date.prototype.constructor +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.constructor; +if (x === 1) + Date.prototype.constructor = 2; +else + Date.prototype.constructor = 1; +if (Date.prototype.constructor === x) { + $ERROR('#1: The Date.prototype.constructor has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A1_T2.js new file mode 100644 index 0000000000..4ab6fc7958 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "constructor" has { DontEnum } attributes +esid: sec-date.prototype.constructor +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.constructor === false) { + $ERROR('#1: The Date.prototype.constructor property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('constructor')) { + $ERROR('#2: The Date.prototype.constructor property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A1_T3.js new file mode 100644 index 0000000000..bd93eca95c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "constructor" has { DontEnum } attributes +esid: sec-date.prototype.constructor +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('constructor')) { + $ERROR('#1: The Date.prototype.constructor property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "constructor") { + $ERROR('#2: The Date.prototype.constructor has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A2_T1.js new file mode 100644 index 0000000000..06496cfd19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "constructor" is 7 +esid: sec-date.prototype.constructor +description: The "length" property of the "constructor" is 7 +---*/ + +if (Date.prototype.constructor.hasOwnProperty("length") !== true) { + $ERROR('#1: The constructor has a "length" property'); +} + +if (Date.prototype.constructor.length !== 7) { + $ERROR('#2: The "length" property of the constructor is 7'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A3_T1.js new file mode 100644 index 0000000000..e2b2424231 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.constructor property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.constructor +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.constructor.length; +verifyNotWritable(Date.prototype.constructor, "length", null, 1); +if (Date.prototype.constructor.length !== x) { + $ERROR('#1: The Date.prototype.constructor.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A3_T2.js new file mode 100644 index 0000000000..497884648f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.constructor property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.constructor +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.constructor.length !== true) { + $ERROR('#1: The Date.prototype.constructor.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.constructor.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.constructor.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A3_T3.js new file mode 100644 index 0000000000..4612afe008 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/constructor/S15.9.5.1_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.constructor property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.constructor +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.constructor.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.constructor.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.constructor) { + if (x === "length") { + $ERROR('#2: The Date.prototype.constructor.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/constructor/browser.js b/js/src/tests/test262/built-ins/Date/prototype/constructor/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/constructor/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/constructor/shell.js b/js/src/tests/test262/built-ins/Date/prototype/constructor/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/constructor/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A1_T1.js new file mode 100644 index 0000000000..5694faa808 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getDate" has { DontEnum } attributes +esid: sec-date.prototype.getdate +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getDate; +if (x === 1) + Date.prototype.getDate = 2; +else + Date.prototype.getDate = 1; +if (Date.prototype.getDate === x) { + $ERROR('#1: The Date.prototype.getDate has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A1_T2.js new file mode 100644 index 0000000000..6d66b5d816 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getDate" has { DontEnum } attributes +esid: sec-date.prototype.getdate +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getDate === false) { + $ERROR('#1: The Date.prototype.getDate property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getDate')) { + $ERROR('#2: The Date.prototype.getDate property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A1_T3.js new file mode 100644 index 0000000000..de6a3e050b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getDate" has { DontEnum } attributes +esid: sec-date.prototype.getdate +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getDate')) { + $ERROR('#1: The Date.prototype.getDate property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getDate") { + $ERROR('#2: The Date.prototype.getDate has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A2_T1.js new file mode 100644 index 0000000000..0c89b763af --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getDate" is 0 +esid: sec-date.prototype.getdate +description: The "length" property of the "getDate" is 0 +---*/ + +if (Date.prototype.getDate.hasOwnProperty("length") !== true) { + $ERROR('#1: The getDate has a "length" property'); +} + +if (Date.prototype.getDate.length !== 0) { + $ERROR('#2: The "length" property of the getDate is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A3_T1.js new file mode 100644 index 0000000000..3910d1c32d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getDate property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.getdate +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getDate.length; +verifyNotWritable(Date.prototype.getDate, "length", null, 1); +if (Date.prototype.getDate.length !== x) { + $ERROR('#1: The Date.prototype.getDate.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A3_T2.js new file mode 100644 index 0000000000..9ab8ebf349 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getDate property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getdate +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getDate.length !== true) { + $ERROR('#1: The Date.prototype.getDate.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getDate.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getDate.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A3_T3.js new file mode 100644 index 0000000000..3e3ad9a6d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/S15.9.5.14_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getDate property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.getdate +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getDate.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getDate.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getDate) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getDate.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/name.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/name.js new file mode 100644 index 0000000000..3c1574d163 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getdate +description: > + Date.prototype.getDate.name is "getDate". +info: | + Date.prototype.getDate ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getDate.name, "getDate"); + +verifyNotEnumerable(Date.prototype.getDate, "name"); +verifyNotWritable(Date.prototype.getDate, "name"); +verifyConfigurable(Date.prototype.getDate, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/not-a-constructor.js new file mode 100644 index 0000000000..675f61b753 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getDate does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getDate), + false, + 'isConstructor(Date.prototype.getDate) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getDate(); +}, '`let date = new Date(Date.now()); new date.getDate()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-invalid-date.js new file mode 100644 index 0000000000..a0e9c653da --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getdate +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getDate(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-non-date.js new file mode 100644 index 0000000000..009b25c25a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getdate +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getDate = Date.prototype.getDate; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getDate, 'function'); + +assert.throws(TypeError, function() { + getDate.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getDate.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getDate.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-non-object.js new file mode 100644 index 0000000000..5804d7d97d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getdate +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getDate = Date.prototype.getDate; +var symbol = Symbol(); + +assert.sameValue(typeof getDate, 'function'); + +assert.throws(TypeError, function() { + getDate.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getDate.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getDate.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getDate.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getDate.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getDate.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-valid-date.js new file mode 100644 index 0000000000..1f765dc15c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDate/this-value-valid-date.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getdate +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return DateFromTime(LocalTime(t)). +---*/ + +assert.sameValue(new Date(2016, 6, 6).getDate(), 6, 'first millisecond'); +assert.sameValue( + new Date(2016, 6, 6, 0, 0, 0, -1).getDate(), 5, 'previous millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 23, 59, 59, 999).getDate(), 6, 'final millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 23, 59, 59, 1000).getDate(), 7, 'subsequent millisecond' +); + +assert.sameValue( + new Date(2016, 1, 29).getDate(), 29, 'first millisecond (month boundary)' +); +assert.sameValue( + new Date(2016, 1, 29, 0, 0, 0, -1).getDate(), + 28, + 'previous millisecond (month boundary)' +); +assert.sameValue( + new Date(2016, 1, 29, 23, 59, 59, 999).getDate(), + 29, + 'final millisecond (month boundary)' +); +assert.sameValue( + new Date(2016, 1, 29, 23, 59, 59, 1000).getDate(), + 1, + 'subsequent millisecond (month boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A1_T1.js new file mode 100644 index 0000000000..9dafd24d5a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getday +info: The Date.prototype property "getDay" has { DontEnum } attributes +es5id: 15.9.5.16_A1_T1 +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getDay; +if (x === 1) + Date.prototype.getDay = 2; +else + Date.prototype.getDay = 1; +if (Date.prototype.getDay === x) { + $ERROR('#1: The Date.prototype.getDay has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A1_T2.js new file mode 100644 index 0000000000..3f6f151485 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A1_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getday +info: The Date.prototype property "getDay" has { DontEnum } attributes +es5id: 15.9.5.16_A1_T2 +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getDay === false) { + $ERROR('#1: The Date.prototype.getDay property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getDay')) { + $ERROR('#2: The Date.prototype.getDay property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A1_T3.js new file mode 100644 index 0000000000..c8fdf0dbb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A1_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getday +info: The Date.prototype property "getDay" has { DontEnum } attributes +es5id: 15.9.5.16_A1_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getDay')) { + $ERROR('#1: The Date.prototype.getDay property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getDay") { + $ERROR('#2: The Date.prototype.getDay has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A2_T1.js new file mode 100644 index 0000000000..9908863d2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A2_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getday +info: The "length" property of the "getDay" is 0 +es5id: 15.9.5.16_A2_T1 +description: The "length" property of the "getDay" is 0 +---*/ + +if (Date.prototype.getDay.hasOwnProperty("length") !== true) { + $ERROR('#1: The getDay has a "length" property'); +} + +if (Date.prototype.getDay.length !== 0) { + $ERROR('#2: The "length" property of the getDay is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A3_T1.js new file mode 100644 index 0000000000..12f9965566 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A3_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getday +info: | + The Date.prototype.getDay property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +es5id: 15.9.5.16_A3_T1 +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getDay.length; +verifyNotWritable(Date.prototype.getDay, "length", null, 1); +if (Date.prototype.getDay.length !== x) { + $ERROR('#1: The Date.prototype.getDay.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A3_T2.js new file mode 100644 index 0000000000..2948ce559e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A3_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getday +info: | + The Date.prototype.getDay property "length" has { ReadOnly, ! DontDelete, + DontEnum } attributes +es5id: 15.9.5.16_A3_T2 +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getDay.length !== true) { + $ERROR('#1: The Date.prototype.getDay.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getDay.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getDay.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A3_T3.js new file mode 100644 index 0000000000..a252ae3ed0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/S15.9.5.16_A3_T3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getday +info: | + The Date.prototype.getDay property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +es5id: 15.9.5.16_A3_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getDay.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getDay.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getDay) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getDay.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/name.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/name.js new file mode 100644 index 0000000000..89c16d7928 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getday +description: > + Date.prototype.getDay.name is "getDay". +info: | + Date.prototype.getDay ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getDay.name, "getDay"); + +verifyNotEnumerable(Date.prototype.getDay, "name"); +verifyNotWritable(Date.prototype.getDay, "name"); +verifyConfigurable(Date.prototype.getDay, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/not-a-constructor.js new file mode 100644 index 0000000000..08a25137e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getDay does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getDay), + false, + 'isConstructor(Date.prototype.getDay) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getDay(); +}, '`let date = new Date(Date.now()); new date.getDay()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-invalid-date.js new file mode 100644 index 0000000000..2040a95868 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getday +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getDay(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-non-date.js new file mode 100644 index 0000000000..a800f5cc0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getday +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getDay = Date.prototype.getDay; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getDay, 'function'); + +assert.throws(TypeError, function() { + getDay.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getDay.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getDay.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-non-object.js new file mode 100644 index 0000000000..708533f16f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getday +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getDay = Date.prototype.getDay; +var symbol = Symbol(); + +assert.sameValue(typeof getDay, 'function'); + +assert.throws(TypeError, function() { + getDay.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getDay.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getDay.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getDay.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getDay.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getDay.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-valid-date.js new file mode 100644 index 0000000000..9a792771d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getDay/this-value-valid-date.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getday +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). +---*/ + +assert.sameValue(new Date(2016, 6, 6).getDay(), 3, 'first millisecond'); +assert.sameValue( + new Date(2016, 6, 6, 0, 0, 0, -1).getDay(), 2, 'previous millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 23, 59, 59, 999).getDay(), 3, 'final millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 23, 59, 59, 1000).getDay(), 4, 'subsequent millisecond' +); + +assert.sameValue( + new Date(2016, 6, 9).getDay(), 6, 'first millisecond (week boundary)' +); +assert.sameValue( + new Date(2016, 6, 9, 0, 0, 0, -1).getDay(), + 5, + 'previous millisecond (week boundary)' +); +assert.sameValue( + new Date(2016, 6, 9, 23, 59, 59, 999).getDay(), + 6, + 'final millisecond (week boundary)' +); +assert.sameValue( + new Date(2016, 6, 9, 23, 59, 59, 1000).getDay(), + 0, + 'subsequent millisecond (week boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A1_T1.js new file mode 100644 index 0000000000..ff5a74f9e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getfullyear +info: The Date.prototype property "getFullYear" has { DontEnum } attributes +es5id: 15.9.5.10_A1_T1 +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getFullYear; +if (x === 1) + Date.prototype.getFullYear = 2; +else + Date.prototype.getFullYear = 1; +if (Date.prototype.getFullYear === x) { + $ERROR('#1: The Date.prototype.getFullYear has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A1_T2.js new file mode 100644 index 0000000000..e770947e17 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A1_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getfullyear +info: The Date.prototype property "getFullYear" has { DontEnum } attributes +es5id: 15.9.5.10_A1_T2 +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getFullYear === false) { + $ERROR('#1: The Date.prototype.getFullYear property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getFullYear')) { + $ERROR('#2: The Date.prototype.getFullYear property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A1_T3.js new file mode 100644 index 0000000000..58b1b25c90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A1_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getfullyear +info: The Date.prototype property "getFullYear" has { DontEnum } attributes +es5id: 15.9.5.10_A1_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getFullYear')) { + $ERROR('#1: The Date.prototype.getFullYear property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getFullYear") { + $ERROR('#2: The Date.prototype.getFullYear has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A2_T1.js new file mode 100644 index 0000000000..ba9592b25f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A2_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getfullyear +info: The "length" property of the "getFullYear" is 0 +es5id: 15.9.5.10_A2_T1 +description: The "length" property of the "getFullYear" is 0 +---*/ + +if (Date.prototype.getFullYear.hasOwnProperty("length") !== true) { + $ERROR('#1: The getFullYear has a "length" property'); +} + +if (Date.prototype.getFullYear.length !== 0) { + $ERROR('#2: The "length" property of the getFullYear is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A3_T1.js new file mode 100644 index 0000000000..834142c6d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A3_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getfullyear +info: | + The Date.prototype.getFullYear property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +es5id: 15.9.5.10_A3_T1 +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getFullYear.length; +verifyNotWritable(Date.prototype.getFullYear, "length", null, 1); +if (Date.prototype.getFullYear.length !== x) { + $ERROR('#1: The Date.prototype.getFullYear.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A3_T2.js new file mode 100644 index 0000000000..658645fb9f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A3_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getfullyear +info: | + The Date.prototype.getFullYear property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +es5id: 15.9.5.10_A3_T2 +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getFullYear.length !== true) { + $ERROR('#1: The Date.prototype.getFullYear.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getFullYear.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getFullYear.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A3_T3.js new file mode 100644 index 0000000000..7bf82177e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/S15.9.5.10_A3_T3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getfullyear +info: | + The Date.prototype.getFullYear property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +es5id: 15.9.5.10_A3_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getFullYear.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getFullYear.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getFullYear) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getFullYear.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/name.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/name.js new file mode 100644 index 0000000000..d6a5b8e6ce --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getfullyear +description: > + Date.prototype.getFullYear.name is "getFullYear". +info: | + Date.prototype.getFullYear ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getFullYear.name, "getFullYear"); + +verifyNotEnumerable(Date.prototype.getFullYear, "name"); +verifyNotWritable(Date.prototype.getFullYear, "name"); +verifyConfigurable(Date.prototype.getFullYear, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/not-a-constructor.js new file mode 100644 index 0000000000..917047cfdb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getFullYear does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getFullYear), + false, + 'isConstructor(Date.prototype.getFullYear) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getFullYear(); +}, '`let date = new Date(Date.now()); new date.getFullYear()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-invalid-date.js new file mode 100644 index 0000000000..3a13ff8808 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getfullyear +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getFullYear(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-non-date.js new file mode 100644 index 0000000000..acc63be044 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getfullyear +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getFullYear = Date.prototype.getFullYear; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getFullYear, 'function'); + +assert.throws(TypeError, function() { + getFullYear.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getFullYear.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getFullYear.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-non-object.js new file mode 100644 index 0000000000..6f6c50d8bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getfullyear +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getFullYear = Date.prototype.getFullYear; +var symbol = Symbol(); + +assert.sameValue(typeof getFullYear, 'function'); + +assert.throws(TypeError, function() { + getFullYear.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getFullYear.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getFullYear.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getFullYear.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getFullYear.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getFullYear.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-valid-date.js new file mode 100644 index 0000000000..d3be3f5411 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getFullYear/this-value-valid-date.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getfullyear +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return YearFromTime(LocalTime(t)). +---*/ + +assert.sameValue(new Date(2016, 0).getFullYear(), 2016, 'first millisecond'); +assert.sameValue( + new Date(2016, 0, 1, 0, 0, 0, -1).getFullYear(), 2015, 'previous millisecond' +); +assert.sameValue( + new Date(2016, 11, 31, 23, 59, 59, 999).getFullYear(), + 2016, + 'final millisecond' +); +assert.sameValue( + new Date(2016, 11, 31, 23, 59, 59, 1000).getFullYear(), + 2017, + 'subsequent millisecond' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A1_T1.js new file mode 100644 index 0000000000..ae993148bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.gethours +info: The Date.prototype property "getHours" has { DontEnum } attributes +es5id: 15.9.5.18_A1_T1 +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getHours; +if (x === 1) + Date.prototype.getHours = 2; +else + Date.prototype.getHours = 1; +if (Date.prototype.getHours === x) { + $ERROR('#1: The Date.prototype.getHours has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A1_T2.js new file mode 100644 index 0000000000..5798cfcfe1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A1_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.gethours +info: The Date.prototype property "getHours" has { DontEnum } attributes +es5id: 15.9.5.18_A1_T2 +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getHours === false) { + $ERROR('#1: The Date.prototype.getHours property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getHours')) { + $ERROR('#2: The Date.prototype.getHours property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A1_T3.js new file mode 100644 index 0000000000..0852376d3b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A1_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.gethours +info: The Date.prototype property "getHours" has { DontEnum } attributes +es5id: 15.9.5.18_A1_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getHours')) { + $ERROR('#1: The Date.prototype.getHours property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getHours") { + $ERROR('#2: The Date.prototype.getHours has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A2_T1.js new file mode 100644 index 0000000000..19fc12b9f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A2_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.gethours +info: The "length" property of the "getHours" is 0 +es5id: 15.9.5.18_A2_T1 +description: The "length" property of the "getHours" is 0 +---*/ + +if (Date.prototype.getHours.hasOwnProperty("length") !== true) { + $ERROR('#1: The getHours has a "length" property'); +} + +if (Date.prototype.getHours.length !== 0) { + $ERROR('#2: The "length" property of the getHours is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A3_T1.js new file mode 100644 index 0000000000..b60369981b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A3_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.gethours +info: | + The Date.prototype.getHours property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +es5id: 15.9.5.18_A3_T1 +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getHours.length; +verifyNotWritable(Date.prototype.getHours, "length", null, 1); +if (Date.prototype.getHours.length !== x) { + $ERROR('#1: The Date.prototype.getHours.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A3_T2.js new file mode 100644 index 0000000000..fe45bba0c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A3_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.gethours +info: | + The Date.prototype.getHours property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +es5id: 15.9.5.18_A3_T2 +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getHours.length !== true) { + $ERROR('#1: The Date.prototype.getHours.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getHours.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getHours.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A3_T3.js new file mode 100644 index 0000000000..42bd577550 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/S15.9.5.18_A3_T3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.gethours +info: | + The Date.prototype.getHours property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +es5id: 15.9.5.18_A3_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getHours.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getHours.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getHours) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getHours.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/name.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/name.js new file mode 100644 index 0000000000..b775ade1e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.gethours +description: > + Date.prototype.getHours.name is "getHours". +info: | + Date.prototype.getHours ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getHours.name, "getHours"); + +verifyNotEnumerable(Date.prototype.getHours, "name"); +verifyNotWritable(Date.prototype.getHours, "name"); +verifyConfigurable(Date.prototype.getHours, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/not-a-constructor.js new file mode 100644 index 0000000000..bdb019bbee --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getHours does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getHours), + false, + 'isConstructor(Date.prototype.getHours) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getHours(); +}, '`let date = new Date(Date.now()); new date.getHours()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-invalid-date.js new file mode 100644 index 0000000000..6d27ad3309 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gethours +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getHours(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-non-date.js new file mode 100644 index 0000000000..57ec097430 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gethours +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getHours = Date.prototype.getHours; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getHours, 'function'); + +assert.throws(TypeError, function() { + getHours.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getHours.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getHours.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-non-object.js new file mode 100644 index 0000000000..772af36457 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gethours +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getHours = Date.prototype.getHours; +var symbol = Symbol(); + +assert.sameValue(typeof getHours, 'function'); + +assert.throws(TypeError, function() { + getHours.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getHours.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getHours.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getHours.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getHours.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getHours.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-valid-date.js new file mode 100644 index 0000000000..105e1434b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getHours/this-value-valid-date.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gethours +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return HourFromTime(LocalTime(t)). +---*/ + +assert.sameValue(new Date(2016, 6, 6, 13).getHours(), 13, 'first millisecond'); +assert.sameValue( + new Date(2016, 6, 6, 13, 0, 0, -1).getHours(), 12, 'previous millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 13, 59, 59, 999).getHours(), + 13, + 'final millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 13, 59, 59, 1000).getHours(), + 14, + 'subsequent millisecond' +); + +assert.sameValue( + new Date(2016, 6, 6, 23).getHours(), 23, 'first millisecond (hour boundary)' +); +assert.sameValue( + new Date(2016, 6, 6, 23, 0, 0, -1).getHours(), + 22, + 'previous millisecond (hour boundary)' +); +assert.sameValue( + new Date(2016, 6, 6, 23, 59, 59, 999).getHours(), + 23, + 'final millisecond (hour boundary)' +); +assert.sameValue( + new Date(2016, 6, 6, 23, 59, 59, 1000).getHours(), + 0, + 'subsequent millisecond (hour boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A1_T1.js new file mode 100644 index 0000000000..7876c2047e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getmilliseconds +info: The Date.prototype property "getMilliseconds" has { DontEnum } attributes +es5id: 15.9.5.24_A1_T1 +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getMilliseconds; +if (x === 1) + Date.prototype.getMilliseconds = 2; +else + Date.prototype.getMilliseconds = 1; +if (Date.prototype.getMilliseconds === x) { + $ERROR('#1: The Date.prototype.getMilliseconds has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A1_T2.js new file mode 100644 index 0000000000..c64defae88 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A1_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getmilliseconds +info: The Date.prototype property "getMilliseconds" has { DontEnum } attributes +es5id: 15.9.5.24_A1_T2 +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getMilliseconds === false) { + $ERROR('#1: The Date.prototype.getMilliseconds property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getMilliseconds')) { + $ERROR('#2: The Date.prototype.getMilliseconds property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A1_T3.js new file mode 100644 index 0000000000..e36daef576 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A1_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getmilliseconds +info: The Date.prototype property "getMilliseconds" has { DontEnum } attributes +es5id: 15.9.5.24_A1_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getMilliseconds')) { + $ERROR('#1: The Date.prototype.getMilliseconds property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getMilliseconds") { + $ERROR('#2: The Date.prototype.getMilliseconds has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A2_T1.js new file mode 100644 index 0000000000..52f791208b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A2_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getmilliseconds +info: The "length" property of the "getMilliseconds" is 0 +es5id: 15.9.5.24_A2_T1 +description: The "length" property of the "getMilliseconds" is 0 +---*/ + +if (Date.prototype.getMilliseconds.hasOwnProperty("length") !== true) { + $ERROR('#1: The getMilliseconds has a "length" property'); +} + +if (Date.prototype.getMilliseconds.length !== 0) { + $ERROR('#2: The "length" property of the getMilliseconds is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A3_T1.js new file mode 100644 index 0000000000..22686dfafb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A3_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getmilliseconds +info: | + The Date.prototype.getMilliseconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +es5id: 15.9.5.24_A3_T1 +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getMilliseconds.length; +verifyNotWritable(Date.prototype.getMilliseconds, "length", null, 1); +if (Date.prototype.getMilliseconds.length !== x) { + $ERROR('#1: The Date.prototype.getMilliseconds.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A3_T2.js new file mode 100644 index 0000000000..318ccfb122 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A3_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getmilliseconds +info: | + The Date.prototype.getMilliseconds property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +es5id: 15.9.5.24_A3_T2 +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getMilliseconds.length !== true) { + $ERROR('#1: The Date.prototype.getMilliseconds.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getMilliseconds.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getMilliseconds.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A3_T3.js new file mode 100644 index 0000000000..9ce2005087 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/S15.9.5.24_A3_T3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getmilliseconds +info: | + The Date.prototype.getMilliseconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +es5id: 15.9.5.24_A3_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getMilliseconds.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getMilliseconds.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getMilliseconds) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getMilliseconds.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/name.js new file mode 100644 index 0000000000..0845a2c619 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getmilliseconds +description: > + Date.prototype.getMilliseconds.name is "getMilliseconds". +info: | + Date.prototype.getMilliseconds ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getMilliseconds.name, "getMilliseconds"); + +verifyNotEnumerable(Date.prototype.getMilliseconds, "name"); +verifyNotWritable(Date.prototype.getMilliseconds, "name"); +verifyConfigurable(Date.prototype.getMilliseconds, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/not-a-constructor.js new file mode 100644 index 0000000000..4682cd3c1e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getMilliseconds does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getMilliseconds), + false, + 'isConstructor(Date.prototype.getMilliseconds) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getMilliseconds(); +}, '`let date = new Date(Date.now()); new date.getMilliseconds()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-invalid-date.js new file mode 100644 index 0000000000..9f01a58c9a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getmilliseconds +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getMilliseconds(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-non-date.js new file mode 100644 index 0000000000..369b0e0e0f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getmilliseconds +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getMilliseconds = Date.prototype.getMilliseconds; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getMilliseconds, 'function'); + +assert.throws(TypeError, function() { + getMilliseconds.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getMilliseconds.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getMilliseconds.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-non-object.js new file mode 100644 index 0000000000..e61eeb017f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getmilliseconds +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getMilliseconds = Date.prototype.getMilliseconds; +var symbol = Symbol(); + +assert.sameValue(typeof getMilliseconds, 'function'); + +assert.throws(TypeError, function() { + getMilliseconds.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getMilliseconds.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getMilliseconds.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getMilliseconds.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getMilliseconds.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getMilliseconds.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-valid-date.js new file mode 100644 index 0000000000..c5ffe86664 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMilliseconds/this-value-valid-date.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getmilliseconds +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return msFromTime(LocalTime(t)). +---*/ + +assert.sameValue( + new Date(2016, 6, 6).getMilliseconds(), 0, 'first millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 0, 0, 0, -1).getMilliseconds(), + 999, + 'previous millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 23, 59, 59, 999).getMilliseconds(), + 999, + 'final millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 23, 59, 59, 1000).getMilliseconds(), + 0, + 'subsequent millisecond' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A1_T1.js new file mode 100644 index 0000000000..e27e40c081 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getminutes +info: The Date.prototype property "getMinutes" has { DontEnum } attributes +es5id: 15.9.5.20_A1_T1 +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getMinutes; +if (x === 1) + Date.prototype.getMinutes = 2; +else + Date.prototype.getMinutes = 1; +if (Date.prototype.getMinutes === x) { + $ERROR('#1: The Date.prototype.getMinutes has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A1_T2.js new file mode 100644 index 0000000000..dd4e6752de --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A1_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getminutes +info: The Date.prototype property "getMinutes" has { DontEnum } attributes +es5id: 15.9.5.20_A1_T2 +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getMinutes === false) { + $ERROR('#1: The Date.prototype.getMinutes property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getMinutes')) { + $ERROR('#2: The Date.prototype.getMinutes property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A1_T3.js new file mode 100644 index 0000000000..c2b7a02396 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A1_T3.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getminutes +info: The Date.prototype property "getMinutes" has { DontEnum } attributes +es5id: 15.9.5.20_A1_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getMinutes')) { + $ERROR('#1: The Date.prototype.getMinutes property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getMinutes") { + $ERROR('#2: The Date.prototype.getMinutes has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A2_T1.js new file mode 100644 index 0000000000..428c76fed8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A2_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getminutes +info: The "length" property of the "getMinutes" is 0 +es5id: 15.9.5.20_A2_T1 +description: The "length" property of the "getMinutes" is 0 +---*/ + +if (Date.prototype.getMinutes.hasOwnProperty("length") !== true) { + $ERROR('#1: The getMinutes has a "length" property'); +} + +if (Date.prototype.getMinutes.length !== 0) { + $ERROR('#2: The "length" property of the getMinutes is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A3_T1.js new file mode 100644 index 0000000000..fea3ec719e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A3_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getminutes +info: | + The Date.prototype.getMinutes property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +es5id: 15.9.5.20_A3_T1 +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getMinutes.length; +verifyNotWritable(Date.prototype.getMinutes, "length", null, 1); +if (Date.prototype.getMinutes.length !== x) { + $ERROR('#1: The Date.prototype.getMinutes.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A3_T2.js new file mode 100644 index 0000000000..bf248c9ffb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A3_T2.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getminutes +info: | + The Date.prototype.getMinutes property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +es5id: 15.9.5.20_A3_T2 +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getMinutes.length !== true) { + $ERROR('#1: The Date.prototype.getMinutes.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getMinutes.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getMinutes.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A3_T3.js new file mode 100644 index 0000000000..ec3667141f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/S15.9.5.20_A3_T3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getminutes +info: | + The Date.prototype.getMinutes property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +es5id: 15.9.5.20_A3_T3 +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getMinutes.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getMinutes.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getMinutes) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getMinutes.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/name.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/name.js new file mode 100644 index 0000000000..e1d71363bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getminutes +description: > + Date.prototype.getMinutes.name is "getMinutes". +info: | + Date.prototype.getMinutes ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getMinutes.name, "getMinutes"); + +verifyNotEnumerable(Date.prototype.getMinutes, "name"); +verifyNotWritable(Date.prototype.getMinutes, "name"); +verifyConfigurable(Date.prototype.getMinutes, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/not-a-constructor.js new file mode 100644 index 0000000000..21682d79fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getMinutes does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getMinutes), + false, + 'isConstructor(Date.prototype.getMinutes) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getMinutes(); +}, '`let date = new Date(Date.now()); new date.getMinutes()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-invalid-date.js new file mode 100644 index 0000000000..ac7436d8fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getminutes +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getMinutes(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-non-date.js new file mode 100644 index 0000000000..879db67716 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getminutes +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getMinutes = Date.prototype.getMinutes; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getMinutes, 'function'); + +assert.throws(TypeError, function() { + getMinutes.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getMinutes.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getMinutes.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-non-object.js new file mode 100644 index 0000000000..606152bf68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getminutes +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getMinutes = Date.prototype.getMinutes; +var symbol = Symbol(); + +assert.sameValue(typeof getMinutes, 'function'); + +assert.throws(TypeError, function() { + getMinutes.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getMinutes.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getMinutes.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getMinutes.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getMinutes.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getMinutes.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-valid-date.js new file mode 100644 index 0000000000..ded979d03c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMinutes/this-value-valid-date.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getminutes +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return MinFromTime(LocalTime(t)). +---*/ + +assert.sameValue(new Date(2016, 6, 6, 14, 6).getMinutes(), 6, 'first millisecond'); +assert.sameValue( + new Date(2016, 6, 6, 14, 6, 0, -1).getMinutes(), 5, 'previous millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 6, 59, 999).getMinutes(), 6, 'final millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 6, 59, 1000).getMinutes(), 7, 'subsequent millisecond' +); + +assert.sameValue( + new Date(2016, 6, 6, 14, 59).getMinutes(), 59, 'first millisecond (hour boundary)' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 59, 0, -1).getMinutes(), + 58, + 'previous millisecond (hour boundary)' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 59, 59, 999).getMinutes(), + 59, + 'final millisecond (hour boundary)' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 59, 59, 1000).getMinutes(), + 0, + 'subsequent millisecond (hour boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A1_T1.js new file mode 100644 index 0000000000..a5f35cc1a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getMonth" has { DontEnum } attributes +esid: sec-date.prototype.getmonth +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getMonth; +if (x === 1) + Date.prototype.getMonth = 2; +else + Date.prototype.getMonth = 1; +if (Date.prototype.getMonth === x) { + $ERROR('#1: The Date.prototype.getMonth has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A1_T2.js new file mode 100644 index 0000000000..0971233ae9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getMonth" has { DontEnum } attributes +esid: sec-date.prototype.getmonth +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getMonth === false) { + $ERROR('#1: The Date.prototype.getMonth property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getMonth')) { + $ERROR('#2: The Date.prototype.getMonth property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A1_T3.js new file mode 100644 index 0000000000..95f6897389 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getMonth" has { DontEnum } attributes +esid: sec-date.prototype.getmonth +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getMonth')) { + $ERROR('#1: The Date.prototype.getMonth property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getMonth") { + $ERROR('#2: The Date.prototype.getMonth has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A2_T1.js new file mode 100644 index 0000000000..790822e564 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getMonth" is 0 +esid: sec-date.prototype.getmonth +description: The "length" property of the "getMonth" is 0 +---*/ + +if (Date.prototype.getMonth.hasOwnProperty("length") !== true) { + $ERROR('#1: The getMonth has a "length" property'); +} + +if (Date.prototype.getMonth.length !== 0) { + $ERROR('#2: The "length" property of the getMonth is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A3_T1.js new file mode 100644 index 0000000000..75d6f20800 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getMonth property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.getmonth +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getMonth.length; +verifyNotWritable(Date.prototype.getMonth, "length", null, 1); +if (Date.prototype.getMonth.length !== x) { + $ERROR('#1: The Date.prototype.getMonth.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A3_T2.js new file mode 100644 index 0000000000..9f19c43303 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getMonth property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getmonth +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getMonth.length !== true) { + $ERROR('#1: The Date.prototype.getMonth.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getMonth.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getMonth.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A3_T3.js new file mode 100644 index 0000000000..40665d01a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/S15.9.5.12_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getMonth property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.getmonth +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getMonth.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getMonth.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getMonth) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getMonth.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/name.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/name.js new file mode 100644 index 0000000000..7071c3d694 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getmonth +description: > + Date.prototype.getMonth.name is "getMonth". +info: | + Date.prototype.getMonth ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getMonth.name, "getMonth"); + +verifyNotEnumerable(Date.prototype.getMonth, "name"); +verifyNotWritable(Date.prototype.getMonth, "name"); +verifyConfigurable(Date.prototype.getMonth, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/not-a-constructor.js new file mode 100644 index 0000000000..53c9ac0819 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getMonth does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getMonth), + false, + 'isConstructor(Date.prototype.getMonth) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getMonth(); +}, '`let date = new Date(Date.now()); new date.getMonth()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-invalid-date.js new file mode 100644 index 0000000000..0e7b5b9f4b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getmonth +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getMonth(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-non-date.js new file mode 100644 index 0000000000..6686d8c9e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getmonth +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getMonth = Date.prototype.getMonth; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getMonth, 'function'); + +assert.throws(TypeError, function() { + getMonth.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getMonth.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getMonth.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-non-object.js new file mode 100644 index 0000000000..40b1779930 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getmonth +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getMonth = Date.prototype.getMonth; +var symbol = Symbol(); + +assert.sameValue(typeof getMonth, 'function'); + +assert.throws(TypeError, function() { + getMonth.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getMonth.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getMonth.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getMonth.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getMonth.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getMonth.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-valid-date.js new file mode 100644 index 0000000000..ec29f27910 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getMonth/this-value-valid-date.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getmonth +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return MonthFromTime(LocalTime(t)). +---*/ + +assert.sameValue(new Date(2016, 6).getMonth(), 6, 'first millisecond'); +assert.sameValue( + new Date(2016, 6, 0, 0, 0, 0, -1).getMonth(), 5, 'previous millisecond' +); +assert.sameValue( + new Date(2016, 6, 31, 23, 59, 59, 999).getMonth(), 6, 'final millisecond' +); +assert.sameValue( + new Date(2016, 6, 31, 23, 59, 59, 1000).getMonth(), 7, 'subsequent millisecond' +); + +assert.sameValue( + new Date(2016, 11, 31).getMonth(), 11, 'first millisecond (year boundary)' +); +assert.sameValue( + new Date(2016, 11, 0, 0, 0, 0, -1).getMonth(), + 10, + 'previous millisecond (year boundary)' +); +assert.sameValue( + new Date(2016, 11, 31, 23, 59, 59, 999).getMonth(), + 11, + 'final millisecond (year boundary)' +); +assert.sameValue( + new Date(2016, 11, 31, 23, 59, 59, 1000).getMonth(), + 0, + 'subsequent millisecond (year boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A1_T1.js new file mode 100644 index 0000000000..c6ef070cce --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getSeconds" has { DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getSeconds; +if (x === 1) + Date.prototype.getSeconds = 2; +else + Date.prototype.getSeconds = 1; +if (Date.prototype.getSeconds === x) { + $ERROR('#1: The Date.prototype.getSeconds has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A1_T2.js new file mode 100644 index 0000000000..a0fff0fa42 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getSeconds" has { DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getSeconds === false) { + $ERROR('#1: The Date.prototype.getSeconds property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getSeconds')) { + $ERROR('#2: The Date.prototype.getSeconds property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A1_T3.js new file mode 100644 index 0000000000..ad33204d44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getSeconds" has { DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getSeconds')) { + $ERROR('#1: The Date.prototype.getSeconds property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getSeconds") { + $ERROR('#2: The Date.prototype.getSeconds has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A2_T1.js new file mode 100644 index 0000000000..fcec8d4c15 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getSeconds" is 0 +esid: sec-date.prototype.getseconds +description: The "length" property of the "getSeconds" is 0 +---*/ + +if (Date.prototype.getSeconds.hasOwnProperty("length") !== true) { + $ERROR('#1: The getSeconds has a "length" property'); +} + +if (Date.prototype.getSeconds.length !== 0) { + $ERROR('#2: The "length" property of the getSeconds is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A3_T1.js new file mode 100644 index 0000000000..1fd7a8cf46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getSeconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getSeconds.length; +verifyNotWritable(Date.prototype.getSeconds, "length", null, 1); +if (Date.prototype.getSeconds.length !== x) { + $ERROR('#1: The Date.prototype.getSeconds.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A3_T2.js new file mode 100644 index 0000000000..fc7fb6e9ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getSeconds property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getSeconds.length !== true) { + $ERROR('#1: The Date.prototype.getSeconds.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getSeconds.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getSeconds.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A3_T3.js new file mode 100644 index 0000000000..0d33e99edb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/S15.9.5.22_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getSeconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getSeconds.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getSeconds.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getSeconds) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getSeconds.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/name.js new file mode 100644 index 0000000000..56d30ef47f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getseconds +description: > + Date.prototype.getSeconds.name is "getSeconds". +info: | + Date.prototype.getSeconds ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getSeconds.name, "getSeconds"); + +verifyNotEnumerable(Date.prototype.getSeconds, "name"); +verifyNotWritable(Date.prototype.getSeconds, "name"); +verifyConfigurable(Date.prototype.getSeconds, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/not-a-constructor.js new file mode 100644 index 0000000000..cae3edd42d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getSeconds does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getSeconds), + false, + 'isConstructor(Date.prototype.getSeconds) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getSeconds(); +}, '`let date = new Date(Date.now()); new date.getSeconds()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-invalid-date.js new file mode 100644 index 0000000000..6446cd025c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getseconds +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getSeconds(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-non-date.js new file mode 100644 index 0000000000..f3931afe03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getseconds +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getSeconds = Date.prototype.getSeconds; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getSeconds, 'function'); + +assert.throws(TypeError, function() { + getSeconds.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getSeconds.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getSeconds.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-non-object.js new file mode 100644 index 0000000000..cc754be716 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getseconds +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getSeconds = Date.prototype.getSeconds; +var symbol = Symbol(); + +assert.sameValue(typeof getSeconds, 'function'); + +assert.throws(TypeError, function() { + getSeconds.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getSeconds.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getSeconds.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getSeconds.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getSeconds.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getSeconds.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-valid-date.js new file mode 100644 index 0000000000..3bddccc6c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getSeconds/this-value-valid-date.js @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getseconds +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return SecFromTime(LocalTime(t)). +---*/ + +assert.sameValue( + new Date(2016, 6, 6, 14, 16, 30).getSeconds(), + 30, + 'first millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 16, 30, -1).getSeconds(), 29, 'previous millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 16, 30, 999).getSeconds(), 30, 'final millisecond' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 16, 30, 1000).getSeconds(), + 31, + 'subsequent millisecond' +); + +assert.sameValue( + new Date(2016, 6, 6, 14, 16, 59).getSeconds(), + 59, + 'first millisecond (minute boundary)' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 16, 59, -1).getSeconds(), + 58, + 'previous millisecond (minute boundary)' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 16, 59, 999).getSeconds(), + 59, + 'final millisecond (minute boundary)' +); +assert.sameValue( + new Date(2016, 6, 6, 14, 16, 59, 1000).getSeconds(), + 0, + 'subsequent millisecond (minute boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A1_T1.js new file mode 100644 index 0000000000..5146bead9c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getTime" has { DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getTime; +if (x === 1) + Date.prototype.getTime = 2; +else + Date.prototype.getTime = 1; +if (Date.prototype.getTime === x) { + $ERROR('#1: The Date.prototype.getTime has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A1_T2.js new file mode 100644 index 0000000000..ce1957f37e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getTime" has { DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getTime === false) { + $ERROR('#1: The Date.prototype.getTime property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getTime')) { + $ERROR('#2: The Date.prototype.getTime property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A1_T3.js new file mode 100644 index 0000000000..c791b94bcc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getTime" has { DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getTime')) { + $ERROR('#1: The Date.prototype.getTime property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getTime") { + $ERROR('#2: The Date.prototype.getTime has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A2_T1.js new file mode 100644 index 0000000000..288147c3d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getTime" is 0 +esid: sec-date.prototype.getseconds +description: The "length" property of the "getTime" is 0 +---*/ + +if (Date.prototype.getTime.hasOwnProperty("length") !== true) { + $ERROR('#1: The getTime has a "length" property'); +} + +if (Date.prototype.getTime.length !== 0) { + $ERROR('#2: The "length" property of the getTime is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A3_T1.js new file mode 100644 index 0000000000..7c9ce76874 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getTime property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getTime.length; +verifyNotWritable(Date.prototype.getTime, "length", null, 1); +if (Date.prototype.getTime.length !== x) { + $ERROR('#1: The Date.prototype.getTime.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A3_T2.js new file mode 100644 index 0000000000..8f177ecf1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getTime property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getTime.length !== true) { + $ERROR('#1: The Date.prototype.getTime.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getTime.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getTime.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A3_T3.js new file mode 100644 index 0000000000..52db1a65d3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/S15.9.5.9_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getTime property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.getseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getTime.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getTime.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getTime) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getTime.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/name.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/name.js new file mode 100644 index 0000000000..3c05eb5508 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getseconds +description: > + Date.prototype.getTime.name is "getTime". +info: | + Date.prototype.getTime ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getTime.name, "getTime"); + +verifyNotEnumerable(Date.prototype.getTime, "name"); +verifyNotWritable(Date.prototype.getTime, "name"); +verifyConfigurable(Date.prototype.getTime, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/not-a-constructor.js new file mode 100644 index 0000000000..31e56a6eb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getTime does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getTime), + false, + 'isConstructor(Date.prototype.getTime) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getTime(); +}, '`let date = new Date(Date.now()); new date.getTime()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-invalid-date.js new file mode 100644 index 0000000000..a86c5a17e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-invalid-date.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gettime +description: Return value for invalid date +info: | + 1. Return ? thisTimeValue(this value). +---*/ + +assert.sameValue(new Date(NaN).getTime(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-non-date.js new file mode 100644 index 0000000000..408bd99cd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gettime +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Return ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getTime = Date.prototype.getTime; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getTime, 'function'); + +assert.throws(TypeError, function() { + getTime.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getTime.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getTime.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-non-object.js new file mode 100644 index 0000000000..8c39bcf37d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gettime +description: Behavior when "this" value is not an Object +info: | + 1. Return ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getTime = Date.prototype.getTime; +var symbol = Symbol(); + +assert.sameValue(typeof getTime, 'function'); + +assert.throws(TypeError, function() { + getTime.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getTime.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getTime.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getTime.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getTime.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getTime.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-valid-date.js new file mode 100644 index 0000000000..a72cb3adb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTime/this-value-valid-date.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gettime +description: Return value for valid dates +info: | + 1. Return ? thisTimeValue(this value). +---*/ + +assert.sameValue(new Date(0).getTime(), 0, '+0'); +assert.sameValue(new Date(-0).getTime(), 0, '-0'); +assert.sameValue(new Date(-1).getTime(), -1); +assert.sameValue(new Date(1).getTime(), 1); +assert.sameValue(new Date(8640000000000000).getTime(), 8640000000000000); +assert.sameValue(new Date(-8640000000000000).getTime(), -8640000000000000); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A1_T1.js new file mode 100644 index 0000000000..d4d50f5459 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A1_T1.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "getTimezoneOffset" has { DontEnum } + attributes +esid: sec-date.prototype.gettimezoneoffset +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getTimezoneOffset; +if (x === 1) + Date.prototype.getTimezoneOffset = 2; +else + Date.prototype.getTimezoneOffset = 1; +if (Date.prototype.getTimezoneOffset === x) { + $ERROR('#1: The Date.prototype.getTimezoneOffset has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A1_T2.js new file mode 100644 index 0000000000..c7460629d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A1_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "getTimezoneOffset" has { DontEnum } + attributes +esid: sec-date.prototype.gettimezoneoffset +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getTimezoneOffset === false) { + $ERROR('#1: The Date.prototype.getTimezoneOffset property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getTimezoneOffset')) { + $ERROR('#2: The Date.prototype.getTimezoneOffset property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A1_T3.js new file mode 100644 index 0000000000..5d23be33e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A1_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "getTimezoneOffset" has { DontEnum } + attributes +esid: sec-date.prototype.gettimezoneoffset +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getTimezoneOffset')) { + $ERROR('#1: The Date.prototype.getTimezoneOffset property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getTimezoneOffset") { + $ERROR('#2: The Date.prototype.getTimezoneOffset has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A2_T1.js new file mode 100644 index 0000000000..956ca3b272 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getTimezoneOffset" is 0 +esid: sec-date.prototype.gettimezoneoffset +description: The "length" property of the "getTimezoneOffset" is 0 +---*/ + +if (Date.prototype.getTimezoneOffset.hasOwnProperty("length") !== true) { + $ERROR('#1: The getTimezoneOffset has a "length" property'); +} + +if (Date.prototype.getTimezoneOffset.length !== 0) { + $ERROR('#2: The "length" property of the getTimezoneOffset is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A3_T1.js new file mode 100644 index 0000000000..5ed73c74a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getTimezoneOffset property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.gettimezoneoffset +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getTimezoneOffset.length; +verifyNotWritable(Date.prototype.getTimezoneOffset, "length", null, 1); +if (Date.prototype.getTimezoneOffset.length !== x) { + $ERROR('#1: The Date.prototype.getTimezoneOffset.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A3_T2.js new file mode 100644 index 0000000000..7df3873cb6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getTimezoneOffset property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.gettimezoneoffset +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getTimezoneOffset.length !== true) { + $ERROR('#1: The Date.prototype.getTimezoneOffset.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getTimezoneOffset.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getTimezoneOffset.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A3_T3.js new file mode 100644 index 0000000000..1332fe470f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/S15.9.5.26_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getTimezoneOffset property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.gettimezoneoffset +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getTimezoneOffset.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getTimezoneOffset.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getTimezoneOffset) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getTimezoneOffset.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/name.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/name.js new file mode 100644 index 0000000000..0fe3e7046d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.gettimezoneoffset +description: > + Date.prototype.getTimezoneOffset.name is "getTimezoneOffset". +info: | + Date.prototype.getTimezoneOffset ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getTimezoneOffset.name, "getTimezoneOffset"); + +verifyNotEnumerable(Date.prototype.getTimezoneOffset, "name"); +verifyNotWritable(Date.prototype.getTimezoneOffset, "name"); +verifyConfigurable(Date.prototype.getTimezoneOffset, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/not-a-constructor.js new file mode 100644 index 0000000000..cd1dcd6992 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getTimezoneOffset does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getTimezoneOffset), + false, + 'isConstructor(Date.prototype.getTimezoneOffset) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getTimezoneOffset(); +}, '`let date = new Date(Date.now()); new date.getTimezoneOffset()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-invalid-date.js new file mode 100644 index 0000000000..d9f7baa4a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gettimezoneoffset +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getTimezoneOffset(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-non-date.js new file mode 100644 index 0000000000..70b8230839 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gettimezoneoffset +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getTimezoneOffset = Date.prototype.getTimezoneOffset; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getTimezoneOffset, 'function'); + +assert.throws(TypeError, function() { + getTimezoneOffset.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getTimezoneOffset.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getTimezoneOffset.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-non-object.js new file mode 100644 index 0000000000..ef9245450d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gettimezoneoffset +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getTimezoneOffset = Date.prototype.getTimezoneOffset; +var symbol = Symbol(); + +assert.sameValue(typeof getTimezoneOffset, 'function'); + +assert.throws(TypeError, function() { + getTimezoneOffset.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getTimezoneOffset.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getTimezoneOffset.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getTimezoneOffset.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getTimezoneOffset.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getTimezoneOffset.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-valid-date.js new file mode 100644 index 0000000000..bf141b1038 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getTimezoneOffset/this-value-valid-date.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.gettimezoneoffset +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. +---*/ + +assert.sameValue( + typeof new Date(0).getTimezoneOffset(), 'number', 'Unix epoch' +); + +assert.sameValue( + typeof new Date(8640000000000000).getTimezoneOffset(), + 'number', + 'latest representable time' +); + +assert.sameValue( + typeof new Date(-8640000000000000).getTimezoneOffset(), + 'number', + 'earliest representable time' +); + +assert.sameValue( + typeof new Date().getTimezoneOffset(), 'number', 'current time' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A1_T1.js new file mode 100644 index 0000000000..b981f876a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCDate" has { DontEnum } attributes +esid: sec-date.prototype.getutcdate +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getUTCDate; +if (x === 1) + Date.prototype.getUTCDate = 2; +else + Date.prototype.getUTCDate = 1; +if (Date.prototype.getUTCDate === x) { + $ERROR('#1: The Date.prototype.getUTCDate has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A1_T2.js new file mode 100644 index 0000000000..c8131d2c0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCDate" has { DontEnum } attributes +esid: sec-date.prototype.getutcdate +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCDate === false) { + $ERROR('#1: The Date.prototype.getUTCDate property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getUTCDate')) { + $ERROR('#2: The Date.prototype.getUTCDate property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A1_T3.js new file mode 100644 index 0000000000..c1e2b06f00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCDate" has { DontEnum } attributes +esid: sec-date.prototype.getutcdate +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getUTCDate')) { + $ERROR('#1: The Date.prototype.getUTCDate property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getUTCDate") { + $ERROR('#2: The Date.prototype.getUTCDate has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A2_T1.js new file mode 100644 index 0000000000..69f0b82962 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getUTCDate" is 0 +esid: sec-date.prototype.getutcdate +description: The "length" property of the "getUTCDate" is 0 +---*/ + +if (Date.prototype.getUTCDate.hasOwnProperty("length") !== true) { + $ERROR('#1: The getUTCDate has a "length" property'); +} + +if (Date.prototype.getUTCDate.length !== 0) { + $ERROR('#2: The "length" property of the getUTCDate is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A3_T1.js new file mode 100644 index 0000000000..378113fdc9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCDate property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcdate +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getUTCDate.length; +verifyNotWritable(Date.prototype.getUTCDate, "length", null, 1); +if (Date.prototype.getUTCDate.length !== x) { + $ERROR('#1: The Date.prototype.getUTCDate.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A3_T2.js new file mode 100644 index 0000000000..9301543936 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCDate property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcdate +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCDate.length !== true) { + $ERROR('#1: The Date.prototype.getUTCDate.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getUTCDate.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getUTCDate.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A3_T3.js new file mode 100644 index 0000000000..4c8b733659 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/S15.9.5.15_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCDate property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcdate +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getUTCDate.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getUTCDate.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getUTCDate) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getUTCDate.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/name.js new file mode 100644 index 0000000000..3968908ce4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getutcdate +description: > + Date.prototype.getUTCDate.name is "getUTCDate". +info: | + Date.prototype.getUTCDate ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getUTCDate.name, "getUTCDate"); + +verifyNotEnumerable(Date.prototype.getUTCDate, "name"); +verifyNotWritable(Date.prototype.getUTCDate, "name"); +verifyConfigurable(Date.prototype.getUTCDate, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/not-a-constructor.js new file mode 100644 index 0000000000..0590ac9a6e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getUTCDate does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getUTCDate), + false, + 'isConstructor(Date.prototype.getUTCDate) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getUTCDate(); +}, '`let date = new Date(Date.now()); new date.getUTCDate()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-invalid-date.js new file mode 100644 index 0000000000..1c5baf2f48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcdate +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getUTCDate(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-non-date.js new file mode 100644 index 0000000000..28ed8a1c65 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcdate +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getUTCDate = Date.prototype.getUTCDate; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getUTCDate, 'function'); + +assert.throws(TypeError, function() { + getUTCDate.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getUTCDate.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getUTCDate.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-non-object.js new file mode 100644 index 0000000000..40726e54bf --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcdate +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getUTCDate = Date.prototype.getUTCDate; +var symbol = Symbol(); + +assert.sameValue(typeof getUTCDate, 'function'); + +assert.throws(TypeError, function() { + getUTCDate.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getUTCDate.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getUTCDate.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getUTCDate.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getUTCDate.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getUTCDate.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-valid-date.js new file mode 100644 index 0000000000..87cfe7790e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDate/this-value-valid-date.js @@ -0,0 +1,44 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcdate +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return DateFromTime(t). +---*/ + +var july6 = 1467763200000; +var feb29 = 1456704000000; +var dayMs = 24 * 60 * 60 * 1000; + +assert.sameValue(new Date(july6).getUTCDate(), 6, 'first millisecond'); +assert.sameValue( + new Date(july6 - 1).getUTCDate(), 5, 'previous millisecond' +); +assert.sameValue( + new Date(july6 + dayMs - 1).getUTCDate(), 6, 'final millisecond' +); +assert.sameValue( + new Date(july6 + dayMs).getUTCDate(), 7, 'subsequent millisecond' +); + +assert.sameValue( + new Date(feb29).getUTCDate(), 29, 'first millisecond (month boundary)' +); +assert.sameValue( + new Date(feb29 - 1).getUTCDate(), 28, 'previous millisecond (month boundary)' +); +assert.sameValue( + new Date(feb29 + dayMs - 1).getUTCDate(), + 29, + 'final millisecond (month boundary)' +); +assert.sameValue( + new Date(feb29 + dayMs).getUTCDate(), + 1, + 'subsequent millisecond (month boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A1_T1.js new file mode 100644 index 0000000000..d099eb7813 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCDay" has { DontEnum } attributes +esid: sec-date.prototype.getutcdaty +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getUTCDay; +if (x === 1) + Date.prototype.getUTCDay = 2; +else + Date.prototype.getUTCDay = 1; +if (Date.prototype.getUTCDay === x) { + $ERROR('#1: The Date.prototype.getUTCDay has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A1_T2.js new file mode 100644 index 0000000000..9bd0764d57 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCDay" has { DontEnum } attributes +esid: sec-date.prototype.getutcdaty +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCDay === false) { + $ERROR('#1: The Date.prototype.getUTCDay property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getUTCDay')) { + $ERROR('#2: The Date.prototype.getUTCDay property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A1_T3.js new file mode 100644 index 0000000000..ad3448eddf --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCDay" has { DontEnum } attributes +esid: sec-date.prototype.getutcdaty +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getUTCDay')) { + $ERROR('#1: The Date.prototype.getUTCDay property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getUTCDay") { + $ERROR('#2: The Date.prototype.getUTCDay has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A2_T1.js new file mode 100644 index 0000000000..ad5b8bee78 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getUTCDay" is 0 +esid: sec-date.prototype.getutcdaty +description: The "length" property of the "getUTCDay" is 0 +---*/ + +if (Date.prototype.getUTCDay.hasOwnProperty("length") !== true) { + $ERROR('#1: The getUTCDay has a "length" property'); +} + +if (Date.prototype.getUTCDay.length !== 0) { + $ERROR('#2: The "length" property of the getUTCDay is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A3_T1.js new file mode 100644 index 0000000000..e2abebd275 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCDay property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcdaty +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getUTCDay.length; +verifyNotWritable(Date.prototype.getUTCDay, "length", null, 1); +if (Date.prototype.getUTCDay.length !== x) { + $ERROR('#1: The Date.prototype.getUTCDay.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A3_T2.js new file mode 100644 index 0000000000..5448f37584 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCDay property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcdaty +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCDay.length !== true) { + $ERROR('#1: The Date.prototype.getUTCDay.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getUTCDay.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getUTCDay.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A3_T3.js new file mode 100644 index 0000000000..d7eefdf86f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/S15.9.5.17_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCDay property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcdaty +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getUTCDay.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getUTCDay.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getUTCDay) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getUTCDay.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/name.js new file mode 100644 index 0000000000..280b83ed76 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getutcdaty +description: > + Date.prototype.getUTCDay.name is "getUTCDay". +info: | + Date.prototype.getUTCDay ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getUTCDay.name, "getUTCDay"); + +verifyNotEnumerable(Date.prototype.getUTCDay, "name"); +verifyNotWritable(Date.prototype.getUTCDay, "name"); +verifyConfigurable(Date.prototype.getUTCDay, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/not-a-constructor.js new file mode 100644 index 0000000000..42d0a20852 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getUTCDay does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getUTCDay), + false, + 'isConstructor(Date.prototype.getUTCDay) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getUTCDay(); +}, '`let date = new Date(Date.now()); new date.getUTCDay()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-invalid-date.js new file mode 100644 index 0000000000..5db81078d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcday +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getUTCDay(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-non-date.js new file mode 100644 index 0000000000..942e781079 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcday +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getUTCDay = Date.prototype.getUTCDay; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getUTCDay, 'function'); + +assert.throws(TypeError, function() { + getUTCDay.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getUTCDay.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getUTCDay.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-non-object.js new file mode 100644 index 0000000000..64f3a903e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcdaty +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getUTCDay = Date.prototype.getUTCDay; +var symbol = Symbol(); + +assert.sameValue(typeof getUTCDay, 'function'); + +assert.throws(TypeError, function() { + getUTCDay.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getUTCDay.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getUTCDay.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getUTCDay.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getUTCDay.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getUTCDay.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-valid-date.js new file mode 100644 index 0000000000..8576c6bee9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCDay/this-value-valid-date.js @@ -0,0 +1,44 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcday +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return WeekDay(t). +---*/ + +var july6 = 1467763200000; +var july9 = 1468022400000; +var dayMs = 24 * 60 * 60 * 1000; + +assert.sameValue(new Date(july6).getUTCDay(), 3, 'first millisecond'); +assert.sameValue( + new Date(july6 - 1).getUTCDay(), 2, 'previous millisecond' +); +assert.sameValue( + new Date(july6 + dayMs - 1).getUTCDay(), 3, 'final millisecond' +); +assert.sameValue( + new Date(july6 + dayMs).getUTCDay(), 4, 'subsequent millisecond' +); + +assert.sameValue( + new Date(july9).getUTCDay(), 6, 'first millisecond (week boundary)' +); +assert.sameValue( + new Date(july9 - 1).getUTCDay(), 5, 'previous millisecond (week boundary)' +); +assert.sameValue( + new Date(july9 + dayMs - 1).getUTCDay(), + 6, + 'final millisecond (week boundary)' +); +assert.sameValue( + new Date(july9 + dayMs).getUTCDay(), + 0, + 'subsequent millisecond (week boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T1.js new file mode 100644 index 0000000000..09990febab --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCFullYear" has { DontEnum } attributes +esid: sec-date.prototype.getutcfullyear +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getUTCFullYear; +if (x === 1) + Date.prototype.getUTCFullYear = 2; +else + Date.prototype.getUTCFullYear = 1; +if (Date.prototype.getUTCFullYear === x) { + $ERROR('#1: The Date.prototype.getUTCFullYear has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T2.js new file mode 100644 index 0000000000..5dc2ba057a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCFullYear" has { DontEnum } attributes +esid: sec-date.prototype.getutcfullyear +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCFullYear === false) { + $ERROR('#1: The Date.prototype.getUTCFullYear property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getUTCFullYear')) { + $ERROR('#2: The Date.prototype.getUTCFullYear property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T3.js new file mode 100644 index 0000000000..4ce0a7eef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCFullYear" has { DontEnum } attributes +esid: sec-date.prototype.getutcfullyear +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getUTCFullYear')) { + $ERROR('#1: The Date.prototype.getUTCFullYear property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getUTCFullYear") { + $ERROR('#2: The Date.prototype.getUTCFullYear has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A2_T1.js new file mode 100644 index 0000000000..c60e6ec9ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getUTCFullYear" is 0 +esid: sec-date.prototype.getutcfullyear +description: The "length" property of the "getUTCFullYear" is 0 +---*/ + +if (Date.prototype.getUTCFullYear.hasOwnProperty("length") !== true) { + $ERROR('#1: The getUTCFullYear has a "length" property'); +} + +if (Date.prototype.getUTCFullYear.length !== 0) { + $ERROR('#2: The "length" property of the getUTCFullYear is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T1.js new file mode 100644 index 0000000000..d233b450eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCFullYear property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcfullyear +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getUTCFullYear.length; +verifyNotWritable(Date.prototype.getUTCFullYear, "length", null, 1); +if (Date.prototype.getUTCFullYear.length !== x) { + $ERROR('#1: The Date.prototype.getUTCFullYear.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T2.js new file mode 100644 index 0000000000..9474c47691 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCFullYear property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcfullyear +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCFullYear.length !== true) { + $ERROR('#1: The Date.prototype.getUTCFullYear.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getUTCFullYear.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getUTCFullYear.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T3.js new file mode 100644 index 0000000000..c40192efd0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCFullYear property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcfullyear +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getUTCFullYear.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getUTCFullYear.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getUTCFullYear) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getUTCFullYear.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/name.js new file mode 100644 index 0000000000..a12fcc0b98 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getutcfullyear +description: > + Date.prototype.getUTCFullYear.name is "getUTCFullYear". +info: | + Date.prototype.getUTCFullYear ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getUTCFullYear.name, "getUTCFullYear"); + +verifyNotEnumerable(Date.prototype.getUTCFullYear, "name"); +verifyNotWritable(Date.prototype.getUTCFullYear, "name"); +verifyConfigurable(Date.prototype.getUTCFullYear, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/not-a-constructor.js new file mode 100644 index 0000000000..6baf587e38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getUTCFullYear does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getUTCFullYear), + false, + 'isConstructor(Date.prototype.getUTCFullYear) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getUTCFullYear(); +}, '`let date = new Date(Date.now()); new date.getUTCFullYear()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-invalid-date.js new file mode 100644 index 0000000000..53365be35d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcfullyear +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getUTCFullYear(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-non-date.js new file mode 100644 index 0000000000..911da2c6a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcfullyear +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getUTCFullYear = Date.prototype.getUTCFullYear; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getUTCFullYear, 'function'); + +assert.throws(TypeError, function() { + getUTCFullYear.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getUTCFullYear.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getUTCFullYear.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-non-object.js new file mode 100644 index 0000000000..67e4215d61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcfullyear +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getUTCFullYear = Date.prototype.getUTCFullYear; +var symbol = Symbol(); + +assert.sameValue(typeof getUTCFullYear, 'function'); + +assert.throws(TypeError, function() { + getUTCFullYear.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getUTCFullYear.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getUTCFullYear.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getUTCFullYear.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getUTCFullYear.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getUTCFullYear.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-valid-date.js new file mode 100644 index 0000000000..9ed72bf248 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/this-value-valid-date.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcfullyear +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return YearFromTime(t). +---*/ + +var dec31 = 1483142400000; +var dayMs = 24 * 60 * 60 * 1000; + +assert.sameValue(new Date(dec31).getUTCFullYear(), 2016, 'first millisecond'); +assert.sameValue( + new Date(dec31 - 1).getUTCFullYear(), 2016, 'previous millisecond' +); +assert.sameValue( + new Date(dec31 + dayMs - 1).getUTCFullYear(), 2016, 'final millisecond' +); +assert.sameValue( + new Date(dec31 + dayMs).getUTCFullYear(), 2017, 'subsequent millisecond' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A1_T1.js new file mode 100644 index 0000000000..efebef47be --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCHours" has { DontEnum } attributes +esid: sec-date.prototype.getutchours +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getUTCHours; +if (x === 1) + Date.prototype.getUTCHours = 2; +else + Date.prototype.getUTCHours = 1; +if (Date.prototype.getUTCHours === x) { + $ERROR('#1: The Date.prototype.getUTCHours has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A1_T2.js new file mode 100644 index 0000000000..13d6ee2b89 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCHours" has { DontEnum } attributes +esid: sec-date.prototype.getutchours +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCHours === false) { + $ERROR('#1: The Date.prototype.getUTCHours property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getUTCHours')) { + $ERROR('#2: The Date.prototype.getUTCHours property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A1_T3.js new file mode 100644 index 0000000000..c931871c93 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCHours" has { DontEnum } attributes +esid: sec-date.prototype.getutchours +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getUTCHours')) { + $ERROR('#1: The Date.prototype.getUTCHours property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getUTCHours") { + $ERROR('#2: The Date.prototype.getUTCHours has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A2_T1.js new file mode 100644 index 0000000000..57d5ec93fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getUTCHours" is 0 +esid: sec-date.prototype.getutchours +description: The "length" property of the "getUTCHours" is 0 +---*/ + +if (Date.prototype.getUTCHours.hasOwnProperty("length") !== true) { + $ERROR('#1: The getUTCHours has a "length" property'); +} + +if (Date.prototype.getUTCHours.length !== 0) { + $ERROR('#2: The "length" property of the getUTCHours is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A3_T1.js new file mode 100644 index 0000000000..7e1e9c5b09 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCHours property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutchours +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getUTCHours.length; +verifyNotWritable(Date.prototype.getUTCHours, "length", null, 1); +if (Date.prototype.getUTCHours.length !== x) { + $ERROR('#1: The Date.prototype.getUTCHours.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A3_T2.js new file mode 100644 index 0000000000..d9cfdb34f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCHours property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutchours +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCHours.length !== true) { + $ERROR('#1: The Date.prototype.getUTCHours.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getUTCHours.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getUTCHours.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A3_T3.js new file mode 100644 index 0000000000..b1e33c96a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/S15.9.5.19_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCHours property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutchours +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getUTCHours.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getUTCHours.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getUTCHours) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getUTCHours.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/name.js new file mode 100644 index 0000000000..d35e74baa5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getutchours +description: > + Date.prototype.getUTCHours.name is "getUTCHours". +info: | + Date.prototype.getUTCHours ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getUTCHours.name, "getUTCHours"); + +verifyNotEnumerable(Date.prototype.getUTCHours, "name"); +verifyNotWritable(Date.prototype.getUTCHours, "name"); +verifyConfigurable(Date.prototype.getUTCHours, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/not-a-constructor.js new file mode 100644 index 0000000000..60ed6e667f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getUTCHours does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getUTCHours), + false, + 'isConstructor(Date.prototype.getUTCHours) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getUTCHours(); +}, '`let date = new Date(Date.now()); new date.getUTCHours()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-invalid-date.js new file mode 100644 index 0000000000..435093209c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutchours +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getUTCHours(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-non-date.js new file mode 100644 index 0000000000..1158d6a6ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutchours +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getUTCHours = Date.prototype.getUTCHours; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getUTCHours, 'function'); + +assert.throws(TypeError, function() { + getUTCHours.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getUTCHours.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getUTCHours.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-non-object.js new file mode 100644 index 0000000000..fea152d46a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutchours +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getUTCHours = Date.prototype.getUTCHours; +var symbol = Symbol(); + +assert.sameValue(typeof getUTCHours, 'function'); + +assert.throws(TypeError, function() { + getUTCHours.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getUTCHours.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getUTCHours.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getUTCHours.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getUTCHours.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getUTCHours.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-valid-date.js new file mode 100644 index 0000000000..19157cf787 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCHours/this-value-valid-date.js @@ -0,0 +1,44 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutchours +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return HourFromTime(t). +---*/ + +var hour15 = 1467817200000; +var hour23 = 1467846000000; +var hourMs = 60 * 60 * 1000; + +assert.sameValue(new Date(hour15).getUTCHours(), 15, 'first millisecond'); +assert.sameValue( + new Date(hour15 - 1).getUTCHours(), 14, 'previous millisecond' +); +assert.sameValue( + new Date(hour15 + hourMs - 1).getUTCHours(), 15, 'final millisecond' +); +assert.sameValue( + new Date(hour15 + hourMs).getUTCHours(), 16, 'subsequent millisecond' +); + +assert.sameValue( + new Date(hour23).getUTCHours(), 23, 'first millisecond (day boundary)' +); +assert.sameValue( + new Date(hour23 - 1).getUTCHours(), 22, 'previous millisecond (day boundary)' +); +assert.sameValue( + new Date(hour23 + hourMs - 1).getUTCHours(), + 23, + 'final millisecond (day boundary)' +); +assert.sameValue( + new Date(hour23 + hourMs).getUTCHours(), + 0, + 'subsequent millisecond (day boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A1_T1.js new file mode 100644 index 0000000000..08c922aa5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A1_T1.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "getUTCMilliseconds" has { DontEnum } + attributes +esid: sec-date.prototype.getutcmilliseconds +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getUTCMilliseconds; +if (x === 1) + Date.prototype.getUTCMilliseconds = 2; +else + Date.prototype.getUTCMilliseconds = 1; +if (Date.prototype.getUTCMilliseconds === x) { + $ERROR('#1: The Date.prototype.getUTCMilliseconds has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A1_T2.js new file mode 100644 index 0000000000..b6d771ec20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A1_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "getUTCMilliseconds" has { DontEnum } + attributes +esid: sec-date.prototype.getutcmilliseconds +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCMilliseconds === false) { + $ERROR('#1: The Date.prototype.getUTCMilliseconds property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getUTCMilliseconds')) { + $ERROR('#2: The Date.prototype.getUTCMilliseconds property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A1_T3.js new file mode 100644 index 0000000000..a0c88d91d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A1_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "getUTCMilliseconds" has { DontEnum } + attributes +esid: sec-date.prototype.getutcmilliseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getUTCMilliseconds')) { + $ERROR('#1: The Date.prototype.getUTCMilliseconds property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getUTCMilliseconds") { + $ERROR('#2: The Date.prototype.getUTCMilliseconds has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A2_T1.js new file mode 100644 index 0000000000..a576936484 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getUTCMilliseconds" is 0 +esid: sec-date.prototype.getutcmilliseconds +description: The "length" property of the "getUTCMilliseconds" is 0 +---*/ + +if (Date.prototype.getUTCMilliseconds.hasOwnProperty("length") !== true) { + $ERROR('#1: The getUTCMilliseconds has a "length" property'); +} + +if (Date.prototype.getUTCMilliseconds.length !== 0) { + $ERROR('#2: The "length" property of the getUTCMilliseconds is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A3_T1.js new file mode 100644 index 0000000000..7035b5bb40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCMilliseconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcmilliseconds +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getUTCMilliseconds.length; +verifyNotWritable(Date.prototype.getUTCMilliseconds, "length", null, 1); +if (Date.prototype.getUTCMilliseconds.length !== x) { + $ERROR('#1: The Date.prototype.getUTCMilliseconds.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A3_T2.js new file mode 100644 index 0000000000..38b900128d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCMilliseconds property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcmilliseconds +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCMilliseconds.length !== true) { + $ERROR('#1: The Date.prototype.getUTCMilliseconds.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getUTCMilliseconds.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getUTCMilliseconds.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A3_T3.js new file mode 100644 index 0000000000..30a87b6189 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/S15.9.5.25_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCMilliseconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcmilliseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getUTCMilliseconds.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getUTCMilliseconds.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getUTCMilliseconds) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getUTCMilliseconds.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/name.js new file mode 100644 index 0000000000..1a723340a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getutcmilliseconds +description: > + Date.prototype.getUTCMilliseconds.name is "getUTCMilliseconds". +info: | + Date.prototype.getUTCMilliseconds ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getUTCMilliseconds.name, "getUTCMilliseconds"); + +verifyNotEnumerable(Date.prototype.getUTCMilliseconds, "name"); +verifyNotWritable(Date.prototype.getUTCMilliseconds, "name"); +verifyConfigurable(Date.prototype.getUTCMilliseconds, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/not-a-constructor.js new file mode 100644 index 0000000000..b9e17b9792 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getUTCMilliseconds does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getUTCMilliseconds), + false, + 'isConstructor(Date.prototype.getUTCMilliseconds) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getUTCMilliseconds(); +}, '`let date = new Date(Date.now()); new date.getUTCMilliseconds()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-invalid-date.js new file mode 100644 index 0000000000..5fff8c51bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcmilliseconds +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getUTCMilliseconds(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-non-date.js new file mode 100644 index 0000000000..b1cf64e3b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcmilliseconds +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getUTCMilliseconds = Date.prototype.getUTCMilliseconds; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getUTCMilliseconds, 'function'); + +assert.throws(TypeError, function() { + getUTCMilliseconds.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getUTCMilliseconds.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getUTCMilliseconds.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-non-object.js new file mode 100644 index 0000000000..8ed9cbdc1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcmilliseconds +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getUTCMilliseconds = Date.prototype.getUTCMilliseconds; +var symbol = Symbol(); + +assert.sameValue(typeof getUTCMilliseconds, 'function'); + +assert.throws(TypeError, function() { + getUTCMilliseconds.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getUTCMilliseconds.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getUTCMilliseconds.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getUTCMilliseconds.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getUTCMilliseconds.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getUTCMilliseconds.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-valid-date.js new file mode 100644 index 0000000000..fdbe4b17fa --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMilliseconds/this-value-valid-date.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcmmilliseconds +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). +---*/ + +var july6 = 1467763200000; + +assert.sameValue(new Date(july6).getUTCMilliseconds(), 0, 'first millisecond'); +assert.sameValue( + new Date(july6 - 1).getUTCMilliseconds(), 999, 'previous millisecond' +); +assert.sameValue( + new Date(july6 + 999).getUTCMilliseconds(), 999, 'final millisecond' +); +assert.sameValue( + new Date(july6 + 1000).getUTCMilliseconds(), 0, 'subsequent millisecond' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A1_T1.js new file mode 100644 index 0000000000..81cf7bf001 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCMinutes" has { DontEnum } attributes +esid: sec-date.prototype.getutcminutes +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getUTCMinutes; +if (x === 1) + Date.prototype.getUTCMinutes = 2; +else + Date.prototype.getUTCMinutes = 1; +if (Date.prototype.getUTCMinutes === x) { + $ERROR('#1: The Date.prototype.getUTCMinutes has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A1_T2.js new file mode 100644 index 0000000000..2221bfcd40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCMinutes" has { DontEnum } attributes +esid: sec-date.prototype.getutcminutes +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCMinutes === false) { + $ERROR('#1: The Date.prototype.getUTCMinutes property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getUTCMinutes')) { + $ERROR('#2: The Date.prototype.getUTCMinutes property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A1_T3.js new file mode 100644 index 0000000000..79e3e1599e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCMinutes" has { DontEnum } attributes +esid: sec-date.prototype.getutcminutes +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getUTCMinutes')) { + $ERROR('#1: The Date.prototype.getUTCMinutes property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getUTCMinutes") { + $ERROR('#2: The Date.prototype.getUTCMinutes has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A2_T1.js new file mode 100644 index 0000000000..189ce2ecff --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getUTCMinutes" is 0 +esid: sec-date.prototype.getutcminutes +description: The "length" property of the "getUTCMinutes" is 0 +---*/ + +if (Date.prototype.getUTCMinutes.hasOwnProperty("length") !== true) { + $ERROR('#1: The getUTCMinutes has a "length" property'); +} + +if (Date.prototype.getUTCMinutes.length !== 0) { + $ERROR('#2: The "length" property of the getUTCMinutes is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A3_T1.js new file mode 100644 index 0000000000..9e1401f319 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCMinutes property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcminutes +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getUTCMinutes.length; +verifyNotWritable(Date.prototype.getUTCMinutes, "length", null, 1); +if (Date.prototype.getUTCMinutes.length !== x) { + $ERROR('#1: The Date.prototype.getUTCMinutes.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A3_T2.js new file mode 100644 index 0000000000..a6ceb08e27 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCMinutes property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcminutes +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCMinutes.length !== true) { + $ERROR('#1: The Date.prototype.getUTCMinutes.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getUTCMinutes.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getUTCMinutes.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A3_T3.js new file mode 100644 index 0000000000..e324304e31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/S15.9.5.21_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCMinutes property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcminutes +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getUTCMinutes.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getUTCMinutes.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getUTCMinutes) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getUTCMinutes.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/name.js new file mode 100644 index 0000000000..5fc1ac7b8d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getutcminutes +description: > + Date.prototype.getUTCMinutes.name is "getUTCMinutes". +info: | + Date.prototype.getUTCMinutes ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getUTCMinutes.name, "getUTCMinutes"); + +verifyNotEnumerable(Date.prototype.getUTCMinutes, "name"); +verifyNotWritable(Date.prototype.getUTCMinutes, "name"); +verifyConfigurable(Date.prototype.getUTCMinutes, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/not-a-constructor.js new file mode 100644 index 0000000000..be50d8d0e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getUTCMinutes does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getUTCMinutes), + false, + 'isConstructor(Date.prototype.getUTCMinutes) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getUTCMinutes(); +}, '`let date = new Date(Date.now()); new date.getUTCMinutes()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-invalid-date.js new file mode 100644 index 0000000000..71021ea4e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcminutes +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getUTCMinutes(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-non-date.js new file mode 100644 index 0000000000..aca3733e13 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcminutes +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getUTCMinutes = Date.prototype.getUTCMinutes; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getUTCMinutes, 'function'); + +assert.throws(TypeError, function() { + getUTCMinutes.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getUTCMinutes.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getUTCMinutes.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-non-object.js new file mode 100644 index 0000000000..a39c1453ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcminutes +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getUTCMinutes = Date.prototype.getUTCMinutes; +var symbol = Symbol(); + +assert.sameValue(typeof getUTCMinutes, 'function'); + +assert.throws(TypeError, function() { + getUTCMinutes.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getUTCMinutes.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getUTCMinutes.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getUTCMinutes.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getUTCMinutes.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getUTCMinutes.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-valid-date.js new file mode 100644 index 0000000000..04792ccc2b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMinutes/this-value-valid-date.js @@ -0,0 +1,52 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcminutes +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return MinFromTime(t). +---*/ + +var threeTwentyTwo = 1467818520000; +var threeFiftyNine = 1467820740000; +var minMs = 60 * 1000; + +assert.sameValue( + new Date(threeTwentyTwo).getUTCMinutes(), 22, 'first millisecond' +); +assert.sameValue( + new Date(threeTwentyTwo - 1).getUTCMinutes(), 21, 'previous millisecond' +); +assert.sameValue( + new Date(threeTwentyTwo + minMs - 1).getUTCMinutes(), 22, 'final millisecond' +); +assert.sameValue( + new Date(threeTwentyTwo + minMs).getUTCMinutes(), + 23, + 'subsequent millisecond' +); + +assert.sameValue( + new Date(threeFiftyNine).getUTCMinutes(), + 59, + 'first millisecond (day boundary)' +); +assert.sameValue( + new Date(threeFiftyNine - 1).getUTCMinutes(), + 58, + 'previous millisecond (day boundary)' +); +assert.sameValue( + new Date(threeFiftyNine + minMs - 1).getUTCMinutes(), + 59, + 'final millisecond (day boundary)' +); +assert.sameValue( + new Date(threeFiftyNine + minMs).getUTCMinutes(), + 0, + 'subsequent millisecond (day boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A1_T1.js new file mode 100644 index 0000000000..580674b944 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCMonth" has { DontEnum } attributes +esid: sec-date.prototype.getutcmonth +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getUTCMonth; +if (x === 1) + Date.prototype.getUTCMonth = 2; +else + Date.prototype.getUTCMonth = 1; +if (Date.prototype.getUTCMonth === x) { + $ERROR('#1: The Date.prototype.getUTCMonth has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A1_T2.js new file mode 100644 index 0000000000..5b11324030 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCMonth" has { DontEnum } attributes +esid: sec-date.prototype.getutcmonth +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCMonth === false) { + $ERROR('#1: The Date.prototype.getUTCMonth property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getUTCMonth')) { + $ERROR('#2: The Date.prototype.getUTCMonth property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A1_T3.js new file mode 100644 index 0000000000..bc58a1ca77 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCMonth" has { DontEnum } attributes +esid: sec-date.prototype.getutcmonth +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getUTCMonth')) { + $ERROR('#1: The Date.prototype.getUTCMonth property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getUTCMonth") { + $ERROR('#2: The Date.prototype.getUTCMonth has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A2_T1.js new file mode 100644 index 0000000000..53ece314e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getUTCMonth" is 0 +esid: sec-date.prototype.getutcmonth +description: The "length" property of the "getUTCMonth" is 0 +---*/ + +if (Date.prototype.getUTCMonth.hasOwnProperty("length") !== true) { + $ERROR('#1: The getUTCMonth has a "length" property'); +} + +if (Date.prototype.getUTCMonth.length !== 0) { + $ERROR('#2: The "length" property of the getUTCMonth is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A3_T1.js new file mode 100644 index 0000000000..eca4426174 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCMonth property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcmonth +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getUTCMonth.length; +verifyNotWritable(Date.prototype.getUTCMonth, "length", null, 1); +if (Date.prototype.getUTCMonth.length !== x) { + $ERROR('#1: The Date.prototype.getUTCMonth.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A3_T2.js new file mode 100644 index 0000000000..c3c4d4c847 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCMonth property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcmonth +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCMonth.length !== true) { + $ERROR('#1: The Date.prototype.getUTCMonth.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getUTCMonth.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getUTCMonth.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A3_T3.js new file mode 100644 index 0000000000..61afa9b239 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/S15.9.5.13_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCMonth property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcmonth +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getUTCMonth.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getUTCMonth.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getUTCMonth) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getUTCMonth.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/name.js new file mode 100644 index 0000000000..796815dd91 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getutcmonth +description: > + Date.prototype.getUTCMonth.name is "getUTCMonth". +info: | + Date.prototype.getUTCMonth ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getUTCMonth.name, "getUTCMonth"); + +verifyNotEnumerable(Date.prototype.getUTCMonth, "name"); +verifyNotWritable(Date.prototype.getUTCMonth, "name"); +verifyConfigurable(Date.prototype.getUTCMonth, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/not-a-constructor.js new file mode 100644 index 0000000000..55428f88be --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getUTCMonth does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getUTCMonth), + false, + 'isConstructor(Date.prototype.getUTCMonth) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getUTCMonth(); +}, '`let date = new Date(Date.now()); new date.getUTCMonth()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-invalid-date.js new file mode 100644 index 0000000000..68bfe82089 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcmonth +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getUTCMonth(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-non-date.js new file mode 100644 index 0000000000..ca28a0d6fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcmonth +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getUTCMonth = Date.prototype.getUTCMonth; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getUTCMonth, 'function'); + +assert.throws(TypeError, function() { + getUTCMonth.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getUTCMonth.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getUTCMonth.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-non-object.js new file mode 100644 index 0000000000..f1396ebdf2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcmonth +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getUTCMonth = Date.prototype.getUTCMonth; +var symbol = Symbol(); + +assert.sameValue(typeof getUTCMonth, 'function'); + +assert.throws(TypeError, function() { + getUTCMonth.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getUTCMonth.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getUTCMonth.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getUTCMonth.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getUTCMonth.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getUTCMonth.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-valid-date.js new file mode 100644 index 0000000000..4873c783a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCMonth/this-value-valid-date.js @@ -0,0 +1,44 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcmonth +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return MonthFromTime(t). +---*/ + +var july31 = 1469923200000; +var dec31 = 1483142400000; +var dayMs = 24 * 60 * 60 * 1000; + +assert.sameValue(new Date(july31).getUTCMonth(), 6, 'first millisecond'); +assert.sameValue( + new Date(july31 - 1).getUTCMonth(), 6, 'previous millisecond' +); +assert.sameValue( + new Date(july31 + dayMs - 1).getUTCMonth(), 6, 'final millisecond' +); +assert.sameValue( + new Date(july31 + dayMs).getUTCMonth(), 7, 'subsequent millisecond' +); + +assert.sameValue( + new Date(dec31).getUTCMonth(), 11, 'first millisecond (year boundary)' +); +assert.sameValue( + new Date(dec31 - 1).getUTCMonth(), 11, 'previous millisecond (year boundary)' +); +assert.sameValue( + new Date(dec31 + dayMs - 1).getUTCMonth(), + 11, + 'final millisecond (year boundary)' +); +assert.sameValue( + new Date(dec31 + dayMs).getUTCMonth(), + 0, + 'subsequent millisecond (year boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A1_T1.js new file mode 100644 index 0000000000..3cb58467a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCSeconds" has { DontEnum } attributes +esid: sec-date.prototype.getutcseconds +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.getUTCSeconds; +if (x === 1) + Date.prototype.getUTCSeconds = 2; +else + Date.prototype.getUTCSeconds = 1; +if (Date.prototype.getUTCSeconds === x) { + $ERROR('#1: The Date.prototype.getUTCSeconds has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A1_T2.js new file mode 100644 index 0000000000..6b47ad8228 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCSeconds" has { DontEnum } attributes +esid: sec-date.prototype.getutcseconds +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCSeconds === false) { + $ERROR('#1: The Date.prototype.getUTCSeconds property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('getUTCSeconds')) { + $ERROR('#2: The Date.prototype.getUTCSeconds property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A1_T3.js new file mode 100644 index 0000000000..5586058853 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "getUTCSeconds" has { DontEnum } attributes +esid: sec-date.prototype.getutcseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('getUTCSeconds')) { + $ERROR('#1: The Date.prototype.getUTCSeconds property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "getUTCSeconds") { + $ERROR('#2: The Date.prototype.getUTCSeconds has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A2_T1.js new file mode 100644 index 0000000000..f263bc6ad4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "getUTCSeconds" is 0 +esid: sec-date.prototype.getutcseconds +description: The "length" property of the "getUTCSeconds" is 0 +---*/ + +if (Date.prototype.getUTCSeconds.hasOwnProperty("length") !== true) { + $ERROR('#1: The getUTCSeconds has a "length" property'); +} + +if (Date.prototype.getUTCSeconds.length !== 0) { + $ERROR('#2: The "length" property of the getUTCSeconds is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A3_T1.js new file mode 100644 index 0000000000..a7dcfa8332 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCSeconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcseconds +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.getUTCSeconds.length; +verifyNotWritable(Date.prototype.getUTCSeconds, "length", null, 1); +if (Date.prototype.getUTCSeconds.length !== x) { + $ERROR('#1: The Date.prototype.getUTCSeconds.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A3_T2.js new file mode 100644 index 0000000000..3a5762b502 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCSeconds property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcseconds +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.getUTCSeconds.length !== true) { + $ERROR('#1: The Date.prototype.getUTCSeconds.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.getUTCSeconds.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.getUTCSeconds.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A3_T3.js new file mode 100644 index 0000000000..512c905cba --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/S15.9.5.23_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.getUTCSeconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.getutcseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.getUTCSeconds.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.getUTCSeconds.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.getUTCSeconds) { + if (x === "length") { + $ERROR('#2: The Date.prototype.getUTCSeconds.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/browser.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/name.js new file mode 100644 index 0000000000..11cdea38b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.getutcseconds +description: > + Date.prototype.getUTCSeconds.name is "getUTCSeconds". +info: | + Date.prototype.getUTCSeconds ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.getUTCSeconds.name, "getUTCSeconds"); + +verifyNotEnumerable(Date.prototype.getUTCSeconds, "name"); +verifyNotWritable(Date.prototype.getUTCSeconds, "name"); +verifyConfigurable(Date.prototype.getUTCSeconds, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/not-a-constructor.js new file mode 100644 index 0000000000..be8ed19fe1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.getUTCSeconds does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.getUTCSeconds), + false, + 'isConstructor(Date.prototype.getUTCSeconds) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getUTCSeconds(); +}, '`let date = new Date(Date.now()); new date.getUTCSeconds()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/shell.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-invalid-date.js new file mode 100644 index 0000000000..98403f3bd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-invalid-date.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcseconds +description: Return value for invalid date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +assert.sameValue(new Date(NaN).getUTCSeconds(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-non-date.js new file mode 100644 index 0000000000..d14a9885fb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-non-date.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcseconds +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var getUTCSeconds = Date.prototype.getUTCSeconds; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof getUTCSeconds, 'function'); + +assert.throws(TypeError, function() { + getUTCSeconds.call({}); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + getUTCSeconds.call([]); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + getUTCSeconds.call(args); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-non-object.js new file mode 100644 index 0000000000..575fe16b64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-non-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcseconds +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var getUTCSeconds = Date.prototype.getUTCSeconds; +var symbol = Symbol(); + +assert.sameValue(typeof getUTCSeconds, 'function'); + +assert.throws(TypeError, function() { + getUTCSeconds.call(0); +}, 'number'); + +assert.throws(TypeError, function() { + getUTCSeconds.call(true); +}, 'boolean'); + +assert.throws(TypeError, function() { + getUTCSeconds.call(null); +}, 'null'); + +assert.throws(TypeError, function() { + getUTCSeconds.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getUTCSeconds.call(''); +}, 'string'); + +assert.throws(TypeError, function() { + getUTCSeconds.call(symbol); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-valid-date.js new file mode 100644 index 0000000000..5851451eea --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCSeconds/this-value-valid-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.getutcseconds +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return SecFromTime(t). +---*/ + +var sec34 = 1467819394000; +var sec59 = 1467819419000; + +assert.sameValue(new Date(sec34).getUTCSeconds(), 34, 'first millisecond'); +assert.sameValue( + new Date(sec34 - 1).getUTCSeconds(), 33, 'previous millisecond' +); +assert.sameValue( + new Date(sec34 + 999).getUTCSeconds(), 34, 'final millisecond' +); +assert.sameValue( + new Date(sec34 + 1000).getUTCSeconds(), 35, 'subsequent millisecond' +); + +assert.sameValue( + new Date(sec59).getUTCSeconds(), 59, 'first millisecond (minute boundary)' +); +assert.sameValue( + new Date(sec59 - 1).getUTCSeconds(), + 58, + 'previous millisecond (minute boundary)' +); +assert.sameValue( + new Date(sec59 + 99).getUTCSeconds(), + 59, + 'final millisecond (minute boundary)' +); +assert.sameValue( + new Date(sec59 + 1000).getUTCSeconds(), + 0, + 'subsequent millisecond (minute boundary)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/no-date-value.js b/js/src/tests/test262/built-ins/Date/prototype/no-date-value.js new file mode 100644 index 0000000000..0ed5661d0a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/no-date-value.js @@ -0,0 +1,29 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-properties-of-the-date-prototype-object +description: > + The Date Prototype object does not have a [[DateValue]] internal slot. +info: | + Properties of the Date Prototype Object + + The Date prototype object: + [...] + * is not a Date instance and does not have a [[DateValue]] internal slot. + + Date.prototype.getTime ( ) + + 1. Return ? thisTimeValue(this value). + + The abstract operation thisTimeValue takes argument value. + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + [...] + 2. Throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Date.prototype.getTime(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T1.js new file mode 100644 index 0000000000..22f237c6c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setDate" has { DontEnum } attributes +esid: sec-date.prototype.setdate +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setDate; +if (x === 1) + Date.prototype.setDate = 2; +else + Date.prototype.setDate = 1; +if (Date.prototype.setDate === x) { + $ERROR('#1: The Date.prototype.setDate has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T2.js new file mode 100644 index 0000000000..e4ece9b6e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setDate" has { DontEnum } attributes +esid: sec-date.prototype.setdate +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setDate === false) { + $ERROR('#1: The Date.prototype.setDate property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setDate')) { + $ERROR('#2: The Date.prototype.setDate property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T3.js new file mode 100644 index 0000000000..208e574e3e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setDate" has { DontEnum } attributes +esid: sec-date.prototype.setdate +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setDate')) { + $ERROR('#1: The Date.prototype.setDate property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setDate") { + $ERROR('#2: The Date.prototype.setDate has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A2_T1.js new file mode 100644 index 0000000000..2e53d67e72 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setDate" is 1 +esid: sec-date.prototype.setdate +description: The "length" property of the "setDate" is 1 +---*/ + +if (Date.prototype.setDate.hasOwnProperty("length") !== true) { + $ERROR('#1: The setDate has a "length" property'); +} + +if (Date.prototype.setDate.length !== 1) { + $ERROR('#2: The "length" property of the setDate is 1'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T1.js new file mode 100644 index 0000000000..f388d1f570 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setDate property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.setdate +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setDate.length; +verifyNotWritable(Date.prototype.setDate, "length", null, 1); +if (Date.prototype.setDate.length !== x) { + $ERROR('#1: The Date.prototype.setDate.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T2.js new file mode 100644 index 0000000000..9fbcd4e86e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setDate property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setdate +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setDate.length !== true) { + $ERROR('#1: The Date.prototype.setDate.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setDate.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setDate.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T3.js new file mode 100644 index 0000000000..bc37a239a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setDate property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.setdate +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setDate.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setDate.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setDate) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setDate.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number-err.js new file mode 100644 index 0000000000..487518b9b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number-err.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setdate +description: Abrupt completion during type coercion of provided argument +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). +---*/ + +var date = new Date(); +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setDate(obj); +}); + +assert.sameValue(date.getTime(), originalValue); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number.js new file mode 100644 index 0000000000..84997779ce --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number.js @@ -0,0 +1,57 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setdate +description: Type coercion of provided argument +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setDate(arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, new Date(2016, 6, 2).getTime(), 'application of specified value' +); + +returnValue = date.setDate(null); + +assert.sameValue(returnValue, new Date(2016, 5, 30).getTime(), 'null'); + +returnValue = date.setDate(true); + +assert.sameValue(returnValue, new Date(2016, 5, 1).getTime(), 'true'); + +returnValue = date.setDate(false); + +assert.sameValue(returnValue, new Date(2016, 4, 31).getTime(), 'false'); + +returnValue = date.setDate(' +00200.000E-0002 '); + +assert.sameValue(returnValue, new Date(2016, 4, 2).getTime(), 'string'); + +returnValue = date.setDate(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/name.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/name.js new file mode 100644 index 0000000000..15ba085ab7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setdate +description: > + Date.prototype.setDate.name is "setDate". +info: | + Date.prototype.setDate ( date ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setDate.name, "setDate"); + +verifyNotEnumerable(Date.prototype.setDate, "name"); +verifyNotWritable(Date.prototype.setDate, "name"); +verifyConfigurable(Date.prototype.setDate, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/new-value-time-clip.js new file mode 100644 index 0000000000..d0c25070ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/new-value-time-clip.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setdate +description: Behavior when new value exceeds [[DateValue]] limits +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +var date = new Date(8.64e15); +var returnValue; + +assert.notSameValue(date.getTime(), NaN); + +returnValue = date.setDate(28); + +assert.sameValue(returnValue, NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/not-a-constructor.js new file mode 100644 index 0000000000..cc4d2bca46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setDate does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setDate), + false, + 'isConstructor(Date.prototype.setDate) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setDate(); +}, '`let date = new Date(Date.now()); new date.setDate()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-invalid-date.js new file mode 100644 index 0000000000..e3e8e953b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-invalid-date.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setdate +description: > + Behavior when the "this" value is a Date object describing an invald date +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. +---*/ + +var date = new Date(NaN); +var result; + +result = date.setDate(0); + +assert.sameValue(result, NaN, 'return value'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-non-date.js new file mode 100644 index 0000000000..66fd4e6881 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-non-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setdate +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var setDate = Date.prototype.setDate; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof setDate, 'function'); + +assert.throws(TypeError, function() { + setDate.call({}, arg); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + setDate.call([], arg); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + setDate.call(args, arg); +}, 'arguments exotic object'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-non-object.js new file mode 100644 index 0000000000..6033b0c9aa --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-non-object.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setdate +description: Behavior when "this" value is not an Object +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var setDate = Date.prototype.setDate; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var symbol = Symbol(); + +assert.sameValue(typeof setDate, 'function'); + +assert.throws(TypeError, function() { + setDate.call(0, arg); +}, 'number'); + +assert.throws(TypeError, function() { + setDate.call(true, arg); +}, 'boolean'); + +assert.throws(TypeError, function() { + setDate.call(null, arg); +}, 'null'); + +assert.throws(TypeError, function() { + setDate.call(undefined, arg); +}, 'undefined'); + +assert.throws(TypeError, function() { + setDate.call('', arg); +}, 'string'); + +assert.throws(TypeError, function() { + setDate.call(symbol, arg); +}, 'symbol'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-valid-date.js new file mode 100644 index 0000000000..8ce10fc6ef --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-valid-date.js @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setdate +description: Return value for valid dates +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setDate(6); + +expected = new Date(2016, 6, 6).getTime(); +assert.sameValue( + returnValue, expected, 'within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setDate(0); + +expected = new Date(2016, 5, 30).getTime(); +assert.sameValue( + returnValue, expected, 'before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setDate(31); + +expected = new Date(2016, 6, 1).getTime(); +assert.sameValue( + returnValue, expected, 'after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/15.9.5.40_1.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/15.9.5.40_1.js new file mode 100644 index 0000000000..793edd6fd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/15.9.5.40_1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setfullyear +description: > + Date.prototype.setFullYear - Date.prototype is itself not an + instance of Date +---*/ + + +assert.throws(TypeError, function() { + Date.prototype.setFullYear(2012); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A1_T1.js new file mode 100644 index 0000000000..2af6f55cd1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setFullYear" has { DontEnum } attributes +esid: sec-date.prototype.setfullyear +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setFullYear; +if (x === 1) + Date.prototype.setFullYear = 2; +else + Date.prototype.setFullYear = 1; +if (Date.prototype.setFullYear === x) { + $ERROR('#1: The Date.prototype.setFullYear has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A1_T2.js new file mode 100644 index 0000000000..5625f2138d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setFullYear" has { DontEnum } attributes +esid: sec-date.prototype.setfullyear +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setFullYear === false) { + $ERROR('#1: The Date.prototype.setFullYear property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setFullYear')) { + $ERROR('#2: The Date.prototype.setFullYear property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A1_T3.js new file mode 100644 index 0000000000..ab94b49104 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setFullYear" has { DontEnum } attributes +esid: sec-date.prototype.setfullyear +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setFullYear')) { + $ERROR('#1: The Date.prototype.setFullYear property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setFullYear") { + $ERROR('#2: The Date.prototype.setFullYear has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A2_T1.js new file mode 100644 index 0000000000..e2db219c03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setFullYear" is 3 +esid: sec-date.prototype.setfullyear +description: The "length" property of the "setFullYear" is 3 +---*/ + +if (Date.prototype.setFullYear.hasOwnProperty("length") !== true) { + $ERROR('#1: The setFullYear has a "length" property'); +} + +if (Date.prototype.setFullYear.length !== 3) { + $ERROR('#2: The "length" property of the setFullYear is 3'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A3_T1.js new file mode 100644 index 0000000000..000f6129d8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setFullYear property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setfullyear +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setFullYear.length; +verifyNotWritable(Date.prototype.setFullYear, "length", null, 1); +if (Date.prototype.setFullYear.length !== x) { + $ERROR('#1: The Date.prototype.setFullYear.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A3_T2.js new file mode 100644 index 0000000000..d1b99713e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setFullYear property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setfullyear +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setFullYear.length !== true) { + $ERROR('#1: The Date.prototype.setFullYear.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setFullYear.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setFullYear.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A3_T3.js new file mode 100644 index 0000000000..e007f22716 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/S15.9.5.40_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setFullYear property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setfullyear +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setFullYear.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setFullYear.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setFullYear) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setFullYear.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-date-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-date-to-number-err.js new file mode 100644 index 0000000000..33e6e9b366 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-date-to-number-err.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Abrupt completion during type coercion of provided "date" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). +---*/ + +var date = new Date(); +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setFullYear(0, 0, obj); +}); + +assert.sameValue(date.getTime(), originalValue); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-date-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-date-to-number.js new file mode 100644 index 0000000000..00773ce72b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-date-to-number.js @@ -0,0 +1,79 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Type coercion of provided "date" +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6, 7, 11, 36, 23, 2); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setFullYear(2016, 6, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 2, 11, 36, 23, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setFullYear(2016, 6, null); + +assert.sameValue( + returnValue, + new Date(2016, 6, 0, 11, 36, 23, 2).getTime(), + 'null' +); + +returnValue = date.setFullYear(2016, 6, true); + +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 11, 36, 23, 2).getTime(), + 'true' +); + +returnValue = date.setFullYear(2016, 6, false); + +assert.sameValue( + returnValue, + new Date(2016, 6, 0, 11, 36, 23, 2).getTime(), + 'false' +); + +returnValue = date.setFullYear(2016, 6, ' +00200.000E-0002 '); + +assert.sameValue( + returnValue, + new Date(2016, 6, 2, 11, 36, 23, 2).getTime(), + 'string' +); + +returnValue = date.setFullYear(2016, 6, undefined); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-month-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-month-to-number-err.js new file mode 100644 index 0000000000..46bb7e8597 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-month-to-number-err.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Abrupt completion during type coercion of provided "month" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setFullYear(0, obj, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-month-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-month-to-number.js new file mode 100644 index 0000000000..500ad370fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-month-to-number.js @@ -0,0 +1,79 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Type coercion of provided "month" +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6, 7, 11, 36, 23, 2); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setFullYear(2016, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 2, 7, 11, 36, 23, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setFullYear(2016, null); + +assert.sameValue( + returnValue, + new Date(2016, 0, 7, 11, 36, 23, 2).getTime(), + 'null' +); + +returnValue = date.setFullYear(2016, true); + +assert.sameValue( + returnValue, + new Date(2016, 1, 7, 11, 36, 23, 2).getTime(), + 'true' +); + +returnValue = date.setFullYear(2016, false); + +assert.sameValue( + returnValue, + new Date(2016, 0, 7, 11, 36, 23, 2).getTime(), + 'false' +); + +returnValue = date.setFullYear(2016, ' +00200.000E-0002 '); + +assert.sameValue( + returnValue, + new Date(2016, 2, 7, 11, 36, 23, 2).getTime(), + 'string' +); + +returnValue = date.setFullYear(2016, undefined); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-year-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-year-to-number-err.js new file mode 100644 index 0000000000..a8ec29c120 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-year-to-number-err.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Abrupt completion during type coercion of provided "year" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setFullYear(obj, counter, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-year-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-year-to-number.js new file mode 100644 index 0000000000..aa8481972f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/arg-year-to-number.js @@ -0,0 +1,79 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Type coercion of provided "year" +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6, 7, 11, 36, 23, 2); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setFullYear(arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(-1, 42, 7, 11, 36, 23, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setFullYear(null); + +assert.sameValue( + returnValue, + new Date(-1, 18, 7, 11, 36, 23, 2).getTime(), + 'null' +); + +returnValue = date.setFullYear(true); + +assert.sameValue( + returnValue, + new Date(-1, 30, 7, 11, 36, 23, 2).getTime(), + 'true' +); + +returnValue = date.setFullYear(false); + +assert.sameValue( + returnValue, + new Date(-1, 18, 7, 11, 36, 23, 2).getTime(), + 'false' +); + +returnValue = date.setFullYear(' +00200.000E-0002 '); + +assert.sameValue( + returnValue, + new Date(-1, 42, 7, 11, 36, 23, 2).getTime(), + 'string' +); + +returnValue = date.setFullYear(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/name.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/name.js new file mode 100644 index 0000000000..07255899ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setfullyear +description: > + Date.prototype.setFullYear.name is "setFullYear". +info: | + Date.prototype.setFullYear ( year [ , month [ , date ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setFullYear.name, "setFullYear"); + +verifyNotEnumerable(Date.prototype.setFullYear, "name"); +verifyNotWritable(Date.prototype.setFullYear, "name"); +verifyConfigurable(Date.prototype.setFullYear, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/new-value-time-clip.js new file mode 100644 index 0000000000..87db6a917d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/new-value-time-clip.js @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Behavior when new value exceeds [[DateValue]] limits +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +var maxMs = 8.64e15; +var maxYear = 275760; +var maxDate = 12; +var maxMonth = 8; +var date = new Date(maxMs); +var returnValue; + +assert.notSameValue(date.getTime(), NaN); + +returnValue = date.setFullYear(maxYear + 1); + +assert.sameValue(returnValue, NaN, 'overflow due to year'); + +date = new Date(maxMs); + +returnValue = date.setFullYear(maxYear, maxMonth + 1); + +assert.sameValue(returnValue, NaN, 'overflow due to month'); + +date = new Date(maxMs); + +returnValue = date.setFullYear(maxYear, maxMonth, maxDate + 2); + +assert.sameValue(returnValue, NaN, 'overflow due to date'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/not-a-constructor.js new file mode 100644 index 0000000000..99b1f387c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setFullYear does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setFullYear), + false, + 'isConstructor(Date.prototype.setFullYear) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setFullYear(); +}, '`let date = new Date(Date.now()); new date.setFullYear()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-invalid-date.js new file mode 100644 index 0000000000..11b2839acd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-invalid-date.js @@ -0,0 +1,52 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: > + Behavior when the "this" value is a Date object describing an invald date +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(NaN); +var expected, result; + +result = date.setFullYear(2016); + +expected = new Date(2016, 0).getTime(); +assert.sameValue(result, expected, 'return value (year)'); +assert.sameValue( + date.getTime(), expected, '[[DateValue]] internal slot (year)' +); + +date = new Date(NaN); + +result = date.setFullYear(2016, 6); + +expected = new Date(2016, 6).getTime(); +assert.sameValue(result, expected, 'return value (month)'); +assert.sameValue( + date.getTime(), expected, '[[DateValue]] internal slot (month)' +); + +date = new Date(NaN); + +result = date.setFullYear(2016, 6, 7); + +expected = new Date(2016, 6, 7).getTime(); +assert.sameValue(result, expected, 'return value (date)'); +assert.sameValue( + date.getTime(), expected, '[[DateValue]] internal slot (month)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-non-date.js new file mode 100644 index 0000000000..e7d7d9eaee --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-non-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var setFullYear = Date.prototype.setFullYear; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof setFullYear, 'function'); + +assert.throws(TypeError, function() { + setFullYear.call({}, arg); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + setFullYear.call([], arg); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + setFullYear.call(args, arg); +}, 'arguments exotic object'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-non-object.js new file mode 100644 index 0000000000..d6646d55d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-non-object.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var setFullYear = Date.prototype.setFullYear; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var symbol = Symbol(); + +assert.sameValue(typeof setFullYear, 'function'); + +assert.throws(TypeError, function() { + setFullYear.call(0, arg); +}, 'number'); + +assert.throws(TypeError, function() { + setFullYear.call(true, arg); +}, 'boolean'); + +assert.throws(TypeError, function() { + setFullYear.call(null, arg); +}, 'null'); + +assert.throws(TypeError, function() { + setFullYear.call(undefined, arg); +}, 'undefined'); + +assert.throws(TypeError, function() { + setFullYear.call('', arg); +}, 'string'); + +assert.throws(TypeError, function() { + setFullYear.call(symbol, arg); +}, 'symbol'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-valid-date-date.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-valid-date-date.js new file mode 100644 index 0000000000..a11967b4f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-valid-date-date.js @@ -0,0 +1,57 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Return value for valid dates (setting date) +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setFullYear(2016, 6, 6); + +expected = new Date(2016, 6, 6).getTime(); +assert.sameValue( + returnValue, expected, 'date within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'date within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setFullYear(2016, 6, 0); + +expected = new Date(2016, 5, 30).getTime(); +assert.sameValue( + returnValue, expected, 'date before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'date before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setFullYear(2016, 5, 31); + +expected = new Date(2016, 6, 1).getTime(); +assert.sameValue( + returnValue, expected, 'date after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'date after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-valid-date-month.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-valid-date-month.js new file mode 100644 index 0000000000..29248c387a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-valid-date-month.js @@ -0,0 +1,57 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Return value for valid dates (setting month) +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setFullYear(2016, 3); + +expected = new Date(2016, 3).getTime(); +assert.sameValue( + returnValue, expected, 'month within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'month within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setFullYear(2016, -1); + +expected = new Date(2015, 11).getTime(); +assert.sameValue( + returnValue, expected, 'month before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'month before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setFullYear(2016, 12); + +expected = new Date(2017, 0).getTime(); +assert.sameValue( + returnValue, expected, 'month after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'month after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-valid-date-year.js b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-valid-date-year.js new file mode 100644 index 0000000000..bd63580906 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setFullYear/this-value-valid-date-year.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setfullyear +description: Return value for valid dates (setting year) +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setFullYear(2015); + +expected = new Date(2015, 6).getTime(); +assert.sameValue(returnValue, expected, 'year (return value)'); +assert.sameValue(date.getTime(), expected, 'year ([[DateValue]] slot)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T1.js new file mode 100644 index 0000000000..b17bf1884e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setHours" has { DontEnum } attributes +esid: sec-date.prototype.sethours +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setHours; +if (x === 1) + Date.prototype.setHours = 2; +else + Date.prototype.setHours = 1; +if (Date.prototype.setHours === x) { + $ERROR('#1: The Date.prototype.setHours has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T2.js new file mode 100644 index 0000000000..2af0361a1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setHours" has { DontEnum } attributes +esid: sec-date.prototype.sethours +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setHours === false) { + $ERROR('#1: The Date.prototype.setHours property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setHours')) { + $ERROR('#2: The Date.prototype.setHours property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T3.js new file mode 100644 index 0000000000..6640f0be3a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setHours" has { DontEnum } attributes +esid: sec-date.prototype.sethours +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setHours')) { + $ERROR('#1: The Date.prototype.setHours property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setHours") { + $ERROR('#2: The Date.prototype.setHours has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A2_T1.js new file mode 100644 index 0000000000..8301666507 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setHours" is 4 +esid: sec-date.prototype.sethours +description: The "length" property of the "setHours" is 4 +---*/ + +if (Date.prototype.setHours.hasOwnProperty("length") !== true) { + $ERROR('#1: The setHours has a "length" property'); +} + +if (Date.prototype.setHours.length !== 4) { + $ERROR('#2: The "length" property of the setHours is 4'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T1.js new file mode 100644 index 0000000000..ead0d9db12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setHours property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.sethours +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setHours.length; +verifyNotWritable(Date.prototype.setHours, "length", null, 1); +if (Date.prototype.setHours.length !== x) { + $ERROR('#1: The Date.prototype.setHours.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T2.js new file mode 100644 index 0000000000..7c3a58b4af --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setHours property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.sethours +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setHours.length !== true) { + $ERROR('#1: The Date.prototype.setHours.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setHours.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setHours.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T3.js new file mode 100644 index 0000000000..6903f8f57e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setHours property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.sethours +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setHours.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setHours.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setHours) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setHours.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-to-number-err.js new file mode 100644 index 0000000000..73dabb4639 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-to-number-err.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Abrupt completion during type coercion of provided "hour" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(hour). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setHours(obj, counter, counter, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-to-number.js new file mode 100644 index 0000000000..216be0e17c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-to-number.js @@ -0,0 +1,64 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Type coercion of provided "hour" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setHours(arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setHours(null); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0).getTime(), 'null'); + +returnValue = date.setHours(true); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 1).getTime(), 'true'); + +returnValue = date.setHours(false); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0).getTime(), 'false'); + +returnValue = date.setHours(' +00200.000E-0002 '); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 2).getTime(), 'string'); + +returnValue = date.setHours(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number-err.js new file mode 100644 index 0000000000..4182ad87d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number-err.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Abrupt completion during type coercion of provided "min" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setHours(0, obj, counter, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number.js new file mode 100644 index 0000000000..a8436d2555 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number.js @@ -0,0 +1,64 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Type coercion of provided "min" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setHours(0, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setHours(0, null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setHours(0, true); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 1).getTime(), 'true'); + +returnValue = date.setHours(0, false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setHours(0, ' +00200.000E-0002 '); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 2).getTime(), 'string'); + +returnValue = date.setHours(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number-err.js new file mode 100644 index 0000000000..b8a62f59f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number-err.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Abrupt completion during type coercion of provided "ms" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). +---*/ + +var date = new Date(); +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setHours(0, 0, 0, obj); +}); + +assert.sameValue(date.getTime(), originalValue); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number.js new file mode 100644 index 0000000000..8ea3112632 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number.js @@ -0,0 +1,68 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Type coercion of provided "ms" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setHours(0, 0, 0, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setHours(0, 0, 0, null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setHours(0, 0, 0, true); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 1).getTime(), 'true' +); + +returnValue = date.setHours(0, 0, 0, false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setHours(0, 0, 0, ' +00200.000E-0002 '); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), 'string' +); + +returnValue = date.setHours(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number-err.js new file mode 100644 index 0000000000..c0ba88235e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number-err.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Abrupt completion during type coercion of provided "sec" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setHours(0, 0, obj, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number.js new file mode 100644 index 0000000000..7171a1cb31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number.js @@ -0,0 +1,66 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Type coercion of provided "sec" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setHours(0, 0, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setHours(0, 0, null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setHours(0, 0, true); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 0, 1).getTime(), 'true'); + +returnValue = date.setHours(0, 0, false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setHours(0, 0, ' +00200.000E-0002 '); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 2).getTime(), 'string' +); + +returnValue = date.setHours(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/name.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/name.js new file mode 100644 index 0000000000..9626594fc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.sethours +description: > + Date.prototype.setHours.name is "setHours". +info: | + Date.prototype.setHours ( hour [ , min [ , sec [ , ms ] ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setHours.name, "setHours"); + +verifyNotEnumerable(Date.prototype.setHours, "name"); +verifyNotWritable(Date.prototype.setHours, "name"); +verifyConfigurable(Date.prototype.setHours, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/new-value-time-clip.js new file mode 100644 index 0000000000..2c08a9fb54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/new-value-time-clip.js @@ -0,0 +1,54 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Behavior when new value exceeds [[DateValue]] limits +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +var maxMs = 8.64e15; +var date = new Date(maxMs); +var returnValue; + +assert.notSameValue(date.getTime(), NaN); + +returnValue = date.setHours(24); + +assert.sameValue(returnValue, NaN, 'overflow due to hours'); + +date = new Date(maxMs); + +returnValue = date.setHours(0, 24 * 60); + +assert.sameValue(returnValue, NaN, 'overflow due to minutes'); + +date = new Date(maxMs); + +returnValue = date.setHours(0, 0, 24 * 60 * 60); + +assert.sameValue(returnValue, NaN, 'overflow due to seconds'); + +date = new Date(maxMs); + +returnValue = date.setHours(0, 0, 0, 24 * 60 * 60 * 1000); + +assert.sameValue(returnValue, NaN, 'overflow due to milliseconds'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/not-a-constructor.js new file mode 100644 index 0000000000..767fe264d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setHours does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setHours), + false, + 'isConstructor(Date.prototype.setHours) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setHours(); +}, '`let date = new Date(Date.now()); new date.setHours()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-invalid-date.js new file mode 100644 index 0000000000..d31e9479c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-invalid-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: > + Behavior when the "this" value is a Date object describing an invald date +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(NaN); +var result; + +result = date.setHours(0); + +assert.sameValue(result, NaN, 'return value (hour)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (hour)'); + +result = date.setHours(0, 0); + +assert.sameValue(result, NaN, 'return value (minute)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (minute)'); + +result = date.setHours(0, 0, 0); + +assert.sameValue(result, NaN, 'return value (second)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (second)'); + +result = date.setHours(0, 0, 0, 0); + +assert.sameValue(result, NaN, 'return value (ms)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (ms)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-non-date.js new file mode 100644 index 0000000000..0112bd38ad --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-non-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var setHours = Date.prototype.setHours; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof setHours, 'function'); + +assert.throws(TypeError, function() { + setHours.call({}, arg); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + setHours.call([], arg); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + setHours.call(args, arg); +}, 'arguments exotic object'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-non-object.js new file mode 100644 index 0000000000..6eee33d9cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-non-object.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Behavior when "this" value is not an Object +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var setHours = Date.prototype.setHours; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var symbol = Symbol(); + +assert.sameValue(typeof setHours, 'function'); + +assert.throws(TypeError, function() { + setHours.call(0, arg); +}, 'number'); + +assert.throws(TypeError, function() { + setHours.call(true, arg); +}, 'boolean'); + +assert.throws(TypeError, function() { + setHours.call(null, arg); +}, 'null'); + +assert.throws(TypeError, function() { + setHours.call(undefined, arg); +}, 'undefined'); + +assert.throws(TypeError, function() { + setHours.call('', arg); +}, 'string'); + +assert.throws(TypeError, function() { + setHours.call(symbol, arg); +}, 'symbol'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-hour.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-hour.js new file mode 100644 index 0000000000..da27e3a00b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-hour.js @@ -0,0 +1,58 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Return value for valid dates (setting hour) +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setHours(6); + +expected = new Date(2016, 6, 1, 6).getTime(); +assert.sameValue( + returnValue, expected, 'hour within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'hour within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setHours(-1); + +expected = new Date(2016, 5, 30, 23).getTime(); +assert.sameValue( + returnValue, expected, 'hour before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'hour before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setHours(24); + +expected = new Date(2016, 6, 1).getTime(); +assert.sameValue( + returnValue, expected, 'hour after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'hour after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-min.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-min.js new file mode 100644 index 0000000000..9469513e35 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-min.js @@ -0,0 +1,58 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Return value for valid dates (setting min) +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setHours(0, 23); + +expected = new Date(2016, 6, 1, 0, 23).getTime(); +assert.sameValue( + returnValue, expected, 'minute within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'minute within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setHours(0, -1); + +expected = new Date(2016, 5, 30, 23, 59).getTime(); +assert.sameValue( + returnValue, expected, 'minute before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'minute before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setHours(0, 60); + +expected = new Date(2016, 5, 30, 1).getTime(); +assert.sameValue( + returnValue, expected, 'minute after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'minute after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-ms.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-ms.js new file mode 100644 index 0000000000..00de558d9a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-ms.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Return value for valid dates (setting ms) +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setHours(0, 0, 0, 543); + +expected = new Date(2016, 6, 1, 0, 0, 0, 543).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setHours(0, 0, 0, -1); + +expected = new Date(2016, 5, 30, 23, 59, 59, 999).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setHours(0, 0, 0, 1000); + +expected = new Date(2016, 5, 30, 0, 0, 1).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-sec.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-sec.js new file mode 100644 index 0000000000..edfbe86f27 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-sec.js @@ -0,0 +1,58 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.sethours +description: Return value for valid dates (setting sec) +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setHours(0, 0, 45); + +expected = new Date(2016, 6, 1, 0, 0, 45).getTime(); +assert.sameValue( + returnValue, expected, 'second within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'second within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setHours(0, 0, -1); + +expected = new Date(2016, 5, 30, 23, 59, 59).getTime(); +assert.sameValue( + returnValue, expected, 'second before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'second before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setHours(0, 0, 60); + +expected = new Date(2016, 5, 30, 0, 1).getTime(); +assert.sameValue( + returnValue, expected, 'second after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'second after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T1.js new file mode 100644 index 0000000000..5007854386 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setMilliseconds" has { DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setMilliseconds; +if (x === 1) + Date.prototype.setMilliseconds = 2; +else + Date.prototype.setMilliseconds = 1; +if (Date.prototype.setMilliseconds === x) { + $ERROR('#1: The Date.prototype.setMilliseconds has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T2.js new file mode 100644 index 0000000000..ac6a02f903 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setMilliseconds" has { DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setMilliseconds === false) { + $ERROR('#1: The Date.prototype.setMilliseconds property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setMilliseconds')) { + $ERROR('#2: The Date.prototype.setMilliseconds property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T3.js new file mode 100644 index 0000000000..495c90bf4b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setMilliseconds" has { DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setMilliseconds')) { + $ERROR('#1: The Date.prototype.setMilliseconds property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setMilliseconds") { + $ERROR('#2: The Date.prototype.setMilliseconds has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A2_T1.js new file mode 100644 index 0000000000..749f4486f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setMilliseconds" is 1 +esid: sec-date.prototype.setmilliseconds +description: The "length" property of the "setMilliseconds" is 1 +---*/ + +if (Date.prototype.setMilliseconds.hasOwnProperty("length") !== true) { + $ERROR('#1: The setMilliseconds has a "length" property'); +} + +if (Date.prototype.setMilliseconds.length !== 1) { + $ERROR('#2: The "length" property of the setMilliseconds is 1'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T1.js new file mode 100644 index 0000000000..f07a5ec13c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setMilliseconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setMilliseconds.length; +verifyNotWritable(Date.prototype.setMilliseconds, "length", null, 1); +if (Date.prototype.setMilliseconds.length !== x) { + $ERROR('#1: The Date.prototype.setMilliseconds.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T2.js new file mode 100644 index 0000000000..abc08f6a82 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setMilliseconds property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setMilliseconds.length !== true) { + $ERROR('#1: The Date.prototype.setMilliseconds.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setMilliseconds.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setMilliseconds.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T3.js new file mode 100644 index 0000000000..eeb7aae1d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setMilliseconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setMilliseconds.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setMilliseconds.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setMilliseconds) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setMilliseconds.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number-err.js new file mode 100644 index 0000000000..0875605156 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number-err.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmilliseconds +description: Abrupt completion during type coercion of provided argument +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). +---*/ + +var date = new Date(); +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setMilliseconds(obj); +}); + +assert.sameValue(date.getTime(), originalValue); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number.js new file mode 100644 index 0000000000..9e9d0270bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number.js @@ -0,0 +1,63 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmilliseconds +description: Type coercion of provided argument +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setMilliseconds(arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setMilliseconds(null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setMilliseconds(true); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 1).getTime(), 'true' +); + +returnValue = date.setMilliseconds(false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setMilliseconds(' +00200.000E-0002 '); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), 'string' +); + +returnValue = date.setMilliseconds(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/name.js new file mode 100644 index 0000000000..3430c5e216 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setmilliseconds +description: > + Date.prototype.setMilliseconds.name is "setMilliseconds". +info: | + Date.prototype.setMilliseconds ( ms ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setMilliseconds.name, "setMilliseconds"); + +verifyNotEnumerable(Date.prototype.setMilliseconds, "name"); +verifyNotWritable(Date.prototype.setMilliseconds, "name"); +verifyConfigurable(Date.prototype.setMilliseconds, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/new-value-time-clip.js new file mode 100644 index 0000000000..42a59468e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/new-value-time-clip.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmilliseconds +description: Behavior when new value exceeds [[DateValue]] limits +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +var date = new Date(8.64e15); +var returnValue; + +assert.notSameValue(date.getTime(), NaN); + +returnValue = date.setMilliseconds(1); + +assert.sameValue(returnValue, NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/not-a-constructor.js new file mode 100644 index 0000000000..3282e1a901 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setMilliseconds does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setMilliseconds), + false, + 'isConstructor(Date.prototype.setMilliseconds) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setMilliseconds(); +}, '`let date = new Date(Date.now()); new date.setMilliseconds()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-invalid-date.js new file mode 100644 index 0000000000..d0d4289699 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-invalid-date.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmilliseconds +description: > + Behavior when the "this" value is a Date object describing an invald date +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. +---*/ + +var date = new Date(NaN); +var result; + +result = date.setMilliseconds(0); + +assert.sameValue(result, NaN, 'return value'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-date.js new file mode 100644 index 0000000000..6c6c2de96c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmilliseconds +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var setMilliseconds = Date.prototype.setMilliseconds; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof setMilliseconds, 'function'); + +assert.throws(TypeError, function() { + setMilliseconds.call({}, arg); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + setMilliseconds.call([], arg); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + setMilliseconds.call(args, arg); +}, 'arguments exotic object'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-object.js new file mode 100644 index 0000000000..856d4cd3e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-object.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmilliseconds +description: Behavior when "this" value is not an Object +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var setMilliseconds = Date.prototype.setMilliseconds; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var symbol = Symbol(); + +assert.sameValue(typeof setMilliseconds, 'function'); + +assert.throws(TypeError, function() { + setMilliseconds.call(0, arg); +}, 'number'); + +assert.throws(TypeError, function() { + setMilliseconds.call(true, arg); +}, 'boolean'); + +assert.throws(TypeError, function() { + setMilliseconds.call(null, arg); +}, 'null'); + +assert.throws(TypeError, function() { + setMilliseconds.call(undefined, arg); +}, 'undefined'); + +assert.throws(TypeError, function() { + setMilliseconds.call('', arg); +}, 'string'); + +assert.throws(TypeError, function() { + setMilliseconds.call(symbol, arg); +}, 'symbol'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-valid-date.js new file mode 100644 index 0000000000..4f1365abde --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-valid-date.js @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmilliseconds +description: Return value for valid dates +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setMilliseconds(333); + +expected = new Date(2016, 6, 1, 0, 0, 0, 333).getTime(); +assert.sameValue( + returnValue, expected, 'within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMilliseconds(-1); + +expected = new Date(2016, 5, 30, 23, 59, 59, 999).getTime(); +assert.sameValue( + returnValue, expected, 'before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMilliseconds(1000); + +expected = new Date(2016, 6, 1).getTime(); +assert.sameValue( + returnValue, expected, 'after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T1.js new file mode 100644 index 0000000000..0670f304e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setMinutes" has { DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setMinutes; +if (x === 1) + Date.prototype.setMinutes = 2; +else + Date.prototype.setMinutes = 1; +if (Date.prototype.setMinutes === x) { + $ERROR('#1: The Date.prototype.setMinutes has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T2.js new file mode 100644 index 0000000000..e0e26dc790 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setMinutes" has { DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setMinutes === false) { + $ERROR('#1: The Date.prototype.setMinutes property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setMinutes')) { + $ERROR('#2: The Date.prototype.setMinutes property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T3.js new file mode 100644 index 0000000000..99744d63fe --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setMinutes" has { DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setMinutes')) { + $ERROR('#1: The Date.prototype.setMinutes property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setMinutes") { + $ERROR('#2: The Date.prototype.setMinutes has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A2_T1.js new file mode 100644 index 0000000000..de1cbd3c63 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setMinutes" is 3 +esid: sec-date.prototype.setminutes +description: The "length" property of the "setMinutes" is 3 +---*/ + +if (Date.prototype.setMinutes.hasOwnProperty("length") !== true) { + $ERROR('#1: The setMinutes has a "length" property'); +} + +if (Date.prototype.setMinutes.length !== 3) { + $ERROR('#2: The "length" property of the setMinutes is 3'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T1.js new file mode 100644 index 0000000000..5451015080 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setMinutes property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setMinutes.length; +verifyNotWritable(Date.prototype.setMinutes, "length", null, 1); +if (Date.prototype.setMinutes.length !== x) { + $ERROR('#1: The Date.prototype.setMinutes.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T2.js new file mode 100644 index 0000000000..f2f8db5612 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setMinutes property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setMinutes.length !== true) { + $ERROR('#1: The Date.prototype.setMinutes.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setMinutes.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setMinutes.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T3.js new file mode 100644 index 0000000000..2a78c50dac --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setMinutes property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setMinutes.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setMinutes.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setMinutes) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setMinutes.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number-err.js new file mode 100644 index 0000000000..dbcee5ffbb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number-err.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: Abrupt completion during type coercion of provided "min" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setMinutes(obj, counter, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number.js new file mode 100644 index 0000000000..18a9bb5809 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number.js @@ -0,0 +1,62 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: Type coercion of provided "min" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 4. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 5. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)). + 6. Let u be TimeClip(UTC(date)). + 7. Set the [[DateValue]] internal slot of this Date object to u. + 8. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setMinutes(arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setMinutes(null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setMinutes(true); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 1).getTime(), 'true'); + +returnValue = date.setMinutes(false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setMinutes(' +00200.000E-0002 '); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 2).getTime(), 'string'); + +returnValue = date.setMinutes(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number-err.js new file mode 100644 index 0000000000..f2036235e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number-err.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: Abrupt completion during type coercion of provided "ms" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 4. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). +---*/ + +var date = new Date(); +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setMinutes(0, 0, obj); +}); + +assert.sameValue(date.getTime(), originalValue); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number.js new file mode 100644 index 0000000000..84d4629baf --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number.js @@ -0,0 +1,66 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: Type coercion of provided "ms" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 4. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 5. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)). + 6. Let u be TimeClip(UTC(date)). + 7. Set the [[DateValue]] internal slot of this Date object to u. + 8. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setMinutes(0, 0, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setMinutes(0, 0, null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setMinutes(0, 0, true); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 1).getTime(), 'true' +); + +returnValue = date.setMinutes(0, 0, false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setMinutes(0, 0, ' +00200.000E-0002 '); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), 'string' +); + +returnValue = date.setMinutes(0, 0, undefined); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number-err.js new file mode 100644 index 0000000000..d57bba3b71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number-err.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: Abrupt completion during type coercion of provided "sec" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setMinutes(0, 0, obj, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number.js new file mode 100644 index 0000000000..dbb11d823a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number.js @@ -0,0 +1,64 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: Type coercion of provided "sec" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 4. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 5. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)). + 6. Let u be TimeClip(UTC(date)). + 7. Set the [[DateValue]] internal slot of this Date object to u. + 8. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setMinutes(0, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setMinutes(0, null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setMinutes(0, true); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 0, 1).getTime(), 'true'); + +returnValue = date.setMinutes(0, false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setMinutes(0, ' +00200.000E-0002 '); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 2).getTime(), 'string' +); + +returnValue = date.setMinutes(0, undefined); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/name.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/name.js new file mode 100644 index 0000000000..5b177e2027 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setminutes +description: > + Date.prototype.setMinutes.name is "setMinutes". +info: | + Date.prototype.setMinutes ( min [ , sec [ , ms ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setMinutes.name, "setMinutes"); + +verifyNotEnumerable(Date.prototype.setMinutes, "name"); +verifyNotWritable(Date.prototype.setMinutes, "name"); +verifyConfigurable(Date.prototype.setMinutes, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/new-value-time-clip.js new file mode 100644 index 0000000000..030a2b1998 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/new-value-time-clip.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: Behavior when new value exceeds [[DateValue]] limits +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 4. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 5. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)). + 6. Let u be TimeClip(UTC(date)). + 7. Set the [[DateValue]] internal slot of this Date object to u. + 8. Return u. + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +var maxMs = 8.64e15; +var date = new Date(maxMs); +var returnValue; + +assert.notSameValue(date.getTime(), NaN); + +returnValue = date.setMinutes(24 * 60); + +assert.sameValue(returnValue, NaN, 'overflow due to minutes'); + +date = new Date(maxMs); + +returnValue = date.setMinutes(0, 24 * 60 * 60); + +assert.sameValue(returnValue, NaN, 'overflow due to seconds'); + +date = new Date(maxMs); + +returnValue = date.setMinutes(0, 0, 24 * 60 * 60 * 1000); + +assert.sameValue(returnValue, NaN, 'overflow due to milliseconds'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/not-a-constructor.js new file mode 100644 index 0000000000..c65d687fb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setMinutes does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setMinutes), + false, + 'isConstructor(Date.prototype.setMinutes) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setMinutes(); +}, '`let date = new Date(Date.now()); new date.setMinutes()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-invalid-date.js new file mode 100644 index 0000000000..625e53d8f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-invalid-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: > + Behavior when the "this" value is a Date object describing an invald date +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(NaN); +var result; + +result = date.setMinutes(0); + +assert.sameValue(result, NaN, 'return value (hour)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (hour)'); + +result = date.setMinutes(0, 0); + +assert.sameValue(result, NaN, 'return value (minute)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (minute)'); + +result = date.setMinutes(0, 0, 0); + +assert.sameValue(result, NaN, 'return value (second)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (second)'); + +result = date.setMinutes(0, 0, 0, 0); + +assert.sameValue(result, NaN, 'return value (ms)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (ms)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-date.js new file mode 100644 index 0000000000..e6b5eff326 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var setMinutes = Date.prototype.setMinutes; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof setMinutes, 'function'); + +assert.throws(TypeError, function() { + setMinutes.call({}, arg); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + setMinutes.call([], arg); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + setMinutes.call(args, arg); +}, 'arguments exotic object'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-object.js new file mode 100644 index 0000000000..4a2e9da81a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-object.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: Behavior when "this" value is not an Object +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var setMinutes = Date.prototype.setMinutes; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var symbol = Symbol(); + +assert.sameValue(typeof setMinutes, 'function'); + +assert.throws(TypeError, function() { + setMinutes.call(0, arg); +}, 'number'); + +assert.throws(TypeError, function() { + setMinutes.call(true, arg); +}, 'boolean'); + +assert.throws(TypeError, function() { + setMinutes.call(null, arg); +}, 'null'); + +assert.throws(TypeError, function() { + setMinutes.call(undefined, arg); +}, 'undefined'); + +assert.throws(TypeError, function() { + setMinutes.call('', arg); +}, 'string'); + +assert.throws(TypeError, function() { + setMinutes.call(symbol, arg); +}, 'symbol'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-valid-date.js new file mode 100644 index 0000000000..76b4f732d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-valid-date.js @@ -0,0 +1,131 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6, 1); +var returnValue, expected; + +returnValue = date.setMinutes(23); + +expected = new Date(2016, 6, 1, 0, 23).getTime(); +assert.sameValue( + returnValue, expected, 'minute within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'minute within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(-1); + +expected = new Date(2016, 5, 30, 23, 59).getTime(); +assert.sameValue( + returnValue, expected, 'minute before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'minute before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(60); + +expected = new Date(2016, 6, 1).getTime(); +assert.sameValue( + returnValue, expected, 'minute after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'minute after time unit boundary ([[DateValue]] slot)' +); + +date = new Date(2016, 6, 1); + +returnValue = date.setMinutes(0, 45); + +expected = new Date(2016, 6, 1, 0, 0, 45).getTime(); +assert.sameValue( + returnValue, expected, 'second within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'second within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(0, -1); + +expected = new Date(2016, 5, 30, 23, 59, 59).getTime(); +assert.sameValue( + returnValue, expected, 'second before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'second before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(0, 60); + +expected = new Date(2016, 5, 30, 23, 1).getTime(); +assert.sameValue( + returnValue, expected, 'second after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'second after time unit boundary ([[DateValue]] slot)' +); + +date = new Date(2016, 6, 1); + +returnValue = date.setMinutes(0, 0, 345); + +expected = new Date(2016, 6, 1, 0, 0, 0, 345).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(0, 0, -1); + +expected = new Date(2016, 5, 30, 23, 59, 59, 999).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(0, 0, 1000); + +expected = new Date(2016, 5, 30, 23, 0, 1).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A1_T1.js new file mode 100644 index 0000000000..87a5698d29 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setMonth" has { DontEnum } attributes +esid: sec-date.prototype.setmonth +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setMonth; +if (x === 1) + Date.prototype.setMonth = 2; +else + Date.prototype.setMonth = 1; +if (Date.prototype.setMonth === x) { + $ERROR('#1: The Date.prototype.setMonth has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A1_T2.js new file mode 100644 index 0000000000..585fca5292 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setMonth" has { DontEnum } attributes +esid: sec-date.prototype.setmonth +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setMonth === false) { + $ERROR('#1: The Date.prototype.setMonth property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setMonth')) { + $ERROR('#2: The Date.prototype.setMonth property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A1_T3.js new file mode 100644 index 0000000000..01e99ef215 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setMonth" has { DontEnum } attributes +esid: sec-date.prototype.setmonth +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setMonth')) { + $ERROR('#1: The Date.prototype.setMonth property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setMonth") { + $ERROR('#2: The Date.prototype.setMonth has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A2_T1.js new file mode 100644 index 0000000000..96673020cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setMonth" is 2 +esid: sec-date.prototype.setmonth +description: The "length" property of the "setMonth" is 2 +---*/ + +if (Date.prototype.setMonth.hasOwnProperty("length") !== true) { + $ERROR('#1: The setMonth has a "length" property'); +} + +if (Date.prototype.setMonth.length !== 2) { + $ERROR('#2: The "length" property of the setMonth is 2'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A3_T1.js new file mode 100644 index 0000000000..c462f63c2a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setMonth property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.setmonth +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setMonth.length; +verifyNotWritable(Date.prototype.setMonth, "length", null, 1); +if (Date.prototype.setMonth.length !== x) { + $ERROR('#1: The Date.prototype.setMonth.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A3_T2.js new file mode 100644 index 0000000000..26cb12820d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setMonth property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setmonth +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setMonth.length !== true) { + $ERROR('#1: The Date.prototype.setMonth.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setMonth.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setMonth.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A3_T3.js new file mode 100644 index 0000000000..258dd006f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/S15.9.5.38_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setMonth property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.setmonth +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setMonth.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setMonth.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setMonth) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setMonth.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-date-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-date-to-number-err.js new file mode 100644 index 0000000000..107b762d8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-date-to-number-err.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: Abrupt completion during type coercion of provided "date" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(month). + 3. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). +---*/ + +var date = new Date(); +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setMonth(0, obj); +}); + +assert.sameValue(date.getTime(), originalValue); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-date-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-date-to-number.js new file mode 100644 index 0000000000..46db557fa8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-date-to-number.js @@ -0,0 +1,77 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: Type coercion of provided "date" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(month). + 3. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 4. Let newDate be MakeDate(MakeDay(YearFromTime(t), m, dt), + TimeWithinDay(t)). + 5. Let u be TimeClip(UTC(newDate)). + 6. Set the [[DateValue]] internal slot of this Date object to u. + 7. Return u. +---*/ + +var date = new Date(2016, 6, 7, 11, 36, 23, 2); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setMonth(6, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 2, 11, 36, 23, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setMonth(6, null); + +assert.sameValue( + returnValue, + new Date(2016, 6, 0, 11, 36, 23, 2).getTime(), + 'null' +); + +returnValue = date.setMonth(6, true); + +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 11, 36, 23, 2).getTime(), + 'true' +); + +returnValue = date.setMonth(6, false); + +assert.sameValue( + returnValue, + new Date(2016, 6, 0, 11, 36, 23, 2).getTime(), + 'false' +); + +returnValue = date.setMonth(6, ' +00200.000E-0002 '); + +assert.sameValue( + returnValue, + new Date(2016, 6, 2, 11, 36, 23, 2).getTime(), + 'string' +); + +returnValue = date.setMonth(6, undefined); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-month-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-month-to-number-err.js new file mode 100644 index 0000000000..e1ce3b4cc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-month-to-number-err.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: Abrupt completion during type coercion of provided "month" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setMonth(obj, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-month-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-month-to-number.js new file mode 100644 index 0000000000..f1af4d13c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/arg-month-to-number.js @@ -0,0 +1,79 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: Type coercion of provided "month" +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6, 7, 11, 36, 23, 2); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setMonth(arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 2, 7, 11, 36, 23, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setMonth(null); + +assert.sameValue( + returnValue, + new Date(2016, 0, 7, 11, 36, 23, 2).getTime(), + 'null' +); + +returnValue = date.setMonth(true); + +assert.sameValue( + returnValue, + new Date(2016, 1, 7, 11, 36, 23, 2).getTime(), + 'true' +); + +returnValue = date.setMonth(false); + +assert.sameValue( + returnValue, + new Date(2016, 0, 7, 11, 36, 23, 2).getTime(), + 'false' +); + +returnValue = date.setMonth(' +00200.000E-0002 '); + +assert.sameValue( + returnValue, + new Date(2016, 2, 7, 11, 36, 23, 2).getTime(), + 'string' +); + +returnValue = date.setMonth(undefined); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/name.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/name.js new file mode 100644 index 0000000000..9e28f33557 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setmonth +description: > + Date.prototype.setMonth.name is "setMonth". +info: | + Date.prototype.setMonth ( month [ , date ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setMonth.name, "setMonth"); + +verifyNotEnumerable(Date.prototype.setMonth, "name"); +verifyNotWritable(Date.prototype.setMonth, "name"); +verifyConfigurable(Date.prototype.setMonth, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/new-value-time-clip.js new file mode 100644 index 0000000000..311f7e4ce6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/new-value-time-clip.js @@ -0,0 +1,43 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: Behavior when new value exceeds [[DateValue]] limits +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +var maxMs = 8.64e15; +var maxDate = 12; +var maxMonth = 8; +var date = new Date(maxMs); +var returnValue; + +assert.notSameValue(date.getTime(), NaN); + +returnValue = date.setMonth(maxMonth + 1); + +assert.sameValue(returnValue, NaN, 'overflow due to month'); + +date = new Date(maxMs); + +returnValue = date.setMonth(maxMonth, maxDate + 2); + +assert.sameValue(returnValue, NaN, 'overflow due to date'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/not-a-constructor.js new file mode 100644 index 0000000000..ce51b8a701 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setMonth does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setMonth), + false, + 'isConstructor(Date.prototype.setMonth) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setMonth(); +}, '`let date = new Date(Date.now()); new date.setMonth()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-invalid-date.js new file mode 100644 index 0000000000..d3e25b5e74 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-invalid-date.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: > + Behavior when the "this" value is a Date object describing an invald date +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(month). + 3. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 4. Let newDate be MakeDate(MakeDay(YearFromTime(t), m, dt), + TimeWithinDay(t)). + 5. Let u be TimeClip(UTC(newDate)). + 6. Set the [[DateValue]] internal slot of this Date object to u. + 7. Return u. +---*/ + +var date = new Date(NaN); +var result; + +result = date.setMonth(6); + +assert.sameValue(result, NaN, 'return value (month)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (month)'); + +date = new Date(NaN); + +result = date.setMonth(6, 7); + +assert.sameValue(result, NaN, 'return value (date)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (month)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-non-date.js new file mode 100644 index 0000000000..4b57615917 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-non-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var setMonth = Date.prototype.setMonth; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof setMonth, 'function'); + +assert.throws(TypeError, function() { + setMonth.call({}, arg); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + setMonth.call([], arg); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + setMonth.call(args, arg); +}, 'arguments exotic object'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-non-object.js new file mode 100644 index 0000000000..c43b784447 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-non-object.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: Behavior when "this" value is not an Object +info: | + 1. Let t be ? thisTimeValue(this value). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var setMonth = Date.prototype.setMonth; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var symbol = Symbol(); + +assert.sameValue(typeof setMonth, 'function'); + +assert.throws(TypeError, function() { + setMonth.call(0, arg); +}, 'number'); + +assert.throws(TypeError, function() { + setMonth.call(true, arg); +}, 'boolean'); + +assert.throws(TypeError, function() { + setMonth.call(null, arg); +}, 'null'); + +assert.throws(TypeError, function() { + setMonth.call(undefined, arg); +}, 'undefined'); + +assert.throws(TypeError, function() { + setMonth.call('', arg); +}, 'string'); + +assert.throws(TypeError, function() { + setMonth.call(symbol, arg); +}, 'symbol'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-valid-date-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-valid-date-date.js new file mode 100644 index 0000000000..ed06da40c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-valid-date-date.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: Return value for valid dates (setting date) +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(month). + 3. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 4. Let newDate be MakeDate(MakeDay(YearFromTime(t), m, dt), + TimeWithinDay(t)). + 5. Let u be TimeClip(UTC(newDate)). + 6. Set the [[DateValue]] internal slot of this Date object to u. + 7. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setMonth(6, 6); + +expected = new Date(2016, 6, 6).getTime(); +assert.sameValue( + returnValue, expected, 'date within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'date within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMonth(6, 0); + +expected = new Date(2016, 5, 30).getTime(); +assert.sameValue( + returnValue, expected, 'date before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'date before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMonth(5, 31); + +expected = new Date(2016, 6, 1).getTime(); +assert.sameValue( + returnValue, expected, 'date after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'date after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-valid-date-month.js b/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-valid-date-month.js new file mode 100644 index 0000000000..f4ba0fc61d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMonth/this-value-valid-date-month.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setmonth +description: Return value for valid dates (setting month) +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(month). + 3. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 4. Let newDate be MakeDate(MakeDay(YearFromTime(t), m, dt), + TimeWithinDay(t)). + 5. Let u be TimeClip(UTC(newDate)). + 6. Set the [[DateValue]] internal slot of this Date object to u. + 7. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setMonth(3); + +expected = new Date(2016, 3).getTime(); +assert.sameValue( + returnValue, expected, 'month within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'month within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMonth(-1); + +expected = new Date(2015, 11).getTime(); +assert.sameValue( + returnValue, expected, 'month before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'month before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMonth(12); + +expected = new Date(2016, 0).getTime(); +assert.sameValue( + returnValue, expected, 'month after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'month after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A1_T1.js new file mode 100644 index 0000000000..e698b1478c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setSeconds" has { DontEnum } attributes +esid: sec-date.prototype.setseconds +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setSeconds; +if (x === 1) + Date.prototype.setSeconds = 2; +else + Date.prototype.setSeconds = 1; +if (Date.prototype.setSeconds === x) { + $ERROR('#1: The Date.prototype.setSeconds has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A1_T2.js new file mode 100644 index 0000000000..c6391e471e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setSeconds" has { DontEnum } attributes +esid: sec-date.prototype.setseconds +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setSeconds === false) { + $ERROR('#1: The Date.prototype.setSeconds property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setSeconds')) { + $ERROR('#2: The Date.prototype.setSeconds property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A1_T3.js new file mode 100644 index 0000000000..d4cfe0ebb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setSeconds" has { DontEnum } attributes +esid: sec-date.prototype.setseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setSeconds')) { + $ERROR('#1: The Date.prototype.setSeconds property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setSeconds") { + $ERROR('#2: The Date.prototype.setSeconds has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A2_T1.js new file mode 100644 index 0000000000..6af3ee696b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setSeconds" is 2 +esid: sec-date.prototype.setseconds +description: The "length" property of the "setSeconds" is 2 +---*/ + +if (Date.prototype.setSeconds.hasOwnProperty("length") !== true) { + $ERROR('#1: The setSeconds has a "length" property'); +} + +if (Date.prototype.setSeconds.length !== 2) { + $ERROR('#2: The "length" property of the setSeconds is 2'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A3_T1.js new file mode 100644 index 0000000000..ac7c5c501c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setSeconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setseconds +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setSeconds.length; +verifyNotWritable(Date.prototype.setSeconds, "length", null, 1); +if (Date.prototype.setSeconds.length !== x) { + $ERROR('#1: The Date.prototype.setSeconds.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A3_T2.js new file mode 100644 index 0000000000..a770c845cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setSeconds property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setseconds +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setSeconds.length !== true) { + $ERROR('#1: The Date.prototype.setSeconds.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setSeconds.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setSeconds.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A3_T3.js new file mode 100644 index 0000000000..cff0f1aec1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/S15.9.5.30_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setSeconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setSeconds.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setSeconds.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setSeconds) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setSeconds.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-ms-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-ms-to-number-err.js new file mode 100644 index 0000000000..abde04c4d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-ms-to-number-err.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setseconds +description: Abrupt completion during type coercion of provided "ms" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let s be ? ToNumber(sec). + 3. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). +---*/ + +var date = new Date(); +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setSeconds(0, obj); +}); + +assert.sameValue(date.getTime(), originalValue); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-ms-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-ms-to-number.js new file mode 100644 index 0000000000..daff2f09ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-ms-to-number.js @@ -0,0 +1,65 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setseconds +description: Type coercion of provided "ms" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let s be ? ToNumber(sec). + 3. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 4. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, + milli)). + 5. Let u be TimeClip(UTC(date)). + 6. Set the [[DateValue]] internal slot of this Date object to u. + 7. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setSeconds(0, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setSeconds(0, null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setSeconds(0, true); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 1).getTime(), 'true' +); + +returnValue = date.setSeconds(0, false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setSeconds(0, ' +00200.000E-0002 '); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), 'string' +); + +returnValue = date.setSeconds(0, undefined); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-sec-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-sec-to-number-err.js new file mode 100644 index 0000000000..c9dd0a499b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-sec-to-number-err.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setseconds +description: Abrupt completion during type coercion of provided "sec" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let s be ? ToNumber(sec). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setSeconds(obj, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-sec-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-sec-to-number.js new file mode 100644 index 0000000000..c75b2ba52a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/arg-sec-to-number.js @@ -0,0 +1,63 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setseconds +description: Type coercion of provided "sec" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let s be ? ToNumber(sec). + 3. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 4. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, + milli)). + 5. Let u be TimeClip(UTC(date)). + 6. Set the [[DateValue]] internal slot of this Date object to u. + 7. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setSeconds(arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setSeconds(null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setSeconds(true); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 0, 1).getTime(), 'true'); + +returnValue = date.setSeconds(false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setSeconds(' +00200.000E-0002 '); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 2).getTime(), 'string' +); + +returnValue = date.setSeconds(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/name.js new file mode 100644 index 0000000000..1850428386 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setseconds +description: > + Date.prototype.setSeconds.name is "setSeconds". +info: | + Date.prototype.setSeconds ( sec [ , ms ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setSeconds.name, "setSeconds"); + +verifyNotEnumerable(Date.prototype.setSeconds, "name"); +verifyNotWritable(Date.prototype.setSeconds, "name"); +verifyConfigurable(Date.prototype.setSeconds, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/new-value-time-clip.js new file mode 100644 index 0000000000..533ee21aa4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/new-value-time-clip.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setseconds +description: Behavior when new value exceeds [[DateValue]] limits +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let s be ? ToNumber(sec). + 3. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 4. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, + milli)). + 5. Let u be TimeClip(UTC(date)). + 6. Set the [[DateValue]] internal slot of this Date object to u. + 7. Return u. + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +var maxMs = 8.64e15; +var date = new Date(maxMs); +var returnValue; + +assert.notSameValue(date.getTime(), NaN); + +returnValue = date.setSeconds(24 * 60 * 60); + +assert.sameValue(returnValue, NaN, 'overflow due to seconds'); + +date = new Date(maxMs); + +returnValue = date.setSeconds(0, 24 * 60 * 60 * 1000); + +assert.sameValue(returnValue, NaN, 'overflow due to milliseconds'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/not-a-constructor.js new file mode 100644 index 0000000000..47cfa721dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setSeconds does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setSeconds), + false, + 'isConstructor(Date.prototype.setSeconds) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setSeconds(); +}, '`let date = new Date(Date.now()); new date.setSeconds()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-invalid-date.js new file mode 100644 index 0000000000..5c587952f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-invalid-date.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setseconds +description: > + Behavior when the "this" value is a Date object describing an invald date +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let s be ? ToNumber(sec). + 3. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 4. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, + milli)). + 5. Let u be TimeClip(UTC(date)). + 6. Set the [[DateValue]] internal slot of this Date object to u. + 7. Return u. +---*/ + +var date = new Date(NaN); +var result; + +result = date.setSeconds(0); + +assert.sameValue(result, NaN, 'return value (second)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (second)'); + +result = date.setSeconds(0, 0); + +assert.sameValue(result, NaN, 'return value (ms)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (ms)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-non-date.js new file mode 100644 index 0000000000..4905c669bd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-non-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setseconds +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var setSeconds = Date.prototype.setSeconds; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof setSeconds, 'function'); + +assert.throws(TypeError, function() { + setSeconds.call({}, arg); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + setSeconds.call([], arg); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + setSeconds.call(args, arg); +}, 'arguments exotic object'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-non-object.js new file mode 100644 index 0000000000..f977f32a26 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-non-object.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setseconds +description: Behavior when "this" value is not an Object +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var setSeconds = Date.prototype.setSeconds; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var symbol = Symbol(); + +assert.sameValue(typeof setSeconds, 'function'); + +assert.throws(TypeError, function() { + setSeconds.call(0, arg); +}, 'number'); + +assert.throws(TypeError, function() { + setSeconds.call(true, arg); +}, 'boolean'); + +assert.throws(TypeError, function() { + setSeconds.call(null, arg); +}, 'null'); + +assert.throws(TypeError, function() { + setSeconds.call(undefined, arg); +}, 'undefined'); + +assert.throws(TypeError, function() { + setSeconds.call('', arg); +}, 'string'); + +assert.throws(TypeError, function() { + setSeconds.call(symbol, arg); +}, 'symbol'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-valid-date-ms.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-valid-date-ms.js new file mode 100644 index 0000000000..9b1d89ff07 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-valid-date-ms.js @@ -0,0 +1,57 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setseconds +description: Return value for valid dates (setting ms) +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let s be ? ToNumber(sec). + 3. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 4. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, + milli)). + 5. Let u be TimeClip(UTC(date)). + 6. Set the [[DateValue]] internal slot of this Date object to u. + 7. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setSeconds(0, 543); + +expected = new Date(2016, 6, 1, 0, 0, 0, 543).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setSeconds(0, -1); + +expected = new Date(2016, 5, 30, 23, 59, 59, 999).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setSeconds(0, 1000); + +expected = new Date(2016, 5, 30, 23, 59, 1).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-valid-date-sec.js b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-valid-date-sec.js new file mode 100644 index 0000000000..27075d0610 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setSeconds/this-value-valid-date-sec.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setseconds +description: Return value for valid dates (setting sec) +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let s be ? ToNumber(sec). + 3. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 4. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, + milli)). + 5. Let u be TimeClip(UTC(date)). + 6. Set the [[DateValue]] internal slot of this Date object to u. + 7. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setSeconds(45); + +expected = new Date(2016, 6, 1, 0, 0, 45).getTime(); +assert.sameValue( + returnValue, expected, 'second within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'second within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setSeconds(-1); + +expected = new Date(2016, 5, 30, 23, 59, 59).getTime(); +assert.sameValue( + returnValue, expected, 'second before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'second before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setSeconds(60); + +expected = new Date(2016, 6).getTime(); +assert.sameValue( + returnValue, expected, 'second after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'second after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A1_T1.js new file mode 100644 index 0000000000..523febe738 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setTime" has { DontEnum } attributes +esid: sec-date.prototype.settime +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setTime; +if (x === 1) + Date.prototype.setTime = 2; +else + Date.prototype.setTime = 1; +if (Date.prototype.setTime === x) { + $ERROR('#1: The Date.prototype.setTime has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A1_T2.js new file mode 100644 index 0000000000..86a73c7431 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setTime" has { DontEnum } attributes +esid: sec-date.prototype.settime +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setTime === false) { + $ERROR('#1: The Date.prototype.setTime property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setTime')) { + $ERROR('#2: The Date.prototype.setTime property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A1_T3.js new file mode 100644 index 0000000000..e9ea6dd879 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setTime" has { DontEnum } attributes +esid: sec-date.prototype.settime +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setTime')) { + $ERROR('#1: The Date.prototype.setTime property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setTime") { + $ERROR('#2: The Date.prototype.setTime has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A2_T1.js new file mode 100644 index 0000000000..a146626d14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setTime" is 1 +esid: sec-date.prototype.settime +description: The "length" property of the "setTime" is 1 +---*/ + +if (Date.prototype.setTime.hasOwnProperty("length") !== true) { + $ERROR('#1: The setTime has a "length" property'); +} + +if (Date.prototype.setTime.length !== 1) { + $ERROR('#2: The "length" property of the setTime is 1'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A3_T1.js new file mode 100644 index 0000000000..201fed573a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setTime property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.settime +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setTime.length; +verifyNotWritable(Date.prototype.setTime, "length", null, 1); +if (Date.prototype.setTime.length !== x) { + $ERROR('#1: The Date.prototype.setTime.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A3_T2.js new file mode 100644 index 0000000000..33ade36b72 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setTime property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.settime +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setTime.length !== true) { + $ERROR('#1: The Date.prototype.setTime.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setTime.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setTime.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A3_T3.js new file mode 100644 index 0000000000..9a964e15f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/S15.9.5.27_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setTime property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.settime +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setTime.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setTime.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setTime) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setTime.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/arg-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/arg-to-number-err.js new file mode 100644 index 0000000000..4ce961f808 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/arg-to-number-err.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.settime +description: Abrupt completion during type coercion of provided argument +info: | + 1. Perform ? thisTimeValue(this value). + 2. Let t be ? ToNumber(time). +---*/ + +var date = new Date(); +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setTime(obj); +}); + +assert.sameValue(date.getTime(), originalValue); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/arg-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/arg-to-number.js new file mode 100644 index 0000000000..daa2553131 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/arg-to-number.js @@ -0,0 +1,53 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.settime +description: Type coercion of provided argument +info: | + 1. Perform ? thisTimeValue(this value). + 2. Let t be ? ToNumber(time). + 3. Let v be TimeClip(t). + 4. Set the [[DateValue]] internal slot of this Date object to v. + 5. Return v. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setTime(arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue(returnValue, 2, 'application of specified value'); + +returnValue = date.setTime(null); + +assert.sameValue(returnValue, 0, 'null'); + +returnValue = date.setTime(true); + +assert.sameValue(returnValue, 1, 'true'); + +returnValue = date.setTime(false); + +assert.sameValue(returnValue, 0, 'false'); + +returnValue = date.setTime(' +00200.000E-0002 '); + +assert.sameValue(returnValue, 2, 'string'); + +returnValue = date.setTime(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/name.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/name.js new file mode 100644 index 0000000000..b978b93ad5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.settime +description: > + Date.prototype.setTime.name is "setTime". +info: | + Date.prototype.setTime ( time ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setTime.name, "setTime"); + +verifyNotEnumerable(Date.prototype.setTime, "name"); +verifyNotWritable(Date.prototype.setTime, "name"); +verifyConfigurable(Date.prototype.setTime, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/new-value-time-clip.js new file mode 100644 index 0000000000..8912795503 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/new-value-time-clip.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.settime +description: Behavior when new value exceeds [[DateValue]] limits +info: | + 1. Perform ? thisTimeValue(this value). + 2. Let t be ? ToNumber(time). + 3. Let v be TimeClip(t). + 4. Set the [[DateValue]] internal slot of this Date object to v. + 5. Return v. + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +var maxMs = 8.64e15; +var date = new Date(); +var returnValue; + +assert.notSameValue(date.getTime(), NaN); + +returnValue = date.setTime(maxMs + 1); + +assert.sameValue(returnValue, NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/not-a-constructor.js new file mode 100644 index 0000000000..5bd2d83907 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setTime does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setTime), + false, + 'isConstructor(Date.prototype.setTime) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setTime(); +}, '`let date = new Date(Date.now()); new date.setTime()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-invalid-date.js new file mode 100644 index 0000000000..d575d58231 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-invalid-date.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.settime +description: > + Behavior when the "this" value is a Date object describing an invald date +info: | + 1. Perform ? thisTimeValue(this value). + 2. Let t be ? ToNumber(time). + 3. Let v be TimeClip(t). + 4. Set the [[DateValue]] internal slot of this Date object to v. + 5. Return v. +---*/ + +var date = new Date(NaN); +var result; + +result = date.setTime(0); + +assert.sameValue(result, 0, 'return value'); +assert.sameValue(date.getTime(), 0, '[[DateValue]] internal slot'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-non-date.js new file mode 100644 index 0000000000..6ecff8e82c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-non-date.js @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.settime +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var setTime = Date.prototype.setTime; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof setTime, 'function'); + +assert.throws(TypeError, function() { + setTime.call({}, arg); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + setTime.call([], arg); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + setTime.call(args, arg); +}, 'arguments exotic object'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-non-object.js new file mode 100644 index 0000000000..c9eb97e3b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-non-object.js @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.settime +description: Behavior when "this" value is not an Object +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var setTime = Date.prototype.setTime; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var symbol = Symbol(); + +assert.sameValue(typeof setTime, 'function'); + +assert.throws(TypeError, function() { + setTime.call(0, arg); +}, 'number'); + +assert.throws(TypeError, function() { + setTime.call(true, arg); +}, 'boolean'); + +assert.throws(TypeError, function() { + setTime.call(null, arg); +}, 'null'); + +assert.throws(TypeError, function() { + setTime.call(undefined, arg); +}, 'undefined'); + +assert.throws(TypeError, function() { + setTime.call('', arg); +}, 'string'); + +assert.throws(TypeError, function() { + setTime.call(symbol, arg); +}, 'symbol'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-valid-date.js new file mode 100644 index 0000000000..e2cad61b51 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setTime/this-value-valid-date.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.settime +description: Return value for valid dates +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue; + +returnValue = date.setTime(6); + +assert.sameValue( + returnValue, 6, 'within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), 6, 'within unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A1_T1.js new file mode 100644 index 0000000000..e06c14dc58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCDate" has { DontEnum } attributes +esid: sec-date.prototype.setutcdate +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setUTCDate; +if (x === 1) + Date.prototype.setUTCDate = 2; +else + Date.prototype.setUTCDate = 1; +if (Date.prototype.setUTCDate === x) { + $ERROR('#1: The Date.prototype.setUTCDate has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A1_T2.js new file mode 100644 index 0000000000..7fefe80313 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCDate" has { DontEnum } attributes +esid: sec-date.prototype.setutcdate +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCDate === false) { + $ERROR('#1: The Date.prototype.setUTCDate property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setUTCDate')) { + $ERROR('#2: The Date.prototype.setUTCDate property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A1_T3.js new file mode 100644 index 0000000000..36036c4a44 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCDate" has { DontEnum } attributes +esid: sec-date.prototype.setutcdate +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setUTCDate')) { + $ERROR('#1: The Date.prototype.setUTCDate property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setUTCDate") { + $ERROR('#2: The Date.prototype.setUTCDate has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A2_T1.js new file mode 100644 index 0000000000..cdfac04306 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setUTCDate" is 1 +esid: sec-date.prototype.setutcdate +description: The "length" property of the "setUTCDate" is 1 +---*/ + +if (Date.prototype.setUTCDate.hasOwnProperty("length") !== true) { + $ERROR('#1: The setUTCDate has a "length" property'); +} + +if (Date.prototype.setUTCDate.length !== 1) { + $ERROR('#2: The "length" property of the setUTCDate is 1'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A3_T1.js new file mode 100644 index 0000000000..8cc3b13cf6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCDate property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcdate +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setUTCDate.length; +verifyNotWritable(Date.prototype.setUTCDate, "length", null, 1); +if (Date.prototype.setUTCDate.length !== x) { + $ERROR('#1: The Date.prototype.setUTCDate.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A3_T2.js new file mode 100644 index 0000000000..3f43144272 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCDate property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcdate +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCDate.length !== true) { + $ERROR('#1: The Date.prototype.setUTCDate.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setUTCDate.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setUTCDate.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A3_T3.js new file mode 100644 index 0000000000..2b622dd475 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/S15.9.5.37_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCDate property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcdate +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setUTCDate.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setUTCDate.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setUTCDate) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setUTCDate.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/name.js new file mode 100644 index 0000000000..4608a57892 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setutcdate +description: > + Date.prototype.setUTCDate.name is "setUTCDate". +info: | + Date.prototype.setUTCDate ( date ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setUTCDate.name, "setUTCDate"); + +verifyNotEnumerable(Date.prototype.setUTCDate, "name"); +verifyNotWritable(Date.prototype.setUTCDate, "name"); +verifyConfigurable(Date.prototype.setUTCDate, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/not-a-constructor.js new file mode 100644 index 0000000000..eb0e04f08c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setUTCDate does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setUTCDate), + false, + 'isConstructor(Date.prototype.setUTCDate) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setUTCDate(); +}, '`let date = new Date(Date.now()); new date.setUTCDate()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCDate/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A1_T1.js new file mode 100644 index 0000000000..bd537df9a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCFullYear" has { DontEnum } attributes +esid: sec-date.prototype.setutcfullyear +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setUTCFullYear; +if (x === 1) + Date.prototype.setUTCFullYear = 2; +else + Date.prototype.setUTCFullYear = 1; +if (Date.prototype.setUTCFullYear === x) { + $ERROR('#1: The Date.prototype.setUTCFullYear has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A1_T2.js new file mode 100644 index 0000000000..83b7ea8259 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCFullYear" has { DontEnum } attributes +esid: sec-date.prototype.setutcfullyear +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCFullYear === false) { + $ERROR('#1: The Date.prototype.setUTCFullYear property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setUTCFullYear')) { + $ERROR('#2: The Date.prototype.setUTCFullYear property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A1_T3.js new file mode 100644 index 0000000000..950049bfa4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCFullYear" has { DontEnum } attributes +esid: sec-date.prototype.setutcfullyear +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setUTCFullYear')) { + $ERROR('#1: The Date.prototype.setUTCFullYear property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setUTCFullYear") { + $ERROR('#2: The Date.prototype.setUTCFullYear has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A2_T1.js new file mode 100644 index 0000000000..480cabe402 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setUTCFullYear" is 3 +esid: sec-date.prototype.setutcfullyear +description: The "length" property of the "setUTCFullYear" is 3 +---*/ + +if (Date.prototype.setUTCFullYear.hasOwnProperty("length") !== true) { + $ERROR('#1: The setUTCFullYear has a "length" property'); +} + +if (Date.prototype.setUTCFullYear.length !== 3) { + $ERROR('#2: The "length" property of the setUTCFullYear is 3'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A3_T1.js new file mode 100644 index 0000000000..a0cc7827ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCFullYear property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcfullyear +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setUTCFullYear.length; +verifyNotWritable(Date.prototype.setUTCFullYear, "length", null, 1); +if (Date.prototype.setUTCFullYear.length !== x) { + $ERROR('#1: The Date.prototype.setUTCFullYear.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A3_T2.js new file mode 100644 index 0000000000..cd3611e701 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCFullYear property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcfullyear +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCFullYear.length !== true) { + $ERROR('#1: The Date.prototype.setUTCFullYear.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setUTCFullYear.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setUTCFullYear.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A3_T3.js new file mode 100644 index 0000000000..e08ea2b768 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/S15.9.5.41_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCFullYear property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcfullyear +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setUTCFullYear.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setUTCFullYear.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setUTCFullYear) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setUTCFullYear.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/name.js new file mode 100644 index 0000000000..3f0c1ce4ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setutcfullyear +description: > + Date.prototype.setUTCFullYear.name is "setUTCFullYear". +info: | + Date.prototype.setUTCFullYear ( year [ , month [ , date ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setUTCFullYear.name, "setUTCFullYear"); + +verifyNotEnumerable(Date.prototype.setUTCFullYear, "name"); +verifyNotWritable(Date.prototype.setUTCFullYear, "name"); +verifyConfigurable(Date.prototype.setUTCFullYear, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/not-a-constructor.js new file mode 100644 index 0000000000..06d291aa71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setUTCFullYear does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setUTCFullYear), + false, + 'isConstructor(Date.prototype.setUTCFullYear) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setUTCFullYear(); +}, '`let date = new Date(Date.now()); new date.setUTCFullYear()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCFullYear/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A1_T1.js new file mode 100644 index 0000000000..3d7ba60ad4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCHours" has { DontEnum } attributes +esid: sec-date.prototype.setutchours +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setUTCHours; +if (x === 1) + Date.prototype.setUTCHours = 2; +else + Date.prototype.setUTCHours = 1; +if (Date.prototype.setUTCHours === x) { + $ERROR('#1: The Date.prototype.setUTCHours has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A1_T2.js new file mode 100644 index 0000000000..6e5dac5a5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCHours" has { DontEnum } attributes +esid: sec-date.prototype.setutchours +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCHours === false) { + $ERROR('#1: The Date.prototype.setUTCHours property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setUTCHours')) { + $ERROR('#2: The Date.prototype.setUTCHours property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A1_T3.js new file mode 100644 index 0000000000..419a06072c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCHours" has { DontEnum } attributes +esid: sec-date.prototype.setutchours +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setUTCHours')) { + $ERROR('#1: The Date.prototype.setUTCHours property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setUTCHours") { + $ERROR('#2: The Date.prototype.setUTCHours has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A2_T1.js new file mode 100644 index 0000000000..1f549ed0a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setUTCHours" is 4 +esid: sec-date.prototype.setutchours +description: The "length" property of the "setUTCHours" is 4 +---*/ + +if (Date.prototype.setUTCHours.hasOwnProperty("length") !== true) { + $ERROR('#1: The setUTCHours has a "length" property'); +} + +if (Date.prototype.setUTCHours.length !== 4) { + $ERROR('#2: The "length" property of the setUTCHours is 4'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A3_T1.js new file mode 100644 index 0000000000..1648297598 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCHours property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutchours +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setUTCHours.length; +verifyNotWritable(Date.prototype.setUTCHours, "length", null, 1); +if (Date.prototype.setUTCHours.length !== x) { + $ERROR('#1: The Date.prototype.setUTCHours.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A3_T2.js new file mode 100644 index 0000000000..e53a2037aa --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCHours property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutchours +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCHours.length !== true) { + $ERROR('#1: The Date.prototype.setUTCHours.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setUTCHours.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setUTCHours.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A3_T3.js new file mode 100644 index 0000000000..e2a1f6e783 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/S15.9.5.35_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCHours property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutchours +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setUTCHours.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setUTCHours.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setUTCHours) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setUTCHours.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/name.js new file mode 100644 index 0000000000..8335871c2c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setutchours +description: > + Date.prototype.setUTCHours.name is "setUTCHours". +info: | + Date.prototype.setUTCHours ( hour [ , min [ , sec [ , ms ] ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setUTCHours.name, "setUTCHours"); + +verifyNotEnumerable(Date.prototype.setUTCHours, "name"); +verifyNotWritable(Date.prototype.setUTCHours, "name"); +verifyConfigurable(Date.prototype.setUTCHours, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/not-a-constructor.js new file mode 100644 index 0000000000..a572e32b52 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setUTCHours does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setUTCHours), + false, + 'isConstructor(Date.prototype.setUTCHours) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setUTCHours(); +}, '`let date = new Date(Date.now()); new date.setUTCHours()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCHours/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A1_T1.js new file mode 100644 index 0000000000..a796b1f67d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A1_T1.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "setUTCMilliseconds" has { DontEnum } + attributes +esid: sec-date.prototype.setutcmilliseconds +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setUTCMilliseconds; +if (x === 1) + Date.prototype.setUTCMilliseconds = 2; +else + Date.prototype.setUTCMilliseconds = 1; +if (Date.prototype.setUTCMilliseconds === x) { + $ERROR('#1: The Date.prototype.setUTCMilliseconds has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A1_T2.js new file mode 100644 index 0000000000..6c2c0f6b90 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A1_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "setUTCMilliseconds" has { DontEnum } + attributes +esid: sec-date.prototype.setutcmilliseconds +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCMilliseconds === false) { + $ERROR('#1: The Date.prototype.setUTCMilliseconds property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setUTCMilliseconds')) { + $ERROR('#2: The Date.prototype.setUTCMilliseconds property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A1_T3.js new file mode 100644 index 0000000000..526e500c28 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A1_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "setUTCMilliseconds" has { DontEnum } + attributes +esid: sec-date.prototype.setutcmilliseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setUTCMilliseconds')) { + $ERROR('#1: The Date.prototype.setUTCMilliseconds property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setUTCMilliseconds") { + $ERROR('#2: The Date.prototype.setUTCMilliseconds has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A2_T1.js new file mode 100644 index 0000000000..4dcfe749af --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setUTCMilliseconds" is 1 +esid: sec-date.prototype.setutcmilliseconds +description: The "length" property of the "setUTCMilliseconds" is 1 +---*/ + +if (Date.prototype.setUTCMilliseconds.hasOwnProperty("length") !== true) { + $ERROR('#1: The setUTCMilliseconds has a "length" property'); +} + +if (Date.prototype.setUTCMilliseconds.length !== 1) { + $ERROR('#2: The "length" property of the setUTCMilliseconds is 1'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A3_T1.js new file mode 100644 index 0000000000..623ae084b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCMilliseconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcmilliseconds +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setUTCMilliseconds.length; +verifyNotWritable(Date.prototype.setUTCMilliseconds, "length", null, 1); +if (Date.prototype.setUTCMilliseconds.length !== x) { + $ERROR('#1: The Date.prototype.setUTCMilliseconds.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A3_T2.js new file mode 100644 index 0000000000..8c8b8c793d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCMilliseconds property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcmilliseconds +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCMilliseconds.length !== true) { + $ERROR('#1: The Date.prototype.setUTCMilliseconds.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setUTCMilliseconds.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setUTCMilliseconds.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A3_T3.js new file mode 100644 index 0000000000..a8e075da6d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/S15.9.5.29_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCMilliseconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcmilliseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setUTCMilliseconds.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setUTCMilliseconds.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setUTCMilliseconds) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setUTCMilliseconds.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/name.js new file mode 100644 index 0000000000..65d0bd6f99 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setutcmilliseconds +description: > + Date.prototype.setUTCMilliseconds.name is "setUTCMilliseconds". +info: | + Date.prototype.setUTCMilliseconds ( ms ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setUTCMilliseconds.name, "setUTCMilliseconds"); + +verifyNotEnumerable(Date.prototype.setUTCMilliseconds, "name"); +verifyNotWritable(Date.prototype.setUTCMilliseconds, "name"); +verifyConfigurable(Date.prototype.setUTCMilliseconds, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/not-a-constructor.js new file mode 100644 index 0000000000..a7e4cbcc7b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setUTCMilliseconds does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setUTCMilliseconds), + false, + 'isConstructor(Date.prototype.setUTCMilliseconds) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setUTCMilliseconds(); +}, '`let date = new Date(Date.now()); new date.setUTCMilliseconds()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMilliseconds/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A1_T1.js new file mode 100644 index 0000000000..63982cfe0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCMinutes" has { DontEnum } attributes +esid: sec-date.prototype.setutcminutes +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setUTCMinutes; +if (x === 1) + Date.prototype.setUTCMinutes = 2; +else + Date.prototype.setUTCMinutes = 1; +if (Date.prototype.setUTCMinutes === x) { + $ERROR('#1: The Date.prototype.setUTCMinutes has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A1_T2.js new file mode 100644 index 0000000000..55ea09df50 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCMinutes" has { DontEnum } attributes +esid: sec-date.prototype.setutcminutes +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCMinutes === false) { + $ERROR('#1: The Date.prototype.setUTCMinutes property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setUTCMinutes')) { + $ERROR('#2: The Date.prototype.setUTCMinutes property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A1_T3.js new file mode 100644 index 0000000000..734fe71a30 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCMinutes" has { DontEnum } attributes +esid: sec-date.prototype.setutcminutes +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setUTCMinutes')) { + $ERROR('#1: The Date.prototype.setUTCMinutes property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setUTCMinutes") { + $ERROR('#2: The Date.prototype.setUTCMinutes has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A2_T1.js new file mode 100644 index 0000000000..33d45f49e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setUTCMinutes" is 3 +esid: sec-date.prototype.setutcminutes +description: The "length" property of the "setUTCMinutes" is 3 +---*/ + +if (Date.prototype.setUTCMinutes.hasOwnProperty("length") !== true) { + $ERROR('#1: The setUTCMinutes has a "length" property'); +} + +if (Date.prototype.setUTCMinutes.length !== 3) { + $ERROR('#2: The "length" property of the setUTCMinutes is 3'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A3_T1.js new file mode 100644 index 0000000000..59433e8acf --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCMinutes property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcminutes +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setUTCMinutes.length; +verifyNotWritable(Date.prototype.setUTCMinutes, "length", null, 1); +if (Date.prototype.setUTCMinutes.length !== x) { + $ERROR('#1: The Date.prototype.setUTCMinutes.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A3_T2.js new file mode 100644 index 0000000000..244c4c9094 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCMinutes property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcminutes +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCMinutes.length !== true) { + $ERROR('#1: The Date.prototype.setUTCMinutes.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setUTCMinutes.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setUTCMinutes.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A3_T3.js new file mode 100644 index 0000000000..5df6683aaa --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/S15.9.5.33_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCMinutes property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcminutes +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setUTCMinutes.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setUTCMinutes.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setUTCMinutes) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setUTCMinutes.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/name.js new file mode 100644 index 0000000000..db16d42c80 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setutcminutes +description: > + Date.prototype.setUTCMinutes.name is "setUTCMinutes". +info: | + Date.prototype.setUTCMinutes ( min [ , sec [, ms ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setUTCMinutes.name, "setUTCMinutes"); + +verifyNotEnumerable(Date.prototype.setUTCMinutes, "name"); +verifyNotWritable(Date.prototype.setUTCMinutes, "name"); +verifyConfigurable(Date.prototype.setUTCMinutes, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/not-a-constructor.js new file mode 100644 index 0000000000..01f6a9293f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setUTCMinutes does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setUTCMinutes), + false, + 'isConstructor(Date.prototype.setUTCMinutes) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setUTCMinutes(); +}, '`let date = new Date(Date.now()); new date.setUTCMinutes()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMinutes/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A1_T1.js new file mode 100644 index 0000000000..e1376417cf --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCMonth" has { DontEnum } attributes +esid: sec-date.prototype.setutcmonth +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setUTCMonth; +if (x === 1) + Date.prototype.setUTCMonth = 2; +else + Date.prototype.setUTCMonth = 1; +if (Date.prototype.setUTCMonth === x) { + $ERROR('#1: The Date.prototype.setUTCMonth has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A1_T2.js new file mode 100644 index 0000000000..c4a08ae027 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCMonth" has { DontEnum } attributes +esid: sec-date.prototype.setutcmonth +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCMonth === false) { + $ERROR('#1: The Date.prototype.setUTCMonth property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setUTCMonth')) { + $ERROR('#2: The Date.prototype.setUTCMonth property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A1_T3.js new file mode 100644 index 0000000000..8598ccaa62 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCMonth" has { DontEnum } attributes +esid: sec-date.prototype.setutcmonth +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setUTCMonth')) { + $ERROR('#1: The Date.prototype.setUTCMonth property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setUTCMonth") { + $ERROR('#2: The Date.prototype.setUTCMonth has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A2_T1.js new file mode 100644 index 0000000000..48c9d339a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setUTCMonth" is 2 +esid: sec-date.prototype.setutcmonth +description: The "length" property of the "setUTCMonth" is 2 +---*/ + +if (Date.prototype.setUTCMonth.hasOwnProperty("length") !== true) { + $ERROR('#1: The setUTCMonth has a "length" property'); +} + +if (Date.prototype.setUTCMonth.length !== 2) { + $ERROR('#2: The "length" property of the setUTCMonth is 2'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A3_T1.js new file mode 100644 index 0000000000..4fd13983f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCMonth property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcmonth +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setUTCMonth.length; +verifyNotWritable(Date.prototype.setUTCMonth, "length", null, 1); +if (Date.prototype.setUTCMonth.length !== x) { + $ERROR('#1: The Date.prototype.setUTCMonth.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A3_T2.js new file mode 100644 index 0000000000..5b085d9977 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCMonth property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcmonth +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCMonth.length !== true) { + $ERROR('#1: The Date.prototype.setUTCMonth.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setUTCMonth.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setUTCMonth.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A3_T3.js new file mode 100644 index 0000000000..0194ec3c0a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/S15.9.5.39_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCMonth property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcmonth +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setUTCMonth.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setUTCMonth.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setUTCMonth) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setUTCMonth.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/name.js new file mode 100644 index 0000000000..70ca8822ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setutcmonth +description: > + Date.prototype.setUTCMonth.name is "setUTCMonth". +info: | + Date.prototype.setUTCMonth ( month [ , date ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setUTCMonth.name, "setUTCMonth"); + +verifyNotEnumerable(Date.prototype.setUTCMonth, "name"); +verifyNotWritable(Date.prototype.setUTCMonth, "name"); +verifyConfigurable(Date.prototype.setUTCMonth, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/not-a-constructor.js new file mode 100644 index 0000000000..977faba6d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setUTCMonth does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setUTCMonth), + false, + 'isConstructor(Date.prototype.setUTCMonth) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setUTCMonth(); +}, '`let date = new Date(Date.now()); new date.setUTCMonth()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCMonth/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A1_T1.js new file mode 100644 index 0000000000..150491707d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCSeconds" has { DontEnum } attributes +esid: sec-date.prototype.setutcseconds +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setUTCSeconds; +if (x === 1) + Date.prototype.setUTCSeconds = 2; +else + Date.prototype.setUTCSeconds = 1; +if (Date.prototype.setUTCSeconds === x) { + $ERROR('#1: The Date.prototype.setUTCSeconds has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A1_T2.js new file mode 100644 index 0000000000..dd52dfee7d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCSeconds" has { DontEnum } attributes +esid: sec-date.prototype.setutcseconds +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCSeconds === false) { + $ERROR('#1: The Date.prototype.setUTCSeconds property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('setUTCSeconds')) { + $ERROR('#2: The Date.prototype.setUTCSeconds property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A1_T3.js new file mode 100644 index 0000000000..b947183266 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "setUTCSeconds" has { DontEnum } attributes +esid: sec-date.prototype.setutcseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('setUTCSeconds')) { + $ERROR('#1: The Date.prototype.setUTCSeconds property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "setUTCSeconds") { + $ERROR('#2: The Date.prototype.setUTCSeconds has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A2_T1.js new file mode 100644 index 0000000000..9199af13d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "setUTCSeconds" is 2 +esid: sec-date.prototype.setutcseconds +description: The "length" property of the "setUTCSeconds" is 2 +---*/ + +if (Date.prototype.setUTCSeconds.hasOwnProperty("length") !== true) { + $ERROR('#1: The setUTCSeconds has a "length" property'); +} + +if (Date.prototype.setUTCSeconds.length !== 2) { + $ERROR('#2: The "length" property of the setUTCSeconds is 2'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A3_T1.js new file mode 100644 index 0000000000..7f09258443 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCSeconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcseconds +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setUTCSeconds.length; +verifyNotWritable(Date.prototype.setUTCSeconds, "length", null, 1); +if (Date.prototype.setUTCSeconds.length !== x) { + $ERROR('#1: The Date.prototype.setUTCSeconds.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A3_T2.js new file mode 100644 index 0000000000..cc6dc34fe3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCSeconds property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcseconds +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.setUTCSeconds.length !== true) { + $ERROR('#1: The Date.prototype.setUTCSeconds.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.setUTCSeconds.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.setUTCSeconds.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A3_T3.js new file mode 100644 index 0000000000..cfdf904c19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/S15.9.5.31_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.setUTCSeconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setutcseconds +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.setUTCSeconds.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.setUTCSeconds.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.setUTCSeconds) { + if (x === "length") { + $ERROR('#2: The Date.prototype.setUTCSeconds.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/name.js new file mode 100644 index 0000000000..b73874e84a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.setutcseconds +description: > + Date.prototype.setUTCSeconds.name is "setUTCSeconds". +info: | + Date.prototype.setUTCSeconds ( sec [ , ms ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.setUTCSeconds.name, "setUTCSeconds"); + +verifyNotEnumerable(Date.prototype.setUTCSeconds, "name"); +verifyNotWritable(Date.prototype.setUTCSeconds, "name"); +verifyConfigurable(Date.prototype.setUTCSeconds, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/not-a-constructor.js new file mode 100644 index 0000000000..b6eebae507 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.setUTCSeconds does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.setUTCSeconds), + false, + 'isConstructor(Date.prototype.setUTCSeconds) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setUTCSeconds(); +}, '`let date = new Date(Date.now()); new date.setUTCSeconds()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setUTCSeconds/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/shell.js b/js/src/tests/test262/built-ins/Date/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T1.js new file mode 100644 index 0000000000..b27c50aa7b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toDateString" has { DontEnum } attributes +esid: sec-date.prototype.todatestring +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.toDateString; +if (x === 1) + Date.prototype.toDateString = 2; +else + Date.prototype.toDateString = 1; +if (Date.prototype.toDateString === x) { + $ERROR('#1: The Date.prototype.toDateString has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T2.js new file mode 100644 index 0000000000..a2b94d970e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toDateString" has { DontEnum } attributes +esid: sec-date.prototype.todatestring +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.toDateString === false) { + $ERROR('#1: The Date.prototype.toDateString property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('toDateString')) { + $ERROR('#2: The Date.prototype.toDateString property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T3.js new file mode 100644 index 0000000000..52fd729d3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toDateString" has { DontEnum } attributes +esid: sec-date.prototype.todatestring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('toDateString')) { + $ERROR('#1: The Date.prototype.toDateString property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "toDateString") { + $ERROR('#2: The Date.prototype.toDateString has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A2_T1.js new file mode 100644 index 0000000000..6225469306 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "toDateString" is 0 +esid: sec-date.prototype.todatestring +description: The "length" property of the "toDateString" is 0 +---*/ + +if (Date.prototype.toDateString.hasOwnProperty("length") !== true) { + $ERROR('#1: The toDateString has a "length" property'); +} + +if (Date.prototype.toDateString.length !== 0) { + $ERROR('#2: The "length" property of the toDateString is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T1.js new file mode 100644 index 0000000000..d538e558a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toDateString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.todatestring +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.toDateString.length; +verifyNotWritable(Date.prototype.toDateString, "length", null, 1); +if (Date.prototype.toDateString.length !== x) { + $ERROR('#1: The Date.prototype.toDateString.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T2.js new file mode 100644 index 0000000000..73fea3c6dd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toDateString property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.todatestring +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.toDateString.length !== true) { + $ERROR('#1: The Date.prototype.toDateString.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.toDateString.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.toDateString.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T3.js new file mode 100644 index 0000000000..cd03502786 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toDateString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.todatestring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.toDateString.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.toDateString.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.toDateString) { + if (x === "length") { + $ERROR('#2: The Date.prototype.toDateString.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/browser.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/format.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/format.js new file mode 100644 index 0000000000..3963baa981 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/format.js @@ -0,0 +1,21 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.todatestring +description: Test the format of the date from toDateString +info: | + Date.prototype.toDateString ( ) + + 5. Return DateString(_t_). +---*/ + +let dateRegExp = /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{2} [0-9]{4}$/ +let match = dateRegExp.exec(new Date().toDateString()); +assert.notSameValue(null, match); + +// Years are padded to the left with zeroes +match = dateRegExp.exec(new Date('0020-01-01T00:00:00Z').toDateString()); +assert.notSameValue(null, match); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/invalid-date.js new file mode 100644 index 0000000000..8a86c80abb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/invalid-date.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.todatestring +description: Invalid Dates are rendered as "Invalid Date" +info: | + Date.prototype.toDateString ( ) + + ... + 3. If tv is NaN, return "Invalid Date". + ... +---*/ + +assert.sameValue(new Date(NaN).toDateString(), "Invalid Date"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/name.js new file mode 100644 index 0000000000..3cd99649b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.todatestring +description: > + Date.prototype.toDateString.name is "toDateString". +info: | + Date.prototype.toDateString ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.toDateString.name, "toDateString"); + +verifyNotEnumerable(Date.prototype.toDateString, "name"); +verifyNotWritable(Date.prototype.toDateString, "name"); +verifyConfigurable(Date.prototype.toDateString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/negative-year.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/negative-year.js new file mode 100644 index 0000000000..dfd228a582 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/negative-year.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Negative years must be serialized with at least four digits +esid: sec-date.prototype.todatestring +info: | + Date.prototype.toDateString ( ) + + 5. Return DateString(_t_). +---*/ + +var negative1DigitYearDateString = (new Date('-000001-07-01T00:00Z')).toDateString(); +var negative2DigitYearDateString = (new Date('-000012-07-01T00:00Z')).toDateString(); +var negative3DigitYearDateString = (new Date('-000123-07-01T00:00Z')).toDateString(); +var negative4DigitYearDateString = (new Date('-001234-07-01T00:00Z')).toDateString(); +var negative5DigitYearDateString = (new Date('-012345-07-01T00:00Z')).toDateString(); +var negative6DigitYearDateString = (new Date('-123456-07-01T00:00Z')).toDateString(); + +// Date.prototype.toDateString emits values like "Fri Mar 28 2019". +// Extract and verify just the year. +assert.sameValue(negative1DigitYearDateString.split(' ')[3], '-0001', + 'Date.prototype.toDateString serializes year -1 to "-0001"'); +assert.sameValue(negative2DigitYearDateString.split(' ')[3], '-0012', + 'Date.prototype.toDateString serializes year -12 to "-0012"'); +assert.sameValue(negative3DigitYearDateString.split(' ')[3], '-0123', + 'Date.prototype.toDateString serializes year -123 to "-0123"'); +assert.sameValue(negative4DigitYearDateString.split(' ')[3], '-1234', + 'Date.prototype.toDateString serializes year -1234 to "-1234"'); +assert.sameValue(negative5DigitYearDateString.split(' ')[3], '-12345', + 'Date.prototype.toDateString serializes year -12345 to "-12345"'); +assert.sameValue(negative6DigitYearDateString.split(' ')[3], '-123456', + 'Date.prototype.toDateString serializes year -123456 to "-123456"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/not-a-constructor.js new file mode 100644 index 0000000000..b70807dc68 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.toDateString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.toDateString), + false, + 'isConstructor(Date.prototype.toDateString) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.toDateString(); +}, '`let date = new Date(Date.now()); new date.toDateString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toDateString/shell.js b/js/src/tests/test262/built-ins/Date/prototype/toDateString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-10.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-10.js new file mode 100644 index 0000000000..44733d6b40 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-10.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - RangeError is not thrown when value + of date is Date(1970, 0, -99999999, 0, 0, 0, 1), the time zone is + UTC(0) +---*/ + +var timeZoneMinutes = new Date().getTimezoneOffset() * (-1); +var date, dateStr; + +if (timeZoneMinutes > 0) { + date = new Date(1970, 0, -99999999, 0, 0, 0, 1); + + assert.throws(RangeError, function() { + date.toISOString(); + }); +} else { + date = new Date(1970, 0, -99999999, 0, 0 + timeZoneMinutes + 60, 0, 1); + + dateStr = date.toISOString(); + + assert.sameValue(dateStr[dateStr.length - 1], "Z"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-11.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-11.js new file mode 100644 index 0000000000..46cf645f0b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-11.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - RangeError is not thrown when value + of date is Date(1970, 0, 100000001, 0, 0, 0, -1), the time zone is + UTC(0) +---*/ + +var timeZoneMinutes = new Date().getTimezoneOffset() * (-1); +var date, dateStr; + +date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes - 60, 0, -1); +dateStr = date.toISOString(); + +assert.sameValue(dateStr[dateStr.length - 1], "Z", 'dateStr[dateStr.length - 1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-12.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-12.js new file mode 100644 index 0000000000..68a07d2130 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-12.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - RangeError is not thrown when value + of date is Date(1970, 0, 100000001, 0, 0, 0, 0), the time zone is + UTC(0) +---*/ + +var timeZoneMinutes = new Date().getTimezoneOffset() * (-1); +var date, dateStr; + +date = new Date(1970, 0, 100000001, 0, 0 + timeZoneMinutes - 60, 0, 0); +dateStr = date.toISOString(); + +assert.sameValue(dateStr[dateStr.length - 1], "Z", 'dateStr[dateStr.length - 1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-13.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-13.js new file mode 100644 index 0000000000..c2a7c4b128 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-13.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - RangeError is thrown when value of + date is outside the valid range of time. +---*/ + +// As specified in ES5 15.9.1.14, time > 8.64e15 is not in the valid range. +var date = new Date(8.64e15 + 1); +assert.throws(RangeError, function() { + date.toISOString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-14.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-14.js new file mode 100644 index 0000000000..14e06ce204 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-14.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - when value of year is -Infinity + Date.prototype.toISOString throw the RangeError +---*/ + +var date = new Date(-Infinity, 1, 70, 0, 0, 0); +assert.throws(RangeError, function() { + date.toISOString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-15.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-15.js new file mode 100644 index 0000000000..2c35e8eb5f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-15.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - value of year is Infinity + Date.prototype.toISOString throw the RangeError +---*/ + +var date = new Date(Infinity, 1, 70, 0, 0, 0); +assert.throws(RangeError, function() { + date.toISOString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-16.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-16.js new file mode 100644 index 0000000000..57d3077101 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-16.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - when this is a String object that + value format is 'YYYY-MM-DDTHH:mm:ss.sssZ' + Date.prototype.toISOString throw the TypeError +---*/ + +var date = new String("1970-01-00000:00:00.000Z"); +assert.throws(TypeError, function() { + Date.prototype.toISOString.call(date); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-2.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-2.js new file mode 100644 index 0000000000..796769d5eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString must exist as a function taking 0 + parameters +---*/ + +assert.sameValue(Date.prototype.toISOString.length, 0, 'Date.prototype.toISOString.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-3.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-3.js new file mode 100644 index 0000000000..d14ec10718 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-3.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: Date.prototype.toISOString must exist as a function +---*/ + +assert.sameValue(typeof(Date.prototype.toISOString), "function", 'typeof (Date.prototype.toISOString)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-4.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-4.js new file mode 100644 index 0000000000..14262310a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-4.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - format of returned string is + 'YYYY-MM-DDTHH:mm:ss.sssZ', the time zone is UTC(0) +---*/ + +var date = new Date(1999, 9, 10, 10, 10, 10, 10); +var localDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000); + +assert.sameValue(localDate.toISOString(), "1999-10-10T10:10:10.010Z", 'localDate.toISOString()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-5.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-5.js new file mode 100644 index 0000000000..e8aa9da25a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-5.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - The returned string is the UTC time + zone(0) +---*/ + +var dateStr = (new Date()).toISOString(); + +assert.sameValue(dateStr[dateStr.length - 1], "Z", 'dateStr[dateStr.length - 1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-6.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-6.js new file mode 100644 index 0000000000..45a331da2d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-6.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - TypeError is thrown when this is any + other objects instead of Date object +---*/ + + +assert.throws(TypeError, function() { + Date.prototype.toISOString.call([]); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-7.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-7.js new file mode 100644 index 0000000000..ca39dde06a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-7.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - TypeError is thrown when this is any + primitive values +---*/ + + +assert.throws(TypeError, function() { + Date.prototype.toISOString.call(15); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-8.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-8.js new file mode 100644 index 0000000000..9ee9f39c9a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-8.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - RangeError is thrown when value of + date is Date(1970, 0, -99999999, 0, 0, 0, -1), the time zone is + UTC(0) +---*/ + +var timeZoneMinutes = new Date().getTimezoneOffset() * (-1); +var date, dateStr; +assert.throws(RangeError, function() { + if (timeZoneMinutes > 0) { + date = new Date(1970, 0, -99999999, 0, 0, 0, -1); + } else { + date = new Date(1970, 0, -99999999, 0, 0 + timeZoneMinutes - 60, 0, -1); + } + + dateStr = date.toISOString(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-9.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-9.js new file mode 100644 index 0000000000..1dd2bd9875 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/15.9.5.43-0-9.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString - RangeError is not thrown when value + of date is Date(1970, 0, -99999999, 0, 0, 0, 0), the time zone is + UTC(0) +---*/ + +var timeZoneMinutes = new Date().getTimezoneOffset() * (-1); +var date, dateStr; + +if (timeZoneMinutes > 0) { + date = new Date(1970, 0, -99999999, 0, 0, 0, 0); + + assert.throws(RangeError, function() { + date.toISOString(); + }); +} else { + date = new Date(1970, 0, -99999999, 0, 0 + timeZoneMinutes + 60, 0, 0); + + dateStr = date.toISOString(); + + assert.sameValue(dateStr[dateStr.length - 1], "Z"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/browser.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/name.js new file mode 100644 index 0000000000..1abb089310 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toisostring +description: > + Date.prototype.toISOString.name is "toISOString". +info: | + Date.prototype.toISOString ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.toISOString.name, "toISOString"); + +verifyNotEnumerable(Date.prototype.toISOString, "name"); +verifyNotWritable(Date.prototype.toISOString, "name"); +verifyConfigurable(Date.prototype.toISOString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/not-a-constructor.js new file mode 100644 index 0000000000..a3dd9891ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.toISOString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.toISOString), + false, + 'isConstructor(Date.prototype.toISOString) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.toISOString(); +}, '`let date = new Date(Date.now()); new date.toISOString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toISOString/shell.js b/js/src/tests/test262/built-ins/Date/prototype/toISOString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toISOString/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/browser.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/builtin.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/builtin.js new file mode 100644 index 0000000000..cccb5c7e2e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/builtin.js @@ -0,0 +1,26 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + Tests that Date.prototype.toJSON meets the requirements + for built-in objects defined by the introduction of chapter 17 of + the ECMAScript Language Specification. +features: [Reflect.construct] +---*/ + +assert(Object.isExtensible(Date.prototype.toJSON), 'Object.isExtensible(Date.prototype.toJSON) must return true'); +assert.sameValue(typeof Date.prototype.toJSON, 'function', 'The value of `typeof Date.prototype.toJSON` is "function"'); +assert.sameValue( + Object.prototype.toString.call(Date.prototype.toJSON), + '[object Function]', + 'Object.prototype.toString.call(Date.prototype.toJSON) must return "[object Function]"' +); +assert.sameValue( + Object.getPrototypeOf(Date.prototype.toJSON), + Function.prototype, + 'Object.getPrototypeOf(Date.prototype.toJSON) must return the value of Function.prototype' +); +assert.sameValue(Date.prototype.toJSON.hasOwnProperty('prototype'), false, 'Date.prototype.toJSON.hasOwnProperty("prototype") must return false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/called-as-function.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/called-as-function.js new file mode 100644 index 0000000000..06e9775c6c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/called-as-function.js @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.tojson +description: > + `this` value is resolved using strict mode semantics, + throwing TypeError if called as top-level function. +info: | + Date.prototype.toJSON ( key ) + + 1. Let O be ? ToObject(this value). + + ToObject ( argument ) + + Argument Type: Undefined + Result: Throw a TypeError exception. +features: [Symbol, Symbol.toPrimitive] +---*/ + +[Symbol.toPrimitive, "toString", "valueOf", "toISOString"].forEach(function(key) { + Object.defineProperty(this, key, { + get: function() { + throw new Test262Error(String(key) + " lookup should not be performed"); + }, + }); +}, this); + +var toJSON = Date.prototype.toJSON; +assert.throws(TypeError, function() { + toJSON(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/invoke-abrupt.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/invoke-abrupt.js new file mode 100644 index 0000000000..0fba650fa8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/invoke-abrupt.js @@ -0,0 +1,40 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + Abrupt completion from GetV or Call. +info: | + Date.prototype.toJSON ( key ) + + [...] + 4. Return ? Invoke(O, "toISOString"). + + Invoke ( V, P [ , argumentsList ] ) + + [...] + 3. Let func be ? GetV(V, P). + 4. Return ? Call(func, V, argumentsList). +---*/ + +var abruptGet = { + get toISOString() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + Date.prototype.toJSON.call(abruptGet); +}); + +var abruptCall = { + toISOString() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + Date.prototype.toJSON.call(abruptCall); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/invoke-arguments.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/invoke-arguments.js new file mode 100644 index 0000000000..59638976cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/invoke-arguments.js @@ -0,0 +1,44 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + toISOString is called with correct context and without arguments. +info: | + Date.prototype.toJSON ( key ) + + [...] + 4. Return ? Invoke(O, "toISOString"). + + Invoke ( V, P [ , argumentsList ] ) + + [...] + 3. Let func be ? GetV(V, P). + 4. Return ? Call(func, V, argumentsList). +---*/ + +var getCount = 0, getContext; +var callCount = 0, callContext, callArguments; +var obj = { + get toISOString() { + getCount += 1; + getContext = this; + + return function() { + callCount += 1; + callContext = this; + callArguments = arguments; + }; + }, +}; + +Date.prototype.toJSON.call(obj); + +assert.sameValue(getCount, 1); +assert.sameValue(getContext, obj); + +assert.sameValue(callCount, 1); +assert.sameValue(callContext, obj); +assert.sameValue(callArguments.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/invoke-result.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/invoke-result.js new file mode 100644 index 0000000000..2f98510e64 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/invoke-result.js @@ -0,0 +1,31 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + Result of toISOString call is returned. +info: | + Date.prototype.toJSON ( key ) + + [...] + 4. Return ? Invoke(O, "toISOString"). + + Invoke ( V, P [ , argumentsList ] ) + + [...] + 3. Let func be ? GetV(V, P). + 4. Return ? Call(func, V, argumentsList). +---*/ + +var date = new Date(); +assert.sameValue(date.toJSON(), date.toISOString()); + +var result = {}; +assert.sameValue( + Date.prototype.toJSON.call({ + toISOString: function() { return result; }, + }), + result +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/length.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/length.js new file mode 100644 index 0000000000..a4186d87dc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/length.js @@ -0,0 +1,25 @@ +// Copyright (C) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + Date.prototype.toJSON.length is 1. +info: | + Date.prototype.toJSON ( key ) + + ECMAScript Standard Built-in Objects + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +verifyProperty(Date.prototype.toJSON, 'length', { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/name.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/name.js new file mode 100644 index 0000000000..ca4abc27f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.tojson +description: > + Date.prototype.toJSON.name is "toJSON". +info: | + Date.prototype.toJSON ( key ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +verifyProperty(Date.prototype.toJSON, 'name', { + value: 'toJSON', + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/non-finite.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/non-finite.js new file mode 100644 index 0000000000..f3f6753a04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/non-finite.js @@ -0,0 +1,29 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + If this value coerces to non-finite number, null is returned. +info: | + Date.prototype.toJSON ( key ) + + [...] + 2. Let tv be ? ToPrimitive(O, hint Number). + 3. If Type(tv) is Number and tv is not finite, return null. +---*/ + +var toJSON = Date.prototype.toJSON; + +assert.sameValue( + toJSON.call({ + get toISOString() { throw new Test262Error(); }, + valueOf: function() { return NaN; }, + }), + null +); + +var num = new Number(-Infinity); +num.toISOString = function() { throw new Test262Error(); }; +assert.sameValue(toJSON.call(num), null); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/not-a-constructor.js new file mode 100644 index 0000000000..df5faff002 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.toJSON does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.toJSON), + false, + 'isConstructor(Date.prototype.toJSON) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.toJSON(); +}, '`let date = new Date(Date.now()); new date.toJSON()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/shell.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-object.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-object.js new file mode 100644 index 0000000000..579cc102a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-object.js @@ -0,0 +1,31 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + This value is coerced to an object. +info: | + Date.prototype.toJSON ( key ) + + 1. Let O be ? ToObject(this value). +features: [Symbol] +---*/ + +var toJSON = Date.prototype.toJSON; +this.toISOString = function() { return 'global'; }; + +assert.throws(TypeError, function() { + toJSON.call(undefined); +}); + +assert.throws(TypeError, function() { + toJSON.call(null); +}); + +Number.prototype.toISOString = function() { return 'str'; }; +assert.sameValue(toJSON.call(10), 'str'); + +Symbol.prototype.toISOString = function() { return 10; }; +assert.sameValue(toJSON.call(Symbol()), 10); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-primitive-abrupt.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-primitive-abrupt.js new file mode 100644 index 0000000000..767d8b8240 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-primitive-abrupt.js @@ -0,0 +1,58 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + Abrupt completion from ToPrimitive. +info: | + Date.prototype.toJSON ( key ) + + [...] + 2. Let tv be ? ToPrimitive(O, hint Number). + + ToPrimitive ( input [ , PreferredType ] ) + + 1. Assert: input is an ECMAScript language value. + 2. If Type(input) is Object, then + [...] + g. Return ? OrdinaryToPrimitive(input, hint). + + OrdinaryToPrimitive ( O, hint ) + + [...] + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +---*/ + +var toJSON = Date.prototype.toJSON; +var getAbrupt = { + get valueOf() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + toJSON.call(getAbrupt); +}); + +var callAbrupt = { + toString: function() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + toJSON.call(callAbrupt); +}); + +var notCoercible = Object.create(null); + +assert.throws(TypeError, function() { + toJSON.call(notCoercible); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-primitive-symbol.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-primitive-symbol.js new file mode 100644 index 0000000000..7cf18d9060 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-primitive-symbol.js @@ -0,0 +1,47 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + This value is coerced to primitive with Number hint (exotic @@toPrimitive). +info: | + Date.prototype.toJSON ( key ) + + [...] + 2. Let tv be ? ToPrimitive(O, hint Number). + + ToPrimitive ( input [ , PreferredType ] ) + + 1. Assert: input is an ECMAScript language value. + 2. If Type(input) is Object, then + [...] + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. +features: [Symbol, Symbol.toPrimitive] +---*/ + +var callCount = 0, _this, _arguments; +var result = new Boolean(false); + +var obj = { + toISOString: function() { return result; }, + toString: function() { throw new Test262Error('should not be called'); }, + valueOf: function() { throw new Test262Error('should not be called'); }, +}; + +obj[Symbol.toPrimitive] = function() { + callCount += 1; + _this = this; + _arguments = arguments; + return 3.14; +}; + +assert.sameValue(Date.prototype.toJSON.call(obj), result); +assert.sameValue(callCount, 1); +assert.sameValue(_this, obj); +assert.sameValue(_arguments[0], 'number'); +assert.sameValue(_arguments.length, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-primitive-value-of.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-primitive-value-of.js new file mode 100644 index 0000000000..f8cf0c5f19 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-primitive-value-of.js @@ -0,0 +1,48 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + This value is coerced to primitive with Number hint (OrdinaryToPrimitive). +info: | + Date.prototype.toJSON ( key ) + + [...] + 2. Let tv be ? ToPrimitive(O, hint Number). + + ToPrimitive ( input [ , PreferredType ] ) + + 1. Assert: input is an ECMAScript language value. + 2. If Type(input) is Object, then + [...] + g. Return ? OrdinaryToPrimitive(input, hint). + + OrdinaryToPrimitive ( O, hint ) + + [...] + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. +---*/ + +var callCount = 0, _this, _arguments; +var result = []; +var obj = { + toISOString: function() { return result; }, + toString: function() { throw new Test262Error('should not be called'); }, + valueOf: function() { + callCount += 1; + _this = this; + _arguments = arguments; + return 'NaN'; + }, +}; + +assert.sameValue(Date.prototype.toJSON.call(obj), result); +assert.sameValue(callCount, 1); +assert.sameValue(_this, obj); +assert.sameValue(_arguments.length, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A1_T1.js new file mode 100644 index 0000000000..a6d4782593 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A1_T1.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "toLocaleDateString" has { DontEnum } + attributes +esid: sec-date.prototype.tolocaledatestring +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.toLocaleDateString; +if (x === 1) + Date.prototype.toLocaleDateString = 2; +else + Date.prototype.toLocaleDateString = 1; +if (Date.prototype.toLocaleDateString === x) { + $ERROR('#1: The Date.prototype.toLocaleDateString has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A1_T2.js new file mode 100644 index 0000000000..4797ee0c1f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A1_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "toLocaleDateString" has { DontEnum } + attributes +esid: sec-date.prototype.tolocaledatestring +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.toLocaleDateString === false) { + $ERROR('#1: The Date.prototype.toLocaleDateString property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('toLocaleDateString')) { + $ERROR('#2: The Date.prototype.toLocaleDateString property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A1_T3.js new file mode 100644 index 0000000000..5b65205597 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A1_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "toLocaleDateString" has { DontEnum } + attributes +esid: sec-date.prototype.tolocaledatestring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('toLocaleDateString')) { + $ERROR('#1: The Date.prototype.toLocaleDateString property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "toLocaleDateString") { + $ERROR('#2: The Date.prototype.toLocaleDateString has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A2_T1.js new file mode 100644 index 0000000000..39d5610eb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "toLocaleDateString" is 0 +esid: sec-date.prototype.tolocaledatestring +description: The "length" property of the "toLocaleDateString" is 0 +---*/ + +if (Date.prototype.toLocaleDateString.hasOwnProperty("length") !== true) { + $ERROR('#1: The toLocaleDateString has a "length" property'); +} + +if (Date.prototype.toLocaleDateString.length !== 0) { + $ERROR('#2: The "length" property of the toLocaleDateString is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A3_T1.js new file mode 100644 index 0000000000..bcfa7790ff --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toLocaleDateString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tolocaledatestring +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.toLocaleDateString.length; +verifyNotWritable(Date.prototype.toLocaleDateString, "length", null, 1); +if (Date.prototype.toLocaleDateString.length !== x) { + $ERROR('#1: The Date.prototype.toLocaleDateString.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A3_T2.js new file mode 100644 index 0000000000..2490e4b95e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toLocaleDateString property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tolocaledatestring +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.toLocaleDateString.length !== true) { + $ERROR('#1: The Date.prototype.toLocaleDateString.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.toLocaleDateString.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.toLocaleDateString.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A3_T3.js new file mode 100644 index 0000000000..8beb55b34e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/S15.9.5.6_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toLocaleDateString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tolocaledatestring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.toLocaleDateString.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.toLocaleDateString.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.toLocaleDateString) { + if (x === "length") { + $ERROR('#2: The Date.prototype.toLocaleDateString.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/browser.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/name.js new file mode 100644 index 0000000000..0f3981a565 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.tolocaledatestring +description: > + Date.prototype.toLocaleDateString.name is "toLocaleDateString". +info: | + Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.toLocaleDateString.name, "toLocaleDateString"); + +verifyNotEnumerable(Date.prototype.toLocaleDateString, "name"); +verifyNotWritable(Date.prototype.toLocaleDateString, "name"); +verifyConfigurable(Date.prototype.toLocaleDateString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/not-a-constructor.js new file mode 100644 index 0000000000..45b56d70ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.toLocaleDateString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.toLocaleDateString), + false, + 'isConstructor(Date.prototype.toLocaleDateString) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.toLocaleDateString(); +}, '`let date = new Date(Date.now()); new date.toLocaleDateString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/shell.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleDateString/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A1_T1.js new file mode 100644 index 0000000000..47d1aee3e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toLocaleString" has { DontEnum } attributes +esid: sec-date.prototype.tolocalestring +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.toLocaleString; +if (x === 1) + Date.prototype.toLocaleString = 2; +else + Date.prototype.toLocaleString = 1; +if (Date.prototype.toLocaleString === x) { + $ERROR('#1: The Date.prototype.toLocaleString has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A1_T2.js new file mode 100644 index 0000000000..53d38c0264 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toLocaleString" has { DontEnum } attributes +esid: sec-date.prototype.tolocalestring +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.toLocaleString === false) { + $ERROR('#1: The Date.prototype.toLocaleString property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('toLocaleString')) { + $ERROR('#2: The Date.prototype.toLocaleString property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A1_T3.js new file mode 100644 index 0000000000..e71894a9ad --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toLocaleString" has { DontEnum } attributes +esid: sec-date.prototype.tolocalestring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('toLocaleString')) { + $ERROR('#1: The Date.prototype.toLocaleString property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "toLocaleString") { + $ERROR('#2: The Date.prototype.toLocaleString has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A2_T1.js new file mode 100644 index 0000000000..2bb675bf79 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "toLocaleString" is 0 +esid: sec-date.prototype.tolocalestring +description: The "length" property of the "toLocaleString" is 0 +---*/ + +if (Date.prototype.toLocaleString.hasOwnProperty("length") !== true) { + $ERROR('#1: The toLocaleString has a "length" property'); +} + +if (Date.prototype.toLocaleString.length !== 0) { + $ERROR('#2: The "length" property of the toLocaleString is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A3_T1.js new file mode 100644 index 0000000000..47fa17f89d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toLocaleString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tolocalestring +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.toLocaleString.length; +verifyNotWritable(Date.prototype.toLocaleString, "length", null, 1); +if (Date.prototype.toLocaleString.length !== x) { + $ERROR('#1: The Date.prototype.toLocaleString.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A3_T2.js new file mode 100644 index 0000000000..2032afd73e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toLocaleString property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tolocalestring +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.toLocaleString.length !== true) { + $ERROR('#1: The Date.prototype.toLocaleString.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.toLocaleString.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.toLocaleString.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A3_T3.js new file mode 100644 index 0000000000..c0dcc380d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/S15.9.5.5_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toLocaleString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tolocalestring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.toLocaleString.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.toLocaleString.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.toLocaleString) { + if (x === "length") { + $ERROR('#2: The Date.prototype.toLocaleString.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/browser.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/name.js new file mode 100644 index 0000000000..1c2d1ad584 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.tolocalestring +description: > + Date.prototype.toLocaleString.name is "toLocaleString". +info: | + Date.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.toLocaleString.name, "toLocaleString"); + +verifyNotEnumerable(Date.prototype.toLocaleString, "name"); +verifyNotWritable(Date.prototype.toLocaleString, "name"); +verifyConfigurable(Date.prototype.toLocaleString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/not-a-constructor.js new file mode 100644 index 0000000000..4af86cd1e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.toLocaleString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.toLocaleString), + false, + 'isConstructor(Date.prototype.toLocaleString) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.toLocaleString(); +}, '`let date = new Date(Date.now()); new date.toLocaleString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/shell.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleString/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A1_T1.js new file mode 100644 index 0000000000..fcdd8f76e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A1_T1.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "toLocaleTimeString" has { DontEnum } + attributes +esid: sec-date.prototype.tolocaletimestring +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.toLocaleTimeString; +if (x === 1) + Date.prototype.toLocaleTimeString = 2; +else + Date.prototype.toLocaleTimeString = 1; +if (Date.prototype.toLocaleTimeString === x) { + $ERROR('#1: The Date.prototype.toLocaleTimeString has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A1_T2.js new file mode 100644 index 0000000000..f8974d5535 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A1_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "toLocaleTimeString" has { DontEnum } + attributes +esid: sec-date.prototype.tolocaletimestring +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.toLocaleTimeString === false) { + $ERROR('#1: The Date.prototype.toLocaleTimeString property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('toLocaleTimeString')) { + $ERROR('#2: The Date.prototype.toLocaleTimeString property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A1_T3.js new file mode 100644 index 0000000000..268cf064e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A1_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype property "toLocaleTimeString" has { DontEnum } + attributes +esid: sec-date.prototype.tolocaletimestring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('toLocaleTimeString')) { + $ERROR('#1: The Date.prototype.toLocaleTimeString property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "toLocaleTimeString") { + $ERROR('#2: The Date.prototype.toLocaleTimeString has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A2_T1.js new file mode 100644 index 0000000000..edc51707c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "toLocaleTimeString" is 0 +esid: sec-date.prototype.tolocaletimestring +description: The "length" property of the "toLocaleTimeString" is 0 +---*/ + +if (Date.prototype.toLocaleTimeString.hasOwnProperty("length") !== true) { + $ERROR('#1: The toLocaleTimeString has a "length" property'); +} + +if (Date.prototype.toLocaleTimeString.length !== 0) { + $ERROR('#2: The "length" property of the toLocaleTimeString is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A3_T1.js new file mode 100644 index 0000000000..2ce301c8f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toLocaleTimeString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tolocaletimestring +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.toLocaleTimeString.length; +verifyNotWritable(Date.prototype.toLocaleTimeString, "length", null, 1); +if (Date.prototype.toLocaleTimeString.length !== x) { + $ERROR('#1: The Date.prototype.toLocaleTimeString.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A3_T2.js new file mode 100644 index 0000000000..24fa1a39bc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toLocaleTimeString property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tolocaletimestring +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.toLocaleTimeString.length !== true) { + $ERROR('#1: The Date.prototype.toLocaleTimeString.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.toLocaleTimeString.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.toLocaleTimeString.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A3_T3.js new file mode 100644 index 0000000000..4bd7c58234 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/S15.9.5.7_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toLocaleTimeString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tolocaletimestring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.toLocaleTimeString.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.toLocaleTimeString.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.toLocaleTimeString) { + if (x === "length") { + $ERROR('#2: The Date.prototype.toLocaleTimeString.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/browser.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/name.js new file mode 100644 index 0000000000..260baf8b5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.tolocaletimestring +description: > + Date.prototype.toLocaleTimeString.name is "toLocaleTimeString". +info: | + Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.toLocaleTimeString.name, "toLocaleTimeString"); + +verifyNotEnumerable(Date.prototype.toLocaleTimeString, "name"); +verifyNotWritable(Date.prototype.toLocaleTimeString, "name"); +verifyConfigurable(Date.prototype.toLocaleTimeString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/not-a-constructor.js new file mode 100644 index 0000000000..6f648bb789 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.toLocaleTimeString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.toLocaleTimeString), + false, + 'isConstructor(Date.prototype.toLocaleTimeString) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.toLocaleTimeString(); +}, '`let date = new Date(Date.now()); new date.toLocaleTimeString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/shell.js b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toLocaleTimeString/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A1_T1.js new file mode 100644 index 0000000000..0fafd8cb54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toString" has { DontEnum } attributes +esid: sec-date.prototype.tostring +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.toString; +if (x === 1) + Date.prototype.toString = 2; +else + Date.prototype.toString = 1; +if (Date.prototype.toString === x) { + $ERROR('#1: The Date.prototype.toString has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A1_T2.js new file mode 100644 index 0000000000..03698a086f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toString" has { DontEnum } attributes +esid: sec-date.prototype.tostring +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.toString === false) { + $ERROR('#1: The Date.prototype.toString property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('toString')) { + $ERROR('#2: The Date.prototype.toString property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A1_T3.js new file mode 100644 index 0000000000..61a25faf0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toString" has { DontEnum } attributes +esid: sec-date.prototype.tostring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('toString')) { + $ERROR('#1: The Date.prototype.toString property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "toString") { + $ERROR('#2: The Date.prototype.toString has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A2_T1.js new file mode 100644 index 0000000000..803a64895a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "toString" is 0 +esid: sec-date.prototype.tostring +description: The "length" property of the "toString" is 0 +---*/ + +if (Date.prototype.toString.hasOwnProperty("length") !== true) { + $ERROR('#1: The toString has a "length" property'); +} + +if (Date.prototype.toString.length !== 0) { + $ERROR('#2: The "length" property of the toString is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A3_T1.js new file mode 100644 index 0000000000..207ac7ef89 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toString property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.tostring +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.toString.length; +verifyNotWritable(Date.prototype.toString, "length", null, 1); +if (Date.prototype.toString.length !== x) { + $ERROR('#1: The Date.prototype.toString.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A3_T2.js new file mode 100644 index 0000000000..c888a26ba0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toString property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tostring +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.toString.length !== true) { + $ERROR('#1: The Date.prototype.toString.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.toString.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.toString.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A3_T3.js new file mode 100644 index 0000000000..9d1df8ecb6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toString property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.tostring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.toString.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.toString.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.toString) { + if (x === "length") { + $ERROR('#2: The Date.prototype.toString.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/browser.js b/js/src/tests/test262/built-ins/Date/prototype/toString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/format.js b/js/src/tests/test262/built-ins/Date/prototype/toString/format.js new file mode 100644 index 0000000000..70aa3efe27 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/format.js @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.tostring +description: Test the format of the time from toString +info: | + Runtime Semantics: ToDateString( _tv_ ) + + 4. Return the String value formed by concatenating DateString(_t_), `" "`, TimeString(_t_), and TimeZoneString(_tv_). + +---*/ + +let stringRegExp = /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{2} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} GMT[+-][0-9]{4}( \(.+\))?$/ +let match = stringRegExp.exec(new Date().toString()); +assert.notSameValue(null, match); + +// Years are padded to the left with zeroes +match = stringRegExp.exec(new Date('0020-01-01T00:00:00Z').toString()); +assert.notSameValue(null, match); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/toString/invalid-date.js new file mode 100644 index 0000000000..9d0373a571 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/invalid-date.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-todatestring +description: Invalid Dates are rendered as "Invalid Date" +info: | + ToDateString ( tv ) + + ... + 2. If tv is NaN, return "Invalid Date". + ... +---*/ + +assert.sameValue(new Date(NaN).toString(), "Invalid Date"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toString/name.js new file mode 100644 index 0000000000..9bfd383b55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.tostring +description: > + Date.prototype.toString.name is "toString". +info: | + Date.prototype.toString ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.toString.name, "toString"); + +verifyNotEnumerable(Date.prototype.toString, "name"); +verifyNotWritable(Date.prototype.toString, "name"); +verifyConfigurable(Date.prototype.toString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/negative-year.js b/js/src/tests/test262/built-ins/Date/prototype/toString/negative-year.js new file mode 100644 index 0000000000..b1cd8d2d2c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/negative-year.js @@ -0,0 +1,36 @@ +// Copyright (C) 2018 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Negative years must be serialized with at least four digits +esid: sec-date.prototype.tostring +info: | + Date.prototype.toString ( ) + + 2. Return ToDateString(_tv_). +---*/ + +var negative1DigitYearToString = (new Date('-000001-07-01T00:00Z')).toString(); +var negative2DigitYearToString = (new Date('-000012-07-01T00:00Z')).toString(); +var negative3DigitYearToString = (new Date('-000123-07-01T00:00Z')).toString(); +var negative4DigitYearToString = (new Date('-001234-07-01T00:00Z')).toString(); +var negative5DigitYearToString = (new Date('-012345-07-01T00:00Z')).toString(); +var negative6DigitYearToString = (new Date('-123456-07-01T00:00Z')).toString(); + +// Date.prototype.toString emits values like +// "Fri Mar 28 2019 10:23:42 GMT-0400 (Eastern Daylight Time)". +// Extract and verify just the year. +assert.sameValue(negative1DigitYearToString.split(' ')[3], '-0001', + 'Date.prototype.toString serializes year -1 to "-0001"'); +assert.sameValue(negative2DigitYearToString.split(' ')[3], '-0012', + 'Date.prototype.toString serializes year -12 to "-0012"'); +assert.sameValue(negative3DigitYearToString.split(' ')[3], '-0123', + 'Date.prototype.toString serializes year -123 to "-0123"'); +assert.sameValue(negative4DigitYearToString.split(' ')[3], '-1234', + 'Date.prototype.toString serializes year -1234 to "-1234"'); +assert.sameValue(negative5DigitYearToString.split(' ')[3], '-12345', + 'Date.prototype.toString serializes year -12345 to "-12345"'); +assert.sameValue(negative6DigitYearToString.split(' ')[3], '-123456', + 'Date.prototype.toString serializes year -123456 to "-123456"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/non-date-receiver.js b/js/src/tests/test262/built-ins/Date/prototype/toString/non-date-receiver.js new file mode 100644 index 0000000000..02ce03a839 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/non-date-receiver.js @@ -0,0 +1,22 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.tostring +description: Date.prototype.toString throws a TypeError on non-Date receivers +info: | + Date.prototype.toString ( ) + + 1. Let tv be ? thisTimeValue(this value). +---*/ + +assert.throws(TypeError, () => Date.prototype.toString()); +assert.throws(TypeError, () => Date.prototype.toString.call(undefined)); +assert.throws(TypeError, () => Date.prototype.toString.call(0)); +assert.throws(TypeError, () => Date.prototype.toString.call({})); +assert.throws(TypeError, () => + Date.prototype.toString.call("Tue Mar 21 2017 12:16:43 GMT-0400 (EDT)")); +assert.throws(TypeError, () => + Date.prototype.toString.call(1490113011493)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toString/not-a-constructor.js new file mode 100644 index 0000000000..29da7f63b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.toString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.toString), + false, + 'isConstructor(Date.prototype.toString) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.toString(); +}, '`let date = new Date(Date.now()); new date.toString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toString/shell.js b/js/src/tests/test262/built-ins/Date/prototype/toString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A1_T1.js new file mode 100644 index 0000000000..ce73828481 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toTimeString" has { DontEnum } attributes +esid: sec-date.prototype.totimestring +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.toTimeString; +if (x === 1) + Date.prototype.toTimeString = 2; +else + Date.prototype.toTimeString = 1; +if (Date.prototype.toTimeString === x) { + $ERROR('#1: The Date.prototype.toTimeString has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A1_T2.js new file mode 100644 index 0000000000..fb2202fee7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toTimeString" has { DontEnum } attributes +esid: sec-date.prototype.totimestring +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.toTimeString === false) { + $ERROR('#1: The Date.prototype.toTimeString property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('toTimeString')) { + $ERROR('#2: The Date.prototype.toTimeString property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A1_T3.js new file mode 100644 index 0000000000..f2863f6482 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toTimeString" has { DontEnum } attributes +esid: sec-date.prototype.totimestring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('toTimeString')) { + $ERROR('#1: The Date.prototype.toTimeString property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "toTimeString") { + $ERROR('#2: The Date.prototype.toTimeString has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A2_T1.js new file mode 100644 index 0000000000..5e0c4a5d8d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "toTimeString" is 0 +esid: sec-date.prototype.totimestring +description: The "length" property of the "toTimeString" is 0 +---*/ + +if (Date.prototype.toTimeString.hasOwnProperty("length") !== true) { + $ERROR('#1: The toTimeString has a "length" property'); +} + +if (Date.prototype.toTimeString.length !== 0) { + $ERROR('#2: The "length" property of the toTimeString is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A3_T1.js new file mode 100644 index 0000000000..3100d56fba --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toTimeString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.totimestring +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.toTimeString.length; +verifyNotWritable(Date.prototype.toTimeString, "length", null, 1); +if (Date.prototype.toTimeString.length !== x) { + $ERROR('#1: The Date.prototype.toTimeString.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A3_T2.js new file mode 100644 index 0000000000..d9a4bebd07 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toTimeString property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.totimestring +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.toTimeString.length !== true) { + $ERROR('#1: The Date.prototype.toTimeString.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.toTimeString.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.toTimeString.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A3_T3.js new file mode 100644 index 0000000000..cb4acac7a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/S15.9.5.4_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toTimeString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.totimestring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.toTimeString.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.toTimeString.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.toTimeString) { + if (x === "length") { + $ERROR('#2: The Date.prototype.toTimeString.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/browser.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/format.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/format.js new file mode 100644 index 0000000000..a00923a27a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/format.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.totimestring +description: Test the format of the time from toTimeString +info: | + Date.prototype.toTimeString ( ) + + 5. Return the String value formed by concatenating TimeString(_t_) and TimeZoneString(_tv_). +---*/ + +let timeRegExp = /^[0-9]{2}:[0-9]{2}:[0-9]{2} GMT[+-][0-9]{4}( \(.+\))?$/ +let match = timeRegExp.exec(new Date().toTimeString()); +assert.notSameValue(null, match); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/invalid-date.js new file mode 100644 index 0000000000..58e9ebd515 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/invalid-date.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.totimestring +description: Invalid Dates are rendered as "Invalid Date" +info: | + Date.prototype.toTimeString ( ) + + ... + 3. If tv is NaN, return "Invalid Date". + ... +---*/ + +assert.sameValue(new Date(NaN).toTimeString(), "Invalid Date"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/name.js new file mode 100644 index 0000000000..4616efbad2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.totimestring +description: > + Date.prototype.toTimeString.name is "toTimeString". +info: | + Date.prototype.toTimeString ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.toTimeString.name, "toTimeString"); + +verifyNotEnumerable(Date.prototype.toTimeString, "name"); +verifyNotWritable(Date.prototype.toTimeString, "name"); +verifyConfigurable(Date.prototype.toTimeString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/not-a-constructor.js new file mode 100644 index 0000000000..7191049f7c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.toTimeString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.toTimeString), + false, + 'isConstructor(Date.prototype.toTimeString) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.toTimeString(); +}, '`let date = new Date(Date.now()); new date.toTimeString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toTimeString/shell.js b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toTimeString/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A1_T1.js new file mode 100644 index 0000000000..e4ed576485 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toUTCString" has { DontEnum } attributes +esid: sec-date.prototype.toutcstring +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.toUTCString; +if (x === 1) + Date.prototype.toUTCString = 2; +else + Date.prototype.toUTCString = 1; +if (Date.prototype.toUTCString === x) { + $ERROR('#1: The Date.prototype.toUTCString has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A1_T2.js new file mode 100644 index 0000000000..32f9766610 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toUTCString" has { DontEnum } attributes +esid: sec-date.prototype.toutcstring +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.toUTCString === false) { + $ERROR('#1: The Date.prototype.toUTCString property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('toUTCString')) { + $ERROR('#2: The Date.prototype.toUTCString property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A1_T3.js new file mode 100644 index 0000000000..d76d01ba93 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "toUTCString" has { DontEnum } attributes +esid: sec-date.prototype.toutcstring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('toUTCString')) { + $ERROR('#1: The Date.prototype.toUTCString property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "toUTCString") { + $ERROR('#2: The Date.prototype.toUTCString has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A2_T1.js new file mode 100644 index 0000000000..73a40e5668 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "toUTCString" is 0 +esid: sec-date.prototype.toutcstring +description: The "length" property of the "toUTCString" is 0 +---*/ + +if (Date.prototype.toUTCString.hasOwnProperty("length") !== true) { + $ERROR('#1: The toUTCString has a "length" property'); +} + +if (Date.prototype.toUTCString.length !== 0) { + $ERROR('#2: The "length" property of the toUTCString is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A3_T1.js new file mode 100644 index 0000000000..08fb716d0f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toUTCString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.toutcstring +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.toUTCString.length; +verifyNotWritable(Date.prototype.toUTCString, "length", null, 1); +if (Date.prototype.toUTCString.length !== x) { + $ERROR('#1: The Date.prototype.toUTCString.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A3_T2.js new file mode 100644 index 0000000000..18879c35e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toUTCString property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.toutcstring +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.toUTCString.length !== true) { + $ERROR('#1: The Date.prototype.toUTCString.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.toUTCString.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.toUTCString.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A3_T3.js new file mode 100644 index 0000000000..6a7b1ebcfb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.toUTCString property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.toutcstring +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.toUTCString.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.toUTCString.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.toUTCString) { + if (x === "length") { + $ERROR('#2: The Date.prototype.toUTCString.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/browser.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/day-names.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/day-names.js new file mode 100644 index 0000000000..89af6499ab --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/day-names.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-todatestring-day-names +description: Test the names of days +---*/ + +assert.sameValue("Sun, 23 Mar 2014 00:00:00 GMT", + (new Date("2014-03-23T00:00:00Z")).toUTCString()); +assert.sameValue("Mon, 24 Mar 2014 00:00:00 GMT", + (new Date("2014-03-24T00:00:00Z")).toUTCString()); +assert.sameValue("Tue, 25 Mar 2014 00:00:00 GMT", + (new Date("2014-03-25T00:00:00Z")).toUTCString()); +assert.sameValue("Wed, 26 Mar 2014 00:00:00 GMT", + (new Date("2014-03-26T00:00:00Z")).toUTCString()); +assert.sameValue("Thu, 27 Mar 2014 00:00:00 GMT", + (new Date("2014-03-27T00:00:00Z")).toUTCString()); +assert.sameValue("Fri, 28 Mar 2014 00:00:00 GMT", + (new Date("2014-03-28T00:00:00Z")).toUTCString()); +assert.sameValue("Sat, 29 Mar 2014 00:00:00 GMT", + (new Date("2014-03-29T00:00:00Z")).toUTCString()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/format.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/format.js new file mode 100644 index 0000000000..54d3c07b1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/format.js @@ -0,0 +1,20 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toutcstring +description: Test the format of the date from toUTCString +info: | + Date.prototype.toUTCString ( ) + + 4. Return the String value formed by concatenating DateString(_tv_, `", "`), `" "`, and TimeString(_tv_). +---*/ + +let utcRegExp = /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat), [0-9]{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} GMT$/ +let match = utcRegExp.exec(new Date().toUTCString()); +assert.notSameValue(null, match); + +// Years are padded to the left with zeroes +assert.sameValue('Wed, 01 Jan 0020 00:00:00 GMT', new Date('0020-01-01T00:00:00Z').toUTCString()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/invalid-date.js new file mode 100644 index 0000000000..8e2e433952 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/invalid-date.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toutcstring +description: Invalid Dates are rendered as "Invalid Date" +info: | + Date.prototype.toUTCString ( ) + + ... + 3. If tv is NaN, return "Invalid Date". + ... +---*/ + +assert.sameValue(new Date(NaN).toUTCString(), "Invalid Date"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/month-names.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/month-names.js new file mode 100644 index 0000000000..e6689d109a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/month-names.js @@ -0,0 +1,34 @@ +// Copyright (C) 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-todatestring-month-names +description: Test the names of months +---*/ + +assert.sameValue("Wed, 01 Jan 2014 00:00:00 GMT", + (new Date("2014-01-01T00:00:00Z")).toUTCString()); +assert.sameValue("Sat, 01 Feb 2014 00:00:00 GMT", + (new Date("2014-02-01T00:00:00Z")).toUTCString()); +assert.sameValue("Sat, 01 Mar 2014 00:00:00 GMT", + (new Date("2014-03-01T00:00:00Z")).toUTCString()); +assert.sameValue("Tue, 01 Apr 2014 00:00:00 GMT", + (new Date("2014-04-01T00:00:00Z")).toUTCString()); +assert.sameValue("Thu, 01 May 2014 00:00:00 GMT", + (new Date("2014-05-01T00:00:00Z")).toUTCString()); +assert.sameValue("Sun, 01 Jun 2014 00:00:00 GMT", + (new Date("2014-06-01T00:00:00Z")).toUTCString()); +assert.sameValue("Tue, 01 Jul 2014 00:00:00 GMT", + (new Date("2014-07-01T00:00:00Z")).toUTCString()); +assert.sameValue("Fri, 01 Aug 2014 00:00:00 GMT", + (new Date("2014-08-01T00:00:00Z")).toUTCString()); +assert.sameValue("Mon, 01 Sep 2014 00:00:00 GMT", + (new Date("2014-09-01T00:00:00Z")).toUTCString()); +assert.sameValue("Wed, 01 Oct 2014 00:00:00 GMT", + (new Date("2014-10-01T00:00:00Z")).toUTCString()); +assert.sameValue("Sat, 01 Nov 2014 00:00:00 GMT", + (new Date("2014-11-01T00:00:00Z")).toUTCString()); +assert.sameValue("Mon, 01 Dec 2014 00:00:00 GMT", + (new Date("2014-12-01T00:00:00Z")).toUTCString()); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/name.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/name.js new file mode 100644 index 0000000000..96fb0dce00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.toutcstring +description: > + Date.prototype.toUTCString.name is "toUTCString". +info: | + Date.prototype.toUTCString ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.toUTCString.name, "toUTCString"); + +verifyNotEnumerable(Date.prototype.toUTCString, "name"); +verifyNotWritable(Date.prototype.toUTCString, "name"); +verifyConfigurable(Date.prototype.toUTCString, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/negative-year.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/negative-year.js new file mode 100644 index 0000000000..a7bbcdf30a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/negative-year.js @@ -0,0 +1,35 @@ +// Copyright (C) 2018 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: > + Negative years must be serialized with at least four digits +esid: sec-date.prototype.toutcstring +info: | + Date.prototype.toUTCString ( ) + + 10. Return the string-concatenation of _weekday_, `","`, the code unit 0x0020 (SPACE), _day_, the code unit 0x0020 (SPACE), _month_, the code unit 0x0020 (SPACE), _yearSign_, _year_, the code unit 0x0020 (SPACE), and TimeString(_tv_). +---*/ + +var negative1DigitYearToUTCString = (new Date('-000001-07-01T00:00Z')).toUTCString(); +var negative2DigitYearToUTCString = (new Date('-000012-07-01T00:00Z')).toUTCString(); +var negative3DigitYearToUTCString = (new Date('-000123-07-01T00:00Z')).toUTCString(); +var negative4DigitYearToUTCString = (new Date('-001234-07-01T00:00Z')).toUTCString(); +var negative5DigitYearToUTCString = (new Date('-012345-07-01T00:00Z')).toUTCString(); +var negative6DigitYearToUTCString = (new Date('-123456-07-01T00:00Z')).toUTCString(); + +// Date.prototype.toUTCString emits values like "Thu, 28 Mar 2019 10:23:42 GMT". +// Extract and verify just the year. +assert.sameValue(negative1DigitYearToUTCString.split(' ')[3], '-0001', + 'Date.prototype.toUTCString serializes year -1 to "-0001"'); +assert.sameValue(negative2DigitYearToUTCString.split(' ')[3], '-0012', + 'Date.prototype.toUTCString serializes year -12 to "-0012"'); +assert.sameValue(negative3DigitYearToUTCString.split(' ')[3], '-0123', + 'Date.prototype.toUTCString serializes year -123 to "-0123"'); +assert.sameValue(negative4DigitYearToUTCString.split(' ')[3], '-1234', + 'Date.prototype.toUTCString serializes year -1234 to "-1234"'); +assert.sameValue(negative5DigitYearToUTCString.split(' ')[3], '-12345', + 'Date.prototype.toUTCString serializes year -12345 to "-12345"'); +assert.sameValue(negative6DigitYearToUTCString.split(' ')[3], '-123456', + 'Date.prototype.toUTCString serializes year -123456 to "-123456"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/not-a-constructor.js new file mode 100644 index 0000000000..7c944cd036 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.toUTCString does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.toUTCString), + false, + 'isConstructor(Date.prototype.toUTCString) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.toUTCString(); +}, '`let date = new Date(Date.now()); new date.toUTCString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/toUTCString/shell.js b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T1.js new file mode 100644 index 0000000000..a5d070a0fc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "valueOf" has { DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.valueOf; +if (x === 1) + Date.prototype.valueOf = 2; +else + Date.prototype.valueOf = 1; +if (Date.prototype.valueOf === x) { + $ERROR('#1: The Date.prototype.valueOf has not the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T2.js new file mode 100644 index 0000000000..880ebc1998 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "valueOf" has { DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking absence of DontDelete attribute +---*/ + +if (delete Date.prototype.valueOf === false) { + $ERROR('#1: The Date.prototype.valueOf property has not the attributes DontDelete'); +} + +if (Date.prototype.hasOwnProperty('valueOf')) { + $ERROR('#2: The Date.prototype.valueOf property has not the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T3.js new file mode 100644 index 0000000000..3613a27ef8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The Date.prototype property "valueOf" has { DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.propertyIsEnumerable('valueOf')) { + $ERROR('#1: The Date.prototype.valueOf property has the attribute DontEnum'); +} + +for (var x in Date.prototype) { + if (x === "valueOf") { + $ERROR('#2: The Date.prototype.valueOf has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A2_T1.js new file mode 100644 index 0000000000..e1e2edc9e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The "length" property of the "valueOf" is 0 +esid: sec-date.prototype.valueof +description: The "length" property of the "valueOf" is 0 +---*/ + +if (Date.prototype.valueOf.hasOwnProperty("length") !== true) { + $ERROR('#1: The valueOf has a "length" property'); +} + +if (Date.prototype.valueOf.length !== 0) { + $ERROR('#2: The "length" property of the valueOf is 0'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T1.js new file mode 100644 index 0000000000..64e477b053 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T1.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.valueOf property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.valueOf.length; +verifyNotWritable(Date.prototype.valueOf, "length", null, 1); +if (Date.prototype.valueOf.length !== x) { + $ERROR('#1: The Date.prototype.valueOf.length has the attribute ReadOnly'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T2.js new file mode 100644 index 0000000000..3d562ee53a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.valueOf property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking DontDelete attribute +---*/ + +if (delete Date.prototype.valueOf.length !== true) { + $ERROR('#1: The Date.prototype.valueOf.length property does not have the attributes DontDelete'); +} + +if (Date.prototype.valueOf.hasOwnProperty('length')) { + $ERROR('#2: The Date.prototype.valueOf.length property does not have the attributes DontDelete'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T3.js new file mode 100644 index 0000000000..a413b63403 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S15.9.5.8_A3_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The Date.prototype.valueOf property "length" has { ReadOnly, DontDelete, + DontEnum } attributes +esid: sec-date.prototype.valueof +description: Checking DontEnum attribute +---*/ + +if (Date.prototype.valueOf.propertyIsEnumerable('length')) { + $ERROR('#1: The Date.prototype.valueOf.length property has the attribute DontEnum'); +} + +for (var x in Date.prototype.valueOf) { + if (x === "length") { + $ERROR('#2: The Date.prototype.valueOf.length has the attribute DontEnum'); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T1.js new file mode 100644 index 0000000000..8a6fbb4a95 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T1.js @@ -0,0 +1,85 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.valueof +info: | + Result of ToInteger(value) conversion is the result of computing + sign(ToNumber(value)) * floor(abs(ToNumber(value))) +es5id: 9.4_A3_T1 +description: For testing constructor Date(Number) is used +---*/ + +// CHECK#1 +var d1 = new Date(6.54321); +if (d1.valueOf() !== 6) { + $ERROR('#1: var d1 = new Date(6.54321); d1.valueOf() === 6;'); +} + +// CHECK#2 +var d2 = new Date(-6.54321); +if (d2.valueOf() !== -6) { + $ERROR('#2: var d2 = new Date(-6.54321); d2.valueOf() === -6;'); +} + +// CHECK#3 +var d3 = new Date(6.54321e2); +if (d3.valueOf() !== 654) { + $ERROR('#3: var d3 = new Date(6.54321e2); d3.valueOf() === 654;'); +} + +// CHECK#4 +var d4 = new Date(-6.54321e2); +if (d4.valueOf() !== -654) { + $ERROR('#4: var d4 = new Date(-6.54321e2); d4.valueOf() === -654;'); +} + +// CHECK#5 +var d5 = new Date(0.654321e1); +if (d5.valueOf() !== 6) { + $ERROR('#5: var d5 = new Date(0.654321e1); d5.valueOf() === 6;'); +} + +// CHECK#6 +var d6 = new Date(-0.654321e1); +if (d6.valueOf() !== -6) { + $ERROR('#6: var d6 = new Date(-0.654321e1); d6.valueOf() === -6;'); +} + +// CHECK#7 +var d7 = new Date(true); +if (d7.valueOf() !== 1) { + $ERROR('#7: var d7 = new Date(true); d7.valueOf() === 1;'); +} + +// CHECK#8 +var d8 = new Date(false); +if (d8.valueOf() !== 0) { + $ERROR('#8: var d8 = new Date(false); d8.valueOf() === 0;'); +} + +// CHECK#9 +var d9 = new Date(1.23e15); +if (d9.valueOf() !== 1.23e15) { + $ERROR('#9: var d9 = new Date(1.23e15); d9.valueOf() === 1.23e15;'); +} + +// CHECK#10 +var d10 = new Date(-1.23e15); +if (d10.valueOf() !== -1.23e15) { + $ERROR('#10: var d10 = new Date(-1.23e15); d10.valueOf() === -1.23e15;'); +} + +// CHECK#11 +var d11 = new Date(1.23e-15); +if (d11.valueOf() !== 0) { + $ERROR('#11: var d11 = new Date(1.23e-15); d11.valueOf() === 0;'); +} + +// CHECK#12 +var d12 = new Date(-1.23e-15); +if (d12.valueOf() !== -0) { + $ERROR('#12: var d12 = new Date(-1.23e-15); d12.valueOf() === -0;'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T2.js new file mode 100644 index 0000000000..e3bf46a690 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/S9.4_A3_T2.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.valueof +info: | + Result of ToInteger(value) conversion is the result of computing + sign(ToNumber(value)) * floor(abs(ToNumber(value))) +es5id: 9.4_A3_T2 +description: > + For testing constructor Date(NaN, Infinity, Infinity, +0 and -0) + is used +---*/ + +// CHECK#1 +var d1 = new Date(Number.NaN); +assert.sameValue(d1.valueOf(), NaN, "NaN"); + +// CHECK#2 +var d2 = new Date(Infinity); +assert.sameValue(d2.valueOf(), NaN, "Infinity"); + +// CHECK#3 +var d3 = new Date(-Infinity); +assert.sameValue(d3.valueOf(), NaN, "-Infinity"); + +// CHECK#4 +var d4 = new Date(0); +if (d4.valueOf() !== 0) { + $ERROR('#4: var d4 = new Date(0); d4.valueOf() === 0;'); +} + +// CHECK#5 +var d5 = new Date(-0); +if (d5.valueOf() !== -0) { + $ERROR('#5: var d5 = new Date(-0); d5.valueOf() === -0;'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/browser.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/name.js new file mode 100644 index 0000000000..e1e16eb74b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.prototype.valueof +description: > + Date.prototype.valueOf.name is "valueOf". +info: | + Date.prototype.valueOf ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Date.prototype.valueOf.name, "valueOf"); + +verifyNotEnumerable(Date.prototype.valueOf, "name"); +verifyNotWritable(Date.prototype.valueOf, "name"); +verifyConfigurable(Date.prototype.valueOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/not-a-constructor.js new file mode 100644 index 0000000000..5e333ff19e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Date.prototype.valueOf does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(Date.prototype.valueOf), + false, + 'isConstructor(Date.prototype.valueOf) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.valueOf(); +}, '`let date = new Date(Date.now()); new date.valueOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/valueOf/shell.js b/js/src/tests/test262/built-ins/Date/prototype/valueOf/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/valueOf/shell.js diff --git a/js/src/tests/test262/built-ins/Date/shell.js b/js/src/tests/test262/built-ins/Date/shell.js new file mode 100644 index 0000000000..e674025f46 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/shell.js @@ -0,0 +1,77 @@ +// GENERATED, DO NOT EDIT +// file: assertRelativeDateMs.js +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Verify that the given date object's Number representation describes the + correct number of milliseconds since the Unix epoch relative to the local + time zone (as interpreted at the specified date). +defines: [assertRelativeDateMs] +---*/ + +/** + * @param {Date} date + * @param {Number} expectedMs + */ +function assertRelativeDateMs(date, expectedMs) { + var actualMs = date.valueOf(); + var localOffset = date.getTimezoneOffset() * 60000; + + if (actualMs - localOffset !== expectedMs) { + $ERROR( + 'Expected ' + date + ' to be ' + expectedMs + + ' milliseconds from the Unix epoch' + ); + } +} + +// file: dateConstants.js +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of date-centric values +defines: + - date_1899_end + - date_1900_start + - date_1969_end + - date_1970_start + - date_1999_end + - date_2000_start + - date_2099_end + - date_2100_start + - start_of_time + - end_of_time +---*/ + +var date_1899_end = -2208988800001; +var date_1900_start = -2208988800000; +var date_1969_end = -1; +var date_1970_start = 0; +var date_1999_end = 946684799999; +var date_2000_start = 946684800000; +var date_2099_end = 4102444799999; +var date_2100_start = 4102444800000; + +var start_of_time = -8.64e15; +var end_of_time = 8.64e15; + +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +---*/ + +function isConstructor(f) { + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/Date/subclassing.js b/js/src/tests/test262/built-ins/Date/subclassing.js new file mode 100644 index 0000000000..b7f2b7134f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/subclassing.js @@ -0,0 +1,56 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: Error retrieving `Symbol.toPrimitive` method from object value +info: | + 3. If NewTarget is not undefined, then + [...] + c. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%DatePrototype%", + « [[DateValue]] »). + [...] + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , + internalSlotsList ] ) + + [...] + 2. Let proto be ? GetPrototypeFromConstructor(constructor, + intrinsicDefaultProto). + 3. Return ObjectCreate(proto, internalSlotsList). +features: [Reflect] +---*/ + +var callCount = 0; +var Ctor = function() { + callCount += 1; +}; +var instance; + +instance = Reflect.construct(Date, [64], Ctor); + +assert.sameValue( + Object.getPrototypeOf(instance), + Ctor.prototype, + 'constructor defines an object `prototype` property' +); +assert.sameValue(callCount, 0, 'constructor not invoked'); +assert.sameValue( + Date.prototype.getTime.call(instance), + 64, + 'proper subclass has a [[DateValue]] slot' +); + +Ctor.prototype = null; +instance = Reflect.construct(Date, [64], Ctor); + +assert.sameValue( + Object.getPrototypeOf(instance), + Date.prototype, + 'constructor does not defines an object `prototype` property' +); +assert.sameValue(callCount, 0, 'constructor not invoked'); +assert.sameValue( + instance.getTime(), 64, 'direct instance has a [[DateValue]] slot' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-get-symbol-to-prim-err.js b/js/src/tests/test262/built-ins/Date/value-get-symbol-to-prim-err.js new file mode 100644 index 0000000000..bee7a320be --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-get-symbol-to-prim-err.js @@ -0,0 +1,34 @@ +// Copyright (c) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: > + Behavior when error thrown while accessing `Symbol.toPrimitive` property +info: | + [...] + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, + then + [...] + b. Else, + i. Let v be ? ToPrimitive(value). + + ES6 Section 7.1.1 ToPrimitive ( input [, PreferredType] ) + + [...] + 4. Let exoticToPrim be GetMethod(input, @@toPrimitive). + 5. ReturnIfAbrupt(exoticToPrim). +features: [Symbol.toPrimitive] +---*/ + +var y = Object.defineProperty({}, Symbol.toPrimitive, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + new Date(y); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-err.js b/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-err.js new file mode 100644 index 0000000000..aa944bb968 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-err.js @@ -0,0 +1,37 @@ +// Copyright (c) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: > + Behavior when error thrown by invocation of `Symbol.toPrimitive` method + during coercion +info: | + [...] + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, + then + [...] + b. Else, + i. Let v be ? ToPrimitive(value). + + ES6 Section 7.1.1 ToPrimitive ( input [, PreferredType] ) + + [...] + 4. Let exoticToPrim be GetMethod(input, @@toPrimitive). + 5. ReturnIfAbrupt(exoticToPrim). + 6. If exoticToPrim is not undefined, then + a. Let result be Call(exoticToPrim, input, «hint»). + b. ReturnIfAbrupt(result). +features: [Symbol.toPrimitive] +---*/ + +var y = {}; +y[Symbol.toPrimitive] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + new Date(y); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-invocation.js b/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-invocation.js new file mode 100644 index 0000000000..55f8505df2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-invocation.js @@ -0,0 +1,49 @@ +// copyright (c) 2016 the v8 project authors. all rights reserved. +// this code is governed by the bsd license found in the license file. +/*--- +esid: sec-date-value +description: Invocation of `Symbol.toPrimitive` method +info: | + [...] + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, + then + [...] + b. Else, + i. Let v be ? ToPrimitive(value). + [...] + + ES6 Section 7.1.1 ToPrimitive ( input [, PreferredType] ) + + 1. If PreferredType was not passed, let hint be "default". + [...] + 4. Let exoticToPrim be GetMethod(input, @@toPrimitive). + 5. ReturnIfAbrupt(exoticToPrim). + 6. If exoticToPrim is not undefined, then + a. Let result be Call(exoticToPrim, input, «hint»). + [...] +features: [Symbol.toPrimitive] +---*/ + +var y = {}; +var callCount = 0; +var thisVal, args; + +y[Symbol.toPrimitive] = function() { + callCount += 1; + thisVal = this; + args = arguments; +}; + +new Date(y); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); +assert.sameValue(thisVal, y, '`this` value is the object being compared'); +assert.sameValue(args.length, 1, 'method invoked with exactly one argument'); +assert.sameValue( + args[0], + 'default', + 'method invoked with the string "default" as the first argument' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-return-obj.js b/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-return-obj.js new file mode 100644 index 0000000000..68fc7443d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-return-obj.js @@ -0,0 +1,48 @@ +// copyright (c) 2016 the v8 project authors. all rights reserved. +// this code is governed by the bsd license found in the license file. +/*--- +esid: sec-date-value +description: > + Behavior when coercion via `Symbol.toPrimitive` yields an Object +info: | + [...] + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, + then + [...] + b. Else, + i. Let v be ? ToPrimitive(value). + + ES6 Section 7.1.1 ToPrimitive ( input [, PreferredType] ) + + [...] + 4. Let exoticToPrim be GetMethod(input, @@toPrimitive). + 5. ReturnIfAbrupt(exoticToPrim). + 6. If exoticToPrim is not undefined, then + a. Let result be Call(exoticToPrim, input, «hint»). + b. ReturnIfAbrupt(result). + c. If Type(result) is not Object, return result. + d. Throw a TypeError exception. +features: [Symbol.toPrimitive] +---*/ + +var y = {}; +var retVal; + +y[Symbol.toPrimitive] = function() { + return retVal; +}; + +retVal = {}; +assert.throws(TypeError, function() { + new Date(y); +}, 'ordinary object'); + +retVal = (function() { + return arguments; +}()); +assert.throws(TypeError, function() { + new Date(y); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-return-prim.js b/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-return-prim.js new file mode 100644 index 0000000000..de2cf4367b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-symbol-to-prim-return-prim.js @@ -0,0 +1,46 @@ +// Copyright (c) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: > + Behavior when coercion via `Symbol.toPrimitive` yields a primitive value +info: | + [...] + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, + then + [...] + b. Else, + i. Let v be ? ToPrimitive(value). + + ES6 Section 7.1.1 ToPrimitive ( input [, PreferredType] ) + + [...] + 4. Let exoticToPrim be GetMethod(input, @@toPrimitive). + 5. ReturnIfAbrupt(exoticToPrim). + 6. If exoticToPrim is not undefined, then + a. Let result be Call(exoticToPrim, input, «hint»). + b. ReturnIfAbrupt(result). + c. If Type(result) is not Object, return result. +features: [Symbol.toPrimitive] +---*/ + +var y = {}; +var retVal; + +y[Symbol.toPrimitive] = function() { + return retVal; +}; + +retVal = 1234; +assert.sameValue(new Date(y).valueOf(), 1234); + +retVal = '2016-06-03T19:03:52.872Z'; +assert.sameValue(new Date(y).valueOf(), 1464980632872); + +retVal = Symbol.toPrimitive; +assert.throws(TypeError, function() { + new Date(y); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-to-primitive-call-err.js b/js/src/tests/test262/built-ins/Date/value-to-primitive-call-err.js new file mode 100644 index 0000000000..3a489f3860 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-to-primitive-call-err.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: Error invoking `Symbol.toPrimitive` method of object value +info: | + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, then + i. Let tv be thisTimeValue(value). + b. Else, + i. Let v be ? ToPrimitive(value). + + ToPrimitive ( input [ , PreferredType ] ) + + [...] + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). +features: [Symbol.toPrimitive] +---*/ + +var badToPrimitive = {}; +badToPrimitive[Symbol.toPrimitive] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + new Date(badToPrimitive); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-to-primitive-call.js b/js/src/tests/test262/built-ins/Date/value-to-primitive-call.js new file mode 100644 index 0000000000..a85d3ebd29 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-to-primitive-call.js @@ -0,0 +1,43 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: Invocation of `Symbol.toPrimitive` method of object value +info: | + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, then + i. Let tv be thisTimeValue(value). + b. Else, + i. Let v be ? ToPrimitive(value). + [...] + + + ToPrimitive ( input [ , PreferredType ] ) + + 1. If PreferredType was not passed, let hint be "default". + 2. Else if PreferredType is hint String, let hint be "string". + 3. Else PreferredType is hint Number, let hint be "number". + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + [...] +features: [Symbol.toPrimitive] +---*/ + +var spyToPrimitive = {}; +var callCount = 0; +var thisValue, args; +spyToPrimitive[Symbol.toPrimitive] = function() { + thisValue = this; + args = arguments; + callCount += 1; +}; + +new Date(spyToPrimitive); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); +assert.sameValue(thisValue, spyToPrimitive, 'function "this" value'); +assert.sameValue(args.length, 1, 'function invoked with exactly one argument'); +assert.sameValue(args[0], 'default', 'argument value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-to-primitive-get-meth-err.js b/js/src/tests/test262/built-ins/Date/value-to-primitive-get-meth-err.js new file mode 100644 index 0000000000..164ec4ba6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-to-primitive-get-meth-err.js @@ -0,0 +1,37 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: Error retrieving `Symbol.toPrimitive` method from object value +info: | + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, then + i. Let tv be thisTimeValue(value). + b. Else, + i. Let v be ? ToPrimitive(value). + [...] +features: [Symbol.toPrimitive] +---*/ + +var poisonedObject = {}; +var poisonedDate = new Date(); +Object.defineProperty(poisonedObject, Symbol.toPrimitive, { + get: function() { + throw new Test262Error(); + } +}); +Object.defineProperty(poisonedDate, Symbol.toPrimitive, { + get: function() { + throw new Test262Error(); + } +}); + +Date(poisonedObject); + +new Date(poisonedDate); + +assert.throws(Test262Error, function() { + new Date(poisonedObject); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-to-primitive-result-faulty.js b/js/src/tests/test262/built-ins/Date/value-to-primitive-result-faulty.js new file mode 100644 index 0000000000..a0478b66a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-to-primitive-result-faulty.js @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: Exotic `Symbol.toPrimitive` method returns a non-primitive +info: | + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, then + i. Let tv be thisTimeValue(value). + b. Else, + i. Let v be ? ToPrimitive(value). + + ToPrimitive ( input [ , PreferredType ] ) + + 1. If PreferredType was not passed, let hint be "default". + 2. Else if PreferredType is hint String, let hint be "string". + 3. Else PreferredType is hint Number, let hint be "number". + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. + c. Throw a TypeError exception. +features: [Symbol.toPrimitive] +---*/ + +var faultyToPrimitive = {}; +var returnValue; +faultyToPrimitive[Symbol.toPrimitive] = function() { + return returnValue; +}; + +returnValue = {}; +assert.throws(TypeError, function() { + new Date(faultyToPrimitive); +}, 'ordinary object'); + +returnValue = []; +assert.throws(TypeError, function() { + new Date(faultyToPrimitive); +}, 'Array exotic object'); + +returnValue = (function() { + return arguments; +}()); +assert.throws(TypeError, function() { + new Date(faultyToPrimitive); +}, 'arguments exotic object'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-to-primitive-result-non-string-prim.js b/js/src/tests/test262/built-ins/Date/value-to-primitive-result-non-string-prim.js new file mode 100644 index 0000000000..8be468338e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-to-primitive-result-non-string-prim.js @@ -0,0 +1,57 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: > + Exotic `Symbol.toPrimitive` method returns a primitive value other than a + string +info: | + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, then + i. Let tv be thisTimeValue(value). + b. Else, + i. Let v be ? ToPrimitive(value). + ii. If Type(v) is String, then + 1. Let tv be the result of parsing v as a date, in exactly the same + manner as for the parse method (20.3.3.2). If the parse resulted + in an abrupt completion, tv is the Completion Record. + + ToPrimitive ( input [ , PreferredType ] ) + + 1. If PreferredType was not passed, let hint be "default". + 2. Else if PreferredType is hint String, let hint be "string". + 3. Else PreferredType is hint Number, let hint be "number". + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. +features: [Symbol.toPrimitive] +---*/ + +var toPrimitive = {}; +var returnValue; +toPrimitive[Symbol.toPrimitive] = function() { + return returnValue; +}; + +returnValue = 8; +assert.sameValue(new Date(toPrimitive).getTime(), 8, 'number'); + +returnValue = undefined; +assert.sameValue(new Date(toPrimitive).getTime(), NaN, 'undefined'); + +returnValue = true; +assert.sameValue(new Date(toPrimitive).getTime(), 1, 'boolean `true`'); + +returnValue = false; +assert.sameValue(new Date(toPrimitive).getTime(), 0, 'boolean `false`'); + +returnValue = null; +assert.sameValue(new Date(toPrimitive).getTime(), 0, 'null'); + +returnValue = Symbol.toPrimitive; +assert.throws(TypeError, function() { + new Date(toPrimitive); +}, 'symbol'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/value-to-primitive-result-string.js b/js/src/tests/test262/built-ins/Date/value-to-primitive-result-string.js new file mode 100644 index 0000000000..0d49d2f0d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/value-to-primitive-result-string.js @@ -0,0 +1,36 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date-value +description: Exotic `Symbol.toPrimitive` method returns a String value +info: | + 3. If NewTarget is not undefined, then + a. If Type(value) is Object and value has a [[DateValue]] internal slot, then + i. Let tv be thisTimeValue(value). + b. Else, + i. Let v be ? ToPrimitive(value). + ii. If Type(v) is String, then + 1. Let tv be the result of parsing v as a date, in exactly the same + manner as for the parse method (20.3.3.2). If the parse resulted + in an abrupt completion, tv is the Completion Record. + + ToPrimitive ( input [ , PreferredType ] ) + + 1. If PreferredType was not passed, let hint be "default". + 2. Else if PreferredType is hint String, let hint be "string". + 3. Else PreferredType is hint Number, let hint be "number". + 4. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + 5. If exoticToPrim is not undefined, then + a. Let result be ? Call(exoticToPrim, input, « hint »). + b. If Type(result) is not Object, return result. +features: [Symbol.toPrimitive] +---*/ + +var stringToPrimitive = {}; +stringToPrimitive[Symbol.toPrimitive] = function() { + return '2016-06-05T18:40:00.000Z'; +}; + +assert.sameValue(new Date(stringToPrimitive).getTime(), 1465152000000); + +reportCompare(0, 0); |