diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Date/prototype/toUTCString')
16 files changed, 354 insertions, 0 deletions
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..8112c69a00 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_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 "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; +} + +assert.notSameValue( + Date.prototype.toUTCString, + x, + 'The value of Date.prototype.toUTCString 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/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..381863eb75 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A1_T2.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. + +/*--- +info: The Date.prototype property "toUTCString" has { DontEnum } attributes +esid: sec-date.prototype.toutcstring +description: Checking absence of DontDelete attribute +---*/ + +assert.notSameValue( + delete Date.prototype.toUTCString, + false, + 'The value of delete Date.prototype.toUTCString is not false' +); + +assert( + !Date.prototype.hasOwnProperty('toUTCString'), + 'The value of !Date.prototype.hasOwnProperty(\'toUTCString\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +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..9f6547954c --- /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 +---*/ +assert( + !Date.prototype.propertyIsEnumerable('toUTCString'), + 'The value of !Date.prototype.propertyIsEnumerable(\'toUTCString\') is expected to be true' +); + +for (var x in Date.prototype) { + assert.notSameValue(x, "toUTCString", 'The value of x is not "toUTCString"'); +} + +// TODO: Convert to verifyProperty() format. + +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..b7e15d69ae --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A2_T1.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 "length" property of the "toUTCString" is 0 +esid: sec-date.prototype.toutcstring +description: The "length" property of the "toUTCString" is 0 +---*/ + +assert.sameValue( + Date.prototype.toUTCString.hasOwnProperty("length"), + true, + 'Date.prototype.toUTCString.hasOwnProperty("length") must return true' +); + +assert.sameValue( + Date.prototype.toUTCString.length, + 0, + 'The value of Date.prototype.toUTCString.length is expected to be 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..37634bdfe6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_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.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); + +assert.sameValue( + Date.prototype.toUTCString.length, + x, + 'The value of Date.prototype.toUTCString.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/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..23528c870d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toUTCString/S15.9.5.42_A3_T2.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.toUTCString property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.toutcstring +description: Checking DontDelete attribute +---*/ + +assert.sameValue( + delete Date.prototype.toUTCString.length, + true, + 'The value of `delete Date.prototype.toUTCString.length` is expected to be true' +); + +assert( + !Date.prototype.toUTCString.hasOwnProperty('length'), + 'The value of !Date.prototype.toUTCString.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/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..b15da4c994 --- /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 +---*/ +assert( + !Date.prototype.toUTCString.propertyIsEnumerable('length'), + 'The value of !Date.prototype.toUTCString.propertyIsEnumerable(\'length\') is expected to be true' +); + +for (var x in Date.prototype.toUTCString) { + 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/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 |