summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Date/parse
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Date/parse
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.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/parse')
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T1.js20
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T2.js14
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T3.js20
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A2_T1.js12
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T1.js19
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T2.js20
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T3.js22
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/name.js28
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js41
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/without-utc-offset.js19
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/year-zero.js22
-rw-r--r--js/src/tests/test262/built-ins/Date/parse/zero.js32
15 files changed, 300 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T1.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T1.js
new file mode 100644
index 0000000000..3409d2dfff
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T1.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 property "parse" has { DontEnum } attributes
+esid: sec-date.parse
+description: Checking absence of ReadOnly attribute
+---*/
+
+var x = Date.parse;
+if (x === 1) {
+ Date.parse = 2;
+} else {
+ Date.parse = 1;
+}
+assert.notSameValue(Date.parse, x, 'The value of Date.parse 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/parse/S15.9.4.2_A1_T2.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T2.js
new file mode 100644
index 0000000000..c0991c97d4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T2.js
@@ -0,0 +1,14 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: The Date property "parse" has { DontEnum } attributes
+esid: sec-date.parse
+description: Checking absence of DontDelete attribute
+---*/
+assert.notSameValue(delete Date.parse, false, 'The value of delete Date.parse is not false');
+assert(!Date.hasOwnProperty('parse'), 'The value of !Date.hasOwnProperty(\'parse\') is expected to be true');
+
+// TODO: Convert to verifyProperty() format.
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T3.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A1_T3.js
new file mode 100644
index 0000000000..e5f2523137
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.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 property "parse" has { DontEnum } attributes
+esid: sec-date.parse
+description: Checking DontEnum attribute
+---*/
+assert(
+ !Date.propertyIsEnumerable('parse'),
+ 'The value of !Date.propertyIsEnumerable(\'parse\') is expected to be true'
+);
+
+for (var x in Date) {
+ assert.notSameValue(x, "parse", 'The value of x is not "parse"');
+}
+
+// TODO: Convert to verifyProperty() format.
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A2_T1.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A2_T1.js
new file mode 100644
index 0000000000..d066cbbd07
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A2_T1.js
@@ -0,0 +1,12 @@
+// 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 "parse" is 1
+esid: sec-date.parse
+description: The "length" property of the "parse" is 1
+---*/
+assert.sameValue(Date.parse.hasOwnProperty("length"), true, 'Date.parse.hasOwnProperty("length") must return true');
+assert.sameValue(Date.parse.length, 1, 'The value of Date.parse.length is expected to be 1');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T1.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T1.js
new file mode 100644
index 0000000000..0c0929164c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T1.js
@@ -0,0 +1,19 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+ The Date.parse property "length" has { ReadOnly, DontDelete, DontEnum }
+ attributes
+esid: sec-date.parse
+description: Checking ReadOnly attribute
+includes: [propertyHelper.js]
+---*/
+
+var x = Date.parse.length;
+verifyNotWritable(Date.parse, "length", null, 1);
+assert.sameValue(Date.parse.length, x, 'The value of Date.parse.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/parse/S15.9.4.2_A3_T2.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T2.js
new file mode 100644
index 0000000000..f224b1fbc2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T2.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.parse property "length" has { ReadOnly, ! DontDelete, DontEnum }
+ attributes
+esid: sec-date.parse
+description: Checking DontDelete attribute
+---*/
+assert.sameValue(delete Date.parse.length, true, 'The value of `delete Date.parse.length` is expected to be true');
+
+assert(
+ !Date.parse.hasOwnProperty('length'),
+ 'The value of !Date.parse.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/parse/S15.9.4.2_A3_T3.js b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.2_A3_T3.js
new file mode 100644
index 0000000000..4c7735de22
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/S15.9.4.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.parse property "length" has { ReadOnly, DontDelete, DontEnum }
+ attributes
+esid: sec-date.parse
+description: Checking DontEnum attribute
+---*/
+assert(
+ !Date.parse.propertyIsEnumerable('length'),
+ 'The value of !Date.parse.propertyIsEnumerable(\'length\') is expected to be true'
+);
+
+for (var x in Date.parse) {
+ 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/parse/browser.js b/js/src/tests/test262/built-ins/Date/parse/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/browser.js
diff --git a/js/src/tests/test262/built-ins/Date/parse/name.js b/js/src/tests/test262/built-ins/Date/parse/name.js
new file mode 100644
index 0000000000..79595c22f8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/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.parse
+description: >
+ Date.parse.name is "parse".
+info: |
+ Date.parse ( string )
+
+ 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.parse.name, "parse");
+
+verifyNotEnumerable(Date.parse, "name");
+verifyNotWritable(Date.parse, "name");
+verifyConfigurable(Date.parse, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js
new file mode 100644
index 0000000000..01551a621c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/not-a-constructor.js
@@ -0,0 +1,31 @@
+// 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.parse 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.parse), false, 'isConstructor(Date.parse) must return false');
+
+assert.throws(TypeError, () => {
+ new Date.parse();
+}, '`new Date.parse()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/parse/shell.js b/js/src/tests/test262/built-ins/Date/parse/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/shell.js
diff --git a/js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js b/js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js
new file mode 100644
index 0000000000..9dffe30587
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/time-value-maximum-range.js
@@ -0,0 +1,41 @@
+// Copyright (C) 2018 Andrew Paprocki. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-date.parse
+description: >
+ Date.parse return value is limited to specified time value maximum range
+info: |
+ Date.parse ( string )
+
+ parse interprets the resulting String as a date and time; it returns a
+ Number, the UTC time value corresponding to the date and time.
+
+ A Date object contains a Number indicating a particular instant in time to
+ within a millisecond. Such a Number is called a time value.
+
+ The actual range of times supported by ECMAScript Date objects is slightly
+ smaller: exactly -100,000,000 days to 100,000,000 days measured relative to
+ midnight at the beginning of 01 January, 1970 UTC. This gives a range of
+ 8,640,000,000,000,000 milliseconds to either side of 01 January, 1970 UTC.
+---*/
+
+const minDateStr = "-271821-04-20T00:00:00.000Z";
+const minDate = new Date(-8640000000000000);
+
+assert.sameValue(minDate.toISOString(), minDateStr, "minDateStr");
+assert.sameValue(Date.parse(minDateStr), minDate.valueOf(), "parse minDateStr");
+
+const maxDateStr = "+275760-09-13T00:00:00.000Z";
+const maxDate = new Date(8640000000000000);
+
+assert.sameValue(maxDate.toISOString(), maxDateStr, "maxDateStr");
+assert.sameValue(Date.parse(maxDateStr), maxDate.valueOf(), "parse maxDateStr");
+
+const belowRange = "-271821-04-19T23:59:59.999Z";
+const aboveRange = "+275760-09-13T00:00:00.001Z";
+
+assert.sameValue(Date.parse(belowRange), NaN, "parse below minimum time value");
+assert.sameValue(Date.parse(aboveRange), NaN, "parse above maximum time value");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/parse/without-utc-offset.js b/js/src/tests/test262/built-ins/Date/parse/without-utc-offset.js
new file mode 100644
index 0000000000..dbe0fbab7c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/without-utc-offset.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2020 Sony Interactive Entertainment Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.parse
+description: >
+ Offsetless date-time strings are local time, offsetless date-only strings are UTC time
+info: |
+ Date.parse ( string )
+
+ When the UTC offset representation is absent, date-only forms are interpreted
+ as a UTC time and date-time forms are interpreted as a local time.
+---*/
+
+const timezoneOffsetMS = new Date(0).getTimezoneOffset() * 60000;
+
+assert.sameValue(Date.parse('1970-01-01T00:00:00'), timezoneOffsetMS);
+assert.sameValue(Date.parse('1970-01-01'), 0);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/parse/year-zero.js b/js/src/tests/test262/built-ins/Date/parse/year-zero.js
new file mode 100644
index 0000000000..f04147e590
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/year-zero.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2022 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-expanded-years
+description: Negative zero, as an extended year, is rejected
+info: |
+ The year 0 is considered positive and must be prefixed with a + sign. The
+ representation of the year 0 as -000000 is invalid.
+---*/
+
+const invalidStrings = [
+ "-000000-03-31T00:45Z",
+ "-000000-03-31T01:45",
+ "-000000-03-31T01:45:00+01:00"
+];
+
+for (const str of invalidStrings) {
+ assert.sameValue(Date.parse(str), NaN, "reject minus zero as extended year");
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/parse/zero.js b/js/src/tests/test262/built-ins/Date/parse/zero.js
new file mode 100644
index 0000000000..5e7e7c0e87
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/parse/zero.js
@@ -0,0 +1,32 @@
+// Copyright (C) 2018 Andrew Paprocki. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-date.parse
+description: >
+ Date.parse of toString/toUTCString/toISOString of zero value is zero
+info: |
+ Date.parse ( string )
+
+ If x is any Date object whose milliseconds amount is zero within a
+ particular implementation of ECMAScript, then all of the following
+ expressions should produce the same numeric value in that
+ implementation, if all the properties referenced have their initial
+ values:
+
+ x.valueOf()
+ Date.parse(x.toString())
+ Date.parse(x.toUTCString())
+ Date.parse(x.toISOString())
+---*/
+
+const zero = new Date(0);
+
+assert.sameValue(zero.valueOf(), Date.parse(zero.toString()),
+ "Date.parse(zeroDate.toString())");
+assert.sameValue(zero.valueOf(), Date.parse(zero.toUTCString()),
+ "Date.parse(zeroDate.toUTCString())");
+assert.sameValue(zero.valueOf(), Date.parse(zero.toISOString()),
+ "Date.parse(zeroDate.toISOString())");
+
+reportCompare(0, 0);