diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear')
15 files changed, 342 insertions, 0 deletions
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..ef8e59efbd --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T1.js @@ -0,0 +1,25 @@ +// Copyright 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; +} + +assert.notSameValue( + Date.prototype.getUTCFullYear, + x, + 'The value of Date.prototype.getUTCFullYear is expected to not equal the value of `x`' +); + +// TODO: Convert to verifyProperty() format. + +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..49733ea562 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A1_T2.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 "getUTCFullYear" has { DontEnum } attributes +esid: sec-date.prototype.getutcfullyear +description: Checking absence of DontDelete attribute +---*/ +assert.notSameValue( + delete Date.prototype.getUTCFullYear, + false, + 'The value of delete Date.prototype.getUTCFullYear is not false' +); + +assert( + !Date.prototype.hasOwnProperty('getUTCFullYear'), + 'The value of !Date.prototype.hasOwnProperty(\'getUTCFullYear\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +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..7ddec587e5 --- /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 +---*/ +assert( + !Date.prototype.propertyIsEnumerable('getUTCFullYear'), + 'The value of !Date.prototype.propertyIsEnumerable(\'getUTCFullYear\') is expected to be true' +); + +for (var x in Date.prototype) { + assert.notSameValue(x, "getUTCFullYear", 'The value of x is not "getUTCFullYear"'); +} + +// TODO: Convert to verifyProperty() format. + +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..9779569d9b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A2_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 "length" property of the "getUTCFullYear" is 0 +esid: sec-date.prototype.getutcfullyear +description: The "length" property of the "getUTCFullYear" is 0 +---*/ +assert.sameValue( + Date.prototype.getUTCFullYear.hasOwnProperty("length"), + true, + 'Date.prototype.getUTCFullYear.hasOwnProperty("length") must return true' +); + +assert.sameValue( + Date.prototype.getUTCFullYear.length, + 0, + 'The value of Date.prototype.getUTCFullYear.length is expected to be 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..ae085004cc --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T1.js @@ -0,0 +1,24 @@ +// Copyright 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); + +assert.sameValue( + Date.prototype.getUTCFullYear.length, + x, + 'The value of Date.prototype.getUTCFullYear.length is expected to equal the value of x' +); + +// TODO: Convert to verifyProperty() format. + +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..8c21d6d788 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/getUTCFullYear/S15.9.5.11_A3_T2.js @@ -0,0 +1,24 @@ +// Copyright 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 +---*/ +assert.sameValue( + delete Date.prototype.getUTCFullYear.length, + true, + 'The value of `delete Date.prototype.getUTCFullYear.length` is expected to be true' +); + +assert( + !Date.prototype.getUTCFullYear.hasOwnProperty('length'), + 'The value of !Date.prototype.getUTCFullYear.hasOwnProperty(\'length\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +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..317b78bd4f --- /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 +---*/ +assert( + !Date.prototype.getUTCFullYear.propertyIsEnumerable('length'), + 'The value of !Date.prototype.getUTCFullYear.propertyIsEnumerable(\'length\') is expected to be true' +); + +for (var x in Date.prototype.getUTCFullYear) { + assert.notSameValue(x, "length", 'The value of x is not "length"'); +} + +// TODO: Convert to verifyProperty() format. + +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); |