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/UTC | |
parent | Initial commit. (diff) | |
download | firefox-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/UTC')
24 files changed, 615 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T1.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T1.js new file mode 100644 index 0000000000..5f2531e1c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_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. + +/*--- +esid: sec-date.utc +info: The Date property "UTC" has { DontEnum } attributes +es5id: 15.9.4.3_A1_T1 +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.UTC; +if (x === 1) { + Date.UTC = 2; +} else { + Date.UTC = 1; +} +assert.notSameValue(Date.UTC, x, 'The value of Date.UTC 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/UTC/S15.9.4.3_A1_T2.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T2.js new file mode 100644 index 0000000000..f859e0b452 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T2.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.utc +info: The Date property "UTC" has { DontEnum } attributes +es5id: 15.9.4.3_A1_T2 +description: Checking absence of DontDelete attribute +---*/ +assert.notSameValue(delete Date.UTC, false, 'The value of delete Date.UTC is not false'); +assert(!Date.hasOwnProperty('UTC'), 'The value of !Date.hasOwnProperty(\'UTC\') is expected to be true'); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T3.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T3.js new file mode 100644 index 0000000000..43b8ccb055 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A1_T3.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. + +/*--- +esid: sec-date.utc +info: The Date property "UTC" has { DontEnum } attributes +es5id: 15.9.4.3_A1_T3 +description: Checking DontEnum attribute +---*/ +assert( + !Date.propertyIsEnumerable('UTC'), + 'The value of !Date.propertyIsEnumerable(\'UTC\') is expected to be true' +); + +for (var x in Date) { + assert.notSameValue(x, "UTC", 'The value of x is not "UTC"'); +} + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A2_T1.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A2_T1.js new file mode 100644 index 0000000000..49e39e4d11 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A2_T1.js @@ -0,0 +1,13 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-date.utc +info: The "length" property of the "UTC" is 7 +es5id: 15.9.4.3_A2_T1 +description: The "length" property of the "UTC" is 7 +---*/ +assert.sameValue(Date.UTC.hasOwnProperty("length"), true, 'Date.UTC.hasOwnProperty("length") must return true'); +assert.sameValue(Date.UTC.length, 7, 'The value of Date.UTC.length is expected to be 7'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T1.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T1.js new file mode 100644 index 0000000000..c9261a5a5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_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. + +/*--- +esid: sec-date.utc +info: | + The Date.UTC property "length" has { ReadOnly, DontDelete, DontEnum } + attributes +es5id: 15.9.4.3_A3_T1 +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.UTC.length; +verifyNotWritable(Date.UTC, "length", null, 1); +assert.sameValue(Date.UTC.length, x, 'The value of Date.UTC.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/UTC/S15.9.4.3_A3_T2.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T2.js new file mode 100644 index 0000000000..07ecc37b20 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_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. + +/*--- +esid: sec-date.utc +info: | + The Date.UTC property "length" has { ReadOnly, ! DontDelete, DontEnum } + attributes +es5id: 15.9.4.3_A3_T2 +description: Checking DontDelete attribute +---*/ + +assert.sameValue(delete Date.UTC.length, true, 'The value of `delete Date.UTC.length` is expected to be true'); + +assert( + !Date.UTC.hasOwnProperty('length'), + 'The value of !Date.UTC.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/UTC/S15.9.4.3_A3_T3.js b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T3.js new file mode 100644 index 0000000000..f5d155d8a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/S15.9.4.3_A3_T3.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. + +/*--- +esid: sec-date.utc +info: | + The Date.UTC property "length" has { ReadOnly, DontDelete, DontEnum } + attributes +es5id: 15.9.4.3_A3_T3 +description: Checking DontEnum attribute +---*/ +assert( + !Date.UTC.propertyIsEnumerable('length'), + 'The value of !Date.UTC.propertyIsEnumerable(\'length\') is expected to be true' +); + +for (var x in Date.UTC) { + 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/UTC/browser.js b/js/src/tests/test262/built-ins/Date/UTC/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/browser.js diff --git a/js/src/tests/test262/built-ins/Date/UTC/coercion-errors.js b/js/src/tests/test262/built-ins/Date/UTC/coercion-errors.js new file mode 100644 index 0000000000..7271172c12 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/coercion-errors.js @@ -0,0 +1,61 @@ +// 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.utc +description: Abrupt completions from coercing input values +info: | + 1. Let y be ? ToNumber(year). + 2. Let m be ? ToNumber(month). + 3. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + 4. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + 5. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + 6. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + 7. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +var thrower = { toString: function() { throw new Test262Error(); } }; +var counter = { toString: function() { callCount += 1; } }; +var callCount = 0; + +assert.throws(Test262Error, function() { + Date.UTC(thrower, counter); +}, 'year'); +assert.sameValue(callCount, 0, 'coercion halts following error from "year"'); + +assert.throws(Test262Error, function() { + Date.UTC(0, thrower, counter); +}, 'month'); +assert.sameValue(callCount, 0, 'coercion halts following error from "month"'); + +assert.throws(Test262Error, function() { + Date.UTC(0, 0, thrower, counter); +}, 'date'); +assert.sameValue(callCount, 0, 'coercion halts following error from "date"'); + +assert.throws(Test262Error, function() { + Date.UTC(0, 0, 1, thrower, counter); +}, 'hours'); +assert.sameValue(callCount, 0, 'coercion halts following error from "hours"'); + +assert.throws(Test262Error, function() { + Date.UTC(0, 0, 1, 0, thrower, counter); +}, 'minutes'); +assert.sameValue( + callCount, 0, 'coercion halts following error from "minutes"' +); + +assert.throws(Test262Error, function() { + Date.UTC(0, 0, 1, 0, 0, thrower, counter); +}, 'seconds'); +assert.sameValue( + callCount, 0, 'coercion halts following error from "seconds"' +); + +assert.throws(Test262Error, function() { + Date.UTC(0, 0, 1, 0, 0, 0, thrower); +}, 'ms'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/coercion-order.js b/js/src/tests/test262/built-ins/Date/UTC/coercion-order.js new file mode 100644 index 0000000000..96d9cd6ad2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/coercion-order.js @@ -0,0 +1,32 @@ +// 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.utc +description: Order of input coercion +info: | + 1. Let y be ? ToNumber(year). + 2. Let m be ? ToNumber(month). + 3. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + 4. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + 5. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + 6. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + 7. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +var log = ''; +var year = { toString: function() { log += 'year'; return 0; } }; +var month = { toString: function() { log += 'month'; return 0; } }; +var date = { toString: function() { log += 'date'; return 1; } }; +var hours = { toString: function() { log += 'hours'; return 0; } }; +var minutes = { toString: function() { log += 'minutes'; return 0; } }; +var seconds = { toString: function() { log += 'seconds'; return 0; } }; +var ms = { toString: function() { log += 'ms'; return 0; } }; + +Date.UTC(year, month, date, hours,minutes, seconds, ms); + +assert.sameValue(log, 'yearmonthdatehoursminutessecondsms'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/fp-evaluation-order.js b/js/src/tests/test262/built-ins/Date/UTC/fp-evaluation-order.js new file mode 100644 index 0000000000..57d9ec6800 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/fp-evaluation-order.js @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: arithmetic in Date is done on floating-point numbers +info: | + [...] + Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + #sec-maketime + + Let _t_ be ((_h_ `*` msPerHour `+` _m_ `*` msPerMinute) `+` _s_ `*` msPerSecond) `+` _milli_, performing the arithmetic according to IEEE 754-2019 rules (that is, as if using the ECMAScript operators `*` and `+`). + + #sec-makedate + + Return day × msPerDay + time. +---*/ + +assert.sameValue(Date.UTC(1970, 0, 1, 80063993375, 29, 1, -288230376151711740), 29312, 'order of operations / precision in MakeTime'); +assert.sameValue(Date.UTC(1970, 0, 213503982336, 0, 0, 0, -18446744073709552000), 34447360, 'precision in MakeDate'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/infinity-make-day.js b/js/src/tests/test262/built-ins/Date/UTC/infinity-make-day.js new file mode 100644 index 0000000000..e4acdd5e3e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/infinity-make-day.js @@ -0,0 +1,29 @@ +// 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.utc +description: Infinite values specified to MakeDay produce NaN +info: | + [...] + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + MakeDay (year, month, date) + + 1. If year is not finite or month is not finite or date is not finite, return + NaN. +---*/ + +assert.sameValue(Date.UTC(Infinity), NaN, 'year: Infinity - single arg'); +assert.sameValue(Date.UTC(-Infinity), NaN, 'year: -Infinity - single arg'); + +assert.sameValue(Date.UTC(Infinity, 0), NaN, 'year: Infinity'); +assert.sameValue(Date.UTC(-Infinity, 0), NaN, 'year: -Infinity'); + +assert.sameValue(Date.UTC(0, Infinity), NaN, 'month: Infinity'); +assert.sameValue(Date.UTC(0, -Infinity), NaN, 'month: -Infinity'); + +assert.sameValue(Date.UTC(0, 0, Infinity), NaN, 'date: Infinity'); +assert.sameValue(Date.UTC(0, 0, -Infinity), NaN, 'date: -Infinity'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/infinity-make-time.js b/js/src/tests/test262/built-ins/Date/UTC/infinity-make-time.js new file mode 100644 index 0000000000..b54dc3fb87 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/infinity-make-time.js @@ -0,0 +1,28 @@ +// 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.utc +description: Infinite values specified to MakeTime produce NaN +info: | + [...] + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + MakeTime (hour, min, sec, ms) + + 1. If hour is not finite or min is not finite or sec is not finite or ms is + not finite, return NaN. +---*/ + +assert.sameValue(Date.UTC(0, 0, 1, Infinity), NaN, 'hour: Infinity'); +assert.sameValue(Date.UTC(0, 0, 1, -Infinity), NaN, 'hour: -Infinity'); + +assert.sameValue(Date.UTC(0, 0, 1, 0, Infinity), NaN, 'minute: Infinity'); +assert.sameValue(Date.UTC(0, 0, 1, 0, -Infinity), NaN, 'minute: -Infinity'); + +assert.sameValue(Date.UTC(0, 0, 1, 0, 0, Infinity), NaN, 'second: Infinity'); +assert.sameValue(Date.UTC(0, 0, 1, 0, 0, -Infinity), NaN, 'second: -Infinity'); + +assert.sameValue(Date.UTC(0, 0, 1, 0, 0, 0, Infinity), NaN, 'ms: Infinity'); +assert.sameValue(Date.UTC(0, 0, 1, 0, 0, 0, -Infinity), NaN, 'ms: -Infinity'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/name.js b/js/src/tests/test262/built-ins/Date/UTC/name.js new file mode 100644 index 0000000000..3310708e58 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/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.utc +description: > + Date.UTC.name is "UTC". +info: | + Date.UTC ( year, month [ , date [ , hours [ , minutes [ , seconds [ , ms ] ] ] ] ] ) + + 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.UTC.name, "UTC"); + +verifyNotEnumerable(Date.UTC, "name"); +verifyNotWritable(Date.UTC, "name"); +verifyConfigurable(Date.UTC, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/nans.js b/js/src/tests/test262/built-ins/Date/UTC/nans.js new file mode 100644 index 0000000000..bb34f493f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/nans.js @@ -0,0 +1,28 @@ +// 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.utc +description: NaN value handling +info: | + 1. Let y be ? ToNumber(year). + 2. Let m be ? ToNumber(month). + 3. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + 4. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + 5. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + 6. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + 7. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +assert.sameValue(Date.UTC(NaN), NaN, 'year'); +assert.sameValue(Date.UTC(NaN, 0), NaN, 'year'); +assert.sameValue(Date.UTC(1970, NaN), NaN, 'month'); +assert.sameValue(Date.UTC(1970, 0, NaN), NaN, 'date'); +assert.sameValue(Date.UTC(1970, 0, 1, NaN), NaN, 'hours'); +assert.sameValue(Date.UTC(1970, 0, 1, 0, NaN), NaN, 'minutes'); +assert.sameValue(Date.UTC(1970, 0, 1, 0, 0, NaN), NaN, 'seconds'); +assert.sameValue(Date.UTC(1970, 0, 1, 0, 0, 0, NaN), NaN, 'ms'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/no-arg.js b/js/src/tests/test262/built-ins/Date/UTC/no-arg.js new file mode 100644 index 0000000000..b9a98a4f1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/no-arg.js @@ -0,0 +1,21 @@ +// 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.utc +description: Tests for non optional arguments +info: | + 1. Let y be ? ToNumber(year). + 2. Let m be ? ToNumber(month). + 3. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + 4. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + 5. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + 6. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + 7. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +assert.sameValue(Date.UTC(), NaN, 'missing non-optional year argument'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/non-integer-values.js b/js/src/tests/test262/built-ins/Date/UTC/non-integer-values.js new file mode 100644 index 0000000000..998d0c2182 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/non-integer-values.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 Viktor Mukhachev. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.utc +description: non-integer values are converted to integers using `ToInteger` +info: | + [...] + Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + #sec-timeclip + + Let clippedTime be ! ToInteger(time). + + #sec-makeday + + Let y be ! ToInteger(year). + Let m be ! ToInteger(month). + Let dt be ! ToInteger(date). + + #sec-maketime + + Let h be ! ToInteger(hour). + Let m be ! ToInteger(min). + Let s be ! ToInteger(sec). + Let milli be ! ToInteger(ms). +---*/ + +assert.sameValue(Date.UTC(1970.9, 0.9, 1.9, 0.9, 0.9, 0.9, 0.9), 0, 'positive non-integer values'); +assert.sameValue(Date.UTC(-1970.9, -0.9, -0.9, -0.9, -0.9, -0.9, -0.9), -124334438400000, 'negative non-integer values'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/UTC/not-a-constructor.js new file mode 100644 index 0000000000..b655948879 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/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.UTC 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.UTC), false, 'isConstructor(Date.UTC) must return false'); + +assert.throws(TypeError, () => { + new Date.UTC(); +}, '`new Date.UTC()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/overflow-make-day.js b/js/src/tests/test262/built-ins/Date/UTC/overflow-make-day.js new file mode 100644 index 0000000000..8aa640d1a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/overflow-make-day.js @@ -0,0 +1,28 @@ +// 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.utc +description: Values specified to MakeDay exceed their calendar boundaries +info: | + [...] + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + MakeDay (year, month, date) + + [...] + 5. Let ym be y + floor(m / 12). + [...] + 7. Find a value t such that YearFromTime(t) is ym and MonthFromTime(t) is mn + and DateFromTime(t) is 1; but if this is not possible (because some + argument is out of range), return NaN. + 8. Return Day(t) + dt - 1. +---*/ + +assert.sameValue(Date.UTC(2016, 12), 1483228800000, 'month: 12'); +assert.sameValue(Date.UTC(2016, 13), 1485907200000, 'month: 13'); +assert.sameValue(Date.UTC(2016, 144), 1830297600000, 'month: 144'); + +assert.sameValue(Date.UTC(2016, 0, 33), 1454371200000, 'day greater than month'); +assert.sameValue(Date.UTC(2016, 2, -27), 1454371200000, 'day negative value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/overflow-make-time.js b/js/src/tests/test262/built-ins/Date/UTC/overflow-make-time.js new file mode 100644 index 0000000000..db975cd160 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/overflow-make-time.js @@ -0,0 +1,37 @@ +// 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.utc +description: Values specified to MakeTime exceed their time boundaries +info: | + [...] + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + MakeTime (hour, min, sec, ms) + + 1. If hour is not finite or min is not finite or sec is not finite or ms is + not finite, return NaN. + 2. Let h be ToInteger(hour). + 3. Let m be ToInteger(min). + 4. Let s be ToInteger(sec). + 5. Let milli be ToInteger(ms). + 6. Let t be h * msPerHour + m * msPerMinute + s * msPerSecond + milli, + performing the arithmetic according to IEEE 754-2008 rules (that is, as if + using the ECMAScript operators * and +). + 7. Return t. +---*/ + +assert.sameValue(Date.UTC(2016, 6, 5, -1), 1467673200000, 'hour: -1'); +assert.sameValue(Date.UTC(2016, 6, 5, 24), 1467763200000, 'hour: 24'); +assert.sameValue(Date.UTC(2016, 6, 5, 0, -1), 1467676740000, 'minute: -1'); +assert.sameValue(Date.UTC(2016, 6, 5, 0, 60), 1467680400000, 'minute: 60'); +assert.sameValue(Date.UTC(2016, 6, 5, 0, 0, -1), 1467676799000, 'second: -1'); +assert.sameValue(Date.UTC(2016, 6, 5, 0, 0, 60), 1467676860000, 'second: 60'); +assert.sameValue( + Date.UTC(2016, 6, 5, 0, 0, 0, -1), 1467676799999, 'millisecond: -1' +); +assert.sameValue( + Date.UTC(2016, 6, 5, 0, 0, 0, 1000), 1467676801000, 'millisecond: 1000' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/return-value.js b/js/src/tests/test262/built-ins/Date/UTC/return-value.js new file mode 100644 index 0000000000..1564c94b55 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/return-value.js @@ -0,0 +1,57 @@ +// 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.utc +description: Return value of `Date.UTC` +info: | + 1. Let y be ? ToNumber(year). + 2. Let m be ? ToNumber(month). + 3. If date is supplied, let dt be ? ToNumber(date); else let dt be 1. + 4. If hours is supplied, let h be ? ToNumber(hours); else let h be 0. + 5. If minutes is supplied, let min be ? ToNumber(minutes); else let min be 0. + 6. If seconds is supplied, let s be ? ToNumber(seconds); else let s be 0. + 7. If ms is supplied, let milli be ? ToNumber(ms); else let milli be 0. + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +assert.sameValue(Date.UTC(1970), 0, '1970'); + +assert.sameValue(Date.UTC(1970, 0), 0, '1970, 0'); +assert.sameValue(Date.UTC(2016, 0), 1451606400000, '2016, 0'); +assert.sameValue(Date.UTC(2016, 6), 1467331200000, '2016, 6'); + +assert.sameValue(Date.UTC(2016, 6, 1), 1467331200000, '2016, 6, 1'); +assert.sameValue(Date.UTC(2016, 6, 5), 1467676800000, '2016, 6, 5'); + +assert.sameValue(Date.UTC(2016, 6, 5, 0), 1467676800000, '2016, 6, 5, 0'); +assert.sameValue(Date.UTC(2016, 6, 5, 15), 1467730800000, '2016, 6, 5, 15'); + +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 0), 1467730800000, '2016, 6, 5, 15, 0' +); +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 34), 1467732840000, '2016, 6, 5, 15, 34' +); + +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 34, 0), 1467732840000, '2016, 6, 5, 15, 34, 0' +); +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 34, 45), 1467732885000, '2016, 6, 5, 15, 34, 45' +); + + +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 34, 45, 0), + 1467732885000, + '2016, 6, 5, 15, 34, 45, 0' +); +assert.sameValue( + Date.UTC(2016, 6, 5, 15, 34, 45, 876), + 1467732885876, + '2016, 6, 5, 15, 34, 45, 0' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/shell.js b/js/src/tests/test262/built-ins/Date/UTC/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/shell.js diff --git a/js/src/tests/test262/built-ins/Date/UTC/time-clip.js b/js/src/tests/test262/built-ins/Date/UTC/time-clip.js new file mode 100644 index 0000000000..5641b3d316 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/time-clip.js @@ -0,0 +1,19 @@ +// 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.utc +description: Time clipping +info: | + [...] + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +assert.notSameValue(Date.UTC(275760, 8, 13, 0, 0, 0, 0), NaN); +assert.sameValue(Date.UTC(275760, 8, 13, 0, 0, 0, 1), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/UTC/year-offset.js b/js/src/tests/test262/built-ins/Date/UTC/year-offset.js new file mode 100644 index 0000000000..cea354ea4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/UTC/year-offset.js @@ -0,0 +1,28 @@ +// 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.utc +description: Conditional offset of provided `year` value +info: | + 1. Let y be ? ToNumber(year). + [...] + 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); + otherwise, let yr be y. + 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). +---*/ + +assert.sameValue(Date.UTC(-1, 0), -62198755200000, '-1 (no offset)'); + +assert.sameValue(Date.UTC(0, 0), -2208988800000, '+0'); +assert.sameValue(Date.UTC(-0, 0), -2208988800000, '-0'); +assert.sameValue(Date.UTC(-0.999999, 0), -2208988800000, '-0.999999'); + +assert.sameValue(Date.UTC(70, 0), 0, '70'); +assert.sameValue(Date.UTC(70, 0), 0, '70.999999'); + +assert.sameValue(Date.UTC(99, 0), 915148800000, '99'); +assert.sameValue(Date.UTC(99.999999, 0), 915148800000, '99.999999'); + +assert.sameValue(Date.UTC(100, 0), -59011459200000, '100 (no offset)'); + +reportCompare(0, 0); |