summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Date/prototype/toDateString
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Date/prototype/toDateString
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Date/prototype/toDateString')
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T1.js25
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T2.js22
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A1_T3.js20
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A2_T1.js21
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T1.js24
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T2.js24
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_A3_T3.js22
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/format.js21
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/invalid-date.js17
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/name.js28
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/negative-year.js35
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/toDateString/shell.js0
14 files changed, 294 insertions, 0 deletions
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..8c3b6275c1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_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 "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;
+}
+
+assert.notSameValue(
+ Date.prototype.toDateString,
+ x,
+ 'The value of Date.prototype.toDateString 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/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..b577a2dbc5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_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 "toDateString" has { DontEnum } attributes
+esid: sec-date.prototype.todatestring
+description: Checking absence of DontDelete attribute
+---*/
+assert.notSameValue(
+ delete Date.prototype.toDateString,
+ false,
+ 'The value of delete Date.prototype.toDateString is not false'
+);
+
+assert(
+ !Date.prototype.hasOwnProperty('toDateString'),
+ 'The value of !Date.prototype.hasOwnProperty(\'toDateString\') is expected to be true'
+);
+
+// TODO: Convert to verifyProperty() format.
+
+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..19fead51e3
--- /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
+---*/
+assert(
+ !Date.prototype.propertyIsEnumerable('toDateString'),
+ 'The value of !Date.prototype.propertyIsEnumerable(\'toDateString\') is expected to be true'
+);
+
+for (var x in Date.prototype) {
+ assert.notSameValue(x, "toDateString", 'The value of x is not "toDateString"');
+}
+
+// TODO: Convert to verifyProperty() format.
+
+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..ec44678499
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_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 "toDateString" is 0
+esid: sec-date.prototype.todatestring
+description: The "length" property of the "toDateString" is 0
+---*/
+assert.sameValue(
+ Date.prototype.toDateString.hasOwnProperty("length"),
+ true,
+ 'Date.prototype.toDateString.hasOwnProperty("length") must return true'
+);
+
+assert.sameValue(
+ Date.prototype.toDateString.length,
+ 0,
+ 'The value of Date.prototype.toDateString.length is expected to be 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..ea918616ee
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_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.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);
+
+assert.sameValue(
+ Date.prototype.toDateString.length,
+ x,
+ 'The value of Date.prototype.toDateString.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/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..d56ed18a20
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/toDateString/S15.9.5.3_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.toDateString property "length" has { ReadOnly, !
+ DontDelete, DontEnum } attributes
+esid: sec-date.prototype.todatestring
+description: Checking DontDelete attribute
+---*/
+assert.sameValue(
+ delete Date.prototype.toDateString.length,
+ true,
+ 'The value of `delete Date.prototype.toDateString.length` is expected to be true'
+);
+
+assert(
+ !Date.prototype.toDateString.hasOwnProperty('length'),
+ 'The value of !Date.prototype.toDateString.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/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..fd89a02806
--- /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
+---*/
+assert(
+ !Date.prototype.toDateString.propertyIsEnumerable('length'),
+ 'The value of !Date.prototype.toDateString.propertyIsEnumerable(\'length\') is expected to be true'
+);
+
+for (var x in Date.prototype.toDateString) {
+ 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/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