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/annexB/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/annexB/built-ins/Date')
32 files changed, 705 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/built-ins/Date/browser.js b/js/src/tests/test262/annexB/built-ins/Date/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/browser.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/B.2.4.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/B.2.4.js new file mode 100644 index 0000000000..4e6091dd06 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/B.2.4.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: B.2.4 +description: > + Object.getOwnPropertyDescriptor returns data desc for functions on + built-ins (Date.prototype.getYear) +includes: [propertyHelper.js] +---*/ + +verifyProperty(Date.prototype, "getYear", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/browser.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/length.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/length.js new file mode 100644 index 0000000000..72bb65b0e7 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.4.1 +description: > + Date.prototype.getYear.length is 0. +info: | + Date.prototype.getYear ( ) + + 17 ECMAScript Standard Built-in Objects: + 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. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + 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.getYear, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/name.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/name.js new file mode 100644 index 0000000000..6a3db43a9f --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/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. + +/*--- +es6id: B.2.4.1 +description: > + Date.prototype.getYear.name is "getYear". +info: | + Date.prototype.getYear ( ) + + 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.getYear, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "getYear" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/nan.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/nan.js new file mode 100644 index 0000000000..121c54fcd5 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/nan.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.getyear +es6id: B.2.4.1 +es5id: B.2.4 +description: NaN time value +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. +---*/ + +var date = new Date({}); + +assert.sameValue(date.getYear(), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/not-a-constructor.js new file mode 100644 index 0000000000..a3936a335e --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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.getYear 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.getYear), + false, + 'isConstructor(Date.prototype.getYear) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.getYear(); +}, '`let date = new Date(Date.now()); new date.getYear()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/return-value.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/return-value.js new file mode 100644 index 0000000000..1df44ae303 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/return-value.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.getyear +es6id: B.2.4.1 +es5id: B.2.4 +description: > + Return value for objects with numeric value in [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, return NaN. + 3. Return YearFromTime(LocalTime(t)) - 1900. +---*/ + +assert.sameValue(new Date(1899, 0).getYear(), -1, '1899: first millisecond'); +assert.sameValue( + new Date(1899, 11, 31, 23, 59, 59, 999).getYear(), + -1, + '1899: final millisecond' +); + +assert.sameValue(new Date(1900, 0).getYear(), 0, '1900: first millisecond'); +assert.sameValue( + new Date(1900, 11, 31, 23, 59, 59, 999).getYear(), + 0, + '1900: final millisecond' +); + +assert.sameValue(new Date(1970, 0).getYear(), 70, '1970: first millisecond'); +assert.sameValue( + new Date(1970, 11, 31, 23, 59, 59, 999).getYear(), + 70, + '1970: final millisecond' +); + +assert.sameValue(new Date(2000, 0).getYear(), 100, '2000: first millisecond'); +assert.sameValue( + new Date(2000, 11, 31, 23, 59, 59, 999).getYear(), + 100, + '2000: final millisecond' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/shell.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/shell.js @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT +// 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/annexB/built-ins/Date/prototype/getYear/this-not-date.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/this-not-date.js new file mode 100644 index 0000000000..cb6888f80a --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/getYear/this-not-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.getyear +es6id: B.2.4.1 +es5id: B.2.4 +description: Behavior when `this` value has no [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). +---*/ + +var getYear = Date.prototype.getYear; + +assert.sameValue(typeof getYear, 'function'); + +assert.throws(TypeError, function() { + getYear.call({}); +}, 'object'); + +assert.throws(TypeError, function() { + getYear.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + getYear.call(null); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/B.2.5.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/B.2.5.js new file mode 100644 index 0000000000..91eb6f7451 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/B.2.5.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: B.2.5 +description: > + Object.getOwnPropertyDescriptor returns data desc for functions on + built-ins (Date.prototype.setYear) +includes: [propertyHelper.js] +---*/ + +verifyProperty(Date.prototype, "setYear", { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/browser.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/length.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/length.js new file mode 100644 index 0000000000..946c22d3d1 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: B.2.4.2 +description: > + Date.prototype.setYear.length is 1. +info: | + Date.prototype.setYear ( ) + + 17 ECMAScript Standard Built-in Objects: + 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. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + 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.setYear, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/name.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/name.js new file mode 100644 index 0000000000..f35e39d327 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/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. + +/*--- +es6id: B.2.4.2 +description: > + Date.prototype.setYear.name is "setYear". +info: | + Date.prototype.setYear ( ) + + 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.setYear, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "setYear" +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/not-a-constructor.js new file mode 100644 index 0000000000..906214fde4 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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.setYear 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.setYear), + false, + 'isConstructor(Date.prototype.setYear) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setYear(); +}, '`let date = new Date(Date.now()); new date.setYear()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/shell.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/shell.js @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT +// 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/annexB/built-ins/Date/prototype/setYear/this-not-date.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/this-not-date.js new file mode 100644 index 0000000000..15614f98e3 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/this-not-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.setyear +es6id: B.2.4.2 +es5id: B.2.5 +description: Behavior when "this" value has no [[DateValue]] internal slot +info: | + 1. Let t be ? thisTimeValue(this value). +---*/ + +var setYear = Date.prototype.setYear; + +assert.sameValue(typeof setYear, 'function'); + +assert.throws(TypeError, function() { + setYear.call({}, 1); +}, 'object'); + +assert.throws(TypeError, function() { + setYear.call(undefined, 1); +}, 'undefined'); + +assert.throws(TypeError, function() { + setYear.call(null, 1); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/this-time-nan.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/this-time-nan.js new file mode 100644 index 0000000000..fb99ad3765 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/this-time-nan.js @@ -0,0 +1,20 @@ +// 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.setyear +es6id: B.2.4.2 +es5id: B.2.5 +description: > + Behavior when the [[DateValue]] internal slot of "this" value is NaN +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). +---*/ + +var date = new Date({}); +var expected = new Date(1971, 0).valueOf(); + +assert.sameValue(date.setYear(71), expected, 'method return value'); +assert.sameValue(date.valueOf(), expected, '[[DateValue]] internal slot'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/this-time-valid.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/this-time-valid.js new file mode 100644 index 0000000000..35ccee0fbf --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/this-time-valid.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.prototype.setyear +es6id: B.2.4.2 +es5id: B.2.5 +description: > + Behavior when the [[DateValue]] internal slot of "this" value is an integer + value +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). +---*/ + +var date = new Date(1970, 1, 2, 3, 4, 5); +var expected = new Date(1971, 1, 2, 3, 4, 5).valueOf(); + +assert.sameValue(date.setYear(71), expected, 'method return value'); +assert.sameValue(date.valueOf(), expected, '[[DateValue]] internal slot'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/time-clip.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/time-clip.js new file mode 100644 index 0000000000..f296e204ab --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/time-clip.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.setyear +es6id: B.2.4.2 +es5id: B.2.5 +description: Clipping of new time value +info: | + [...] + 9. Set the [[DateValue]] internal slot of this Date object to + TimeClip(date). + 10. Return the value of the [[DateValue]] internal slot of this Date + object. +---*/ + +var date; + +date = new Date(1970, 8, 10, 0, 0, 0, 0); + +assert.notSameValue( + date.setYear(275760), NaN, 'method return value (valid date)' +); +assert.notSameValue( + date.valueOf(), NaN, '[[DateValue]] internal slot (valid date)' +); + +date = new Date(1970, 8, 14, 0, 0, 0, 0); + +assert.sameValue( + date.setYear(275760), NaN, 'method return value (invalid date)' +); +assert.sameValue( + date.valueOf(), NaN, '[[DateValue]] internal slot (invalid date)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-nan.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-nan.js new file mode 100644 index 0000000000..9a14f8f777 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-nan.js @@ -0,0 +1,38 @@ +// 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.setyear +es6id: B.2.4.2 +es5id: B.2.5 +description: Behavior when year value coerces to NaN +info: | + [...] + 3. Let y be ? ToNumber(year). + 4. If y is NaN, set the [[DateValue]] internal slot of this Date object to + NaN and return NaN. +features: [Symbol] +---*/ + +var date; + +date = new Date(); +assert.sameValue(date.setYear(), NaN, 'return value (no argument)'); +assert.sameValue( + date.valueOf(), NaN, '[[DateValue]] internal slot (no argument)' +); + +date = new Date(); +assert.sameValue(date.setYear(NaN), NaN, 'return value (literal NaN)'); +assert.sameValue( + date.valueOf(), NaN, '[[DateValue]] internal slot (literal NaN)' +); + +date = new Date(); +assert.sameValue( + date.setYear('not a number'), NaN, 'return value (NaN from ToNumber)' +); +assert.sameValue( + date.valueOf(), NaN, '[[DateValue]] internal slot (NaN from ToNumber)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-number-absolute.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-number-absolute.js new file mode 100644 index 0000000000..61cc1d91a3 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-number-absolute.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.setyear +es6id: B.2.4.2 +es5id: B.2.5 +description: > + Behavior when the integer representation of the specified `year` is not + relative to 1900 +info: | + [...] + 5. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yyyy be ToInteger(y) + + 1900. + 6. Else, let yyyy be y. + [...] +---*/ + +var date; + +date = new Date(1970, 0); +date.setYear(-1); +assert.sameValue(date.getFullYear(), -1); + +date = new Date(1970, 0); +date.setYear(100); +assert.sameValue(date.getFullYear(), 100); + +date = new Date(1970, 0); +date.setYear(1899); +assert.sameValue(date.getFullYear(), 1899); + +date = new Date(1970, 0); +date.setYear(1900); +assert.sameValue(date.getFullYear(), 1900); + +date = new Date(1970, 0); +date.setYear(1999); +assert.sameValue(date.getFullYear(), 1999); + +date = new Date(1970, 0); +date.setYear(2000); +assert.sameValue(date.getFullYear(), 2000); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-number-relative.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-number-relative.js new file mode 100644 index 0000000000..632acfa129 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-number-relative.js @@ -0,0 +1,47 @@ +// 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.setyear +es6id: B.2.4.2 +es5id: B.2.5 +description: > + Behavior when the integer representation of the specified `year` is + relative to 1900 +info: | + [...] + 5. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yyyy be ToInteger(y) + + 1900. + [...] +---*/ + +var date; + +date = new Date(1970, 0); +date.setYear(-0.9999999); +assert.sameValue(date.getFullYear(), 1900, 'y = -0.999999'); + +date = new Date(1970, 0); +date.setYear(-0); +assert.sameValue(date.getFullYear(), 1900, 'y = -0'); + +date = new Date(1970, 0); +date.setYear(0); +assert.sameValue(date.getFullYear(), 1900, 'y = 0'); + +date = new Date(1970, 0); +date.setYear(50); +assert.sameValue(date.getFullYear(), 1950, 'y = 50'); + +date = new Date(1970, 0); +date.setYear(50.999999); +assert.sameValue(date.getFullYear(), 1950, 'y = 50.999999'); + +date = new Date(1970, 0); +date.setYear(99); +assert.sameValue(date.getFullYear(), 1999, 'y = 99'); + +date = new Date(1970, 0); +date.setYear(99.999999); +assert.sameValue(date.getFullYear(), 1999, 'y = 99.999999'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-to-number-err.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-to-number-err.js new file mode 100644 index 0000000000..d7e318f571 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-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.setyear +es6id: B.2.4.2 +es5id: B.2.5 +description: > + Behavior when calling ToNumber on year value returns an abrupt completion +info: | + [...] + 3. Let y be ? ToNumber(year). +features: [Symbol] +---*/ + +var date = new Date(); +var symbol = Symbol(''); +var year = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setYear(year); +}); + +assert.throws(TypeError, function() { + date.setYear(symbol); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/shell.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/shell.js diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/browser.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/browser.js diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/not-a-constructor.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/not-a-constructor.js new file mode 100644 index 0000000000..bb6c5f412f --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/not-a-constructor.js @@ -0,0 +1,34 @@ +// 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.toGMTString 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.toGMTString), + false, + 'isConstructor(Date.prototype.toGMTString) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.toGMTString(); +}, '`let date = new Date(Date.now()); new date.toGMTString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/prop-desc.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/prop-desc.js new file mode 100644 index 0000000000..c7f55f91a1 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/prop-desc.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: B.2.6 +description: > + Object.getOwnPropertyDescriptor returns data desc for functions on + built-ins (Date.prototype.toGMTString) +includes: [propertyHelper.js] + +---*/ + +verifyProperty(Date.prototype, "toGMTString", { + enumerable: false, + writable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/shell.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/shell.js new file mode 100644 index 0000000000..54371b7789 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/shell.js @@ -0,0 +1,19 @@ +// GENERATED, DO NOT EDIT +// 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/annexB/built-ins/Date/prototype/toGMTString/value.js b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/value.js new file mode 100644 index 0000000000..27e9f98edd --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/prototype/toGMTString/value.js @@ -0,0 +1,16 @@ +// 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.togmtstring +es6id: B.2.4.3 +es5id: B.2.6 +description: Value of `Date.prototype.toGMTString` +info: | + The function object that is the initial value of Date.prototype.toGMTString + is the same function object that is the initial value of + Date.prototype.toUTCString. +---*/ + +assert.sameValue(Date.prototype.toGMTString, Date.prototype.toUTCString); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/built-ins/Date/shell.js b/js/src/tests/test262/annexB/built-ins/Date/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/Date/shell.js |