diff options
Diffstat (limited to '')
15 files changed, 312 insertions, 0 deletions
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..6612e3a747 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_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 "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; +} + +assert.notSameValue( + Date.prototype.toString, + x, + 'The value of Date.prototype.toString 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/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..0395c2e111 --- /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 +---*/ + +assert.notSameValue(delete Date.prototype.toString, false, 'The value of delete Date.prototype.toString is not false'); +assert( + !Date.prototype.hasOwnProperty('toString'), + 'The value of !Date.prototype.hasOwnProperty(\'toString\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +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..494bbdb2ac --- /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 +---*/ +assert( + !Date.prototype.propertyIsEnumerable('toString'), + 'The value of !Date.prototype.propertyIsEnumerable(\'toString\') is expected to be true' +); + +for (var x in Date.prototype) { + assert.notSameValue(x, "toString", 'The value of x is not "toString"'); +} + +// TODO: Convert to verifyProperty() format. + +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..6139039893 --- /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 +---*/ + +assert.sameValue( + Date.prototype.toString.hasOwnProperty("length"), + true, + 'Date.prototype.toString.hasOwnProperty("length") must return true' +); + +assert.sameValue(Date.prototype.toString.length, 0, 'The value of Date.prototype.toString.length is expected to be 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..f8505716f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_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.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); + +assert.sameValue( + Date.prototype.toString.length, + x, + 'The value of Date.prototype.toString.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/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..d265d9f4c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toString/S15.9.5.2_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.toString property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.tostring +description: Checking DontDelete attribute +---*/ + +assert.sameValue( + delete Date.prototype.toString.length, + true, + 'The value of `delete Date.prototype.toString.length` is expected to be true' +); + +assert( + !Date.prototype.toString.hasOwnProperty('length'), + 'The value of !Date.prototype.toString.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/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..d4b54c6f79 --- /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 +---*/ +assert( + !Date.prototype.toString.propertyIsEnumerable('length'), + 'The value of !Date.prototype.toString.propertyIsEnumerable(\'length\') is expected to be true' +); + +for (var x in Date.prototype.toString) { + 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/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 |