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/prototype/setMinutes | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.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/prototype/setMinutes')
23 files changed, 881 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T1.js new file mode 100644 index 0000000000..495135965b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_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 "setMinutes" has { DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setMinutes; +if (x === 1) { + Date.prototype.setMinutes = 2; +} else { + Date.prototype.setMinutes = 1; +} + +assert.notSameValue( + Date.prototype.setMinutes, + x, + 'The value of Date.prototype.setMinutes 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/setMinutes/S15.9.5.32_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T2.js new file mode 100644 index 0000000000..3cc72be727 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_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 "setMinutes" has { DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking absence of DontDelete attribute +---*/ +assert.notSameValue( + delete Date.prototype.setMinutes, + false, + 'The value of delete Date.prototype.setMinutes is not false' +); + +assert( + !Date.prototype.hasOwnProperty('setMinutes'), + 'The value of !Date.prototype.hasOwnProperty(\'setMinutes\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A1_T3.js new file mode 100644 index 0000000000..61eba85e1a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_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 "setMinutes" has { DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking DontEnum attribute +---*/ +assert( + !Date.prototype.propertyIsEnumerable('setMinutes'), + 'The value of !Date.prototype.propertyIsEnumerable(\'setMinutes\') is expected to be true' +); + +for (var x in Date.prototype) { + assert.notSameValue(x, "setMinutes", 'The value of x is not "setMinutes"'); +} + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A2_T1.js new file mode 100644 index 0000000000..e95e992ab1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_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 "setMinutes" is 3 +esid: sec-date.prototype.setminutes +description: The "length" property of the "setMinutes" is 3 +---*/ +assert.sameValue( + Date.prototype.setMinutes.hasOwnProperty("length"), + true, + 'Date.prototype.setMinutes.hasOwnProperty("length") must return true' +); + +assert.sameValue( + Date.prototype.setMinutes.length, + 3, + 'The value of Date.prototype.setMinutes.length is expected to be 3' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T1.js new file mode 100644 index 0000000000..2224b138ad --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_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.setMinutes property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setMinutes.length; +verifyNotWritable(Date.prototype.setMinutes, "length", null, 1); + +assert.sameValue( + Date.prototype.setMinutes.length, + x, + 'The value of Date.prototype.setMinutes.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/setMinutes/S15.9.5.32_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T2.js new file mode 100644 index 0000000000..d9a4a75086 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_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.setMinutes property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking DontDelete attribute +---*/ +assert.sameValue( + delete Date.prototype.setMinutes.length, + true, + 'The value of `delete Date.prototype.setMinutes.length` is expected to be true' +); + +assert( + !Date.prototype.setMinutes.hasOwnProperty('length'), + 'The value of !Date.prototype.setMinutes.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/setMinutes/S15.9.5.32_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_A3_T3.js new file mode 100644 index 0000000000..1380f4e35b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/S15.9.5.32_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.setMinutes property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setminutes +description: Checking DontEnum attribute +---*/ +assert( + !Date.prototype.setMinutes.propertyIsEnumerable('length'), + 'The value of !Date.prototype.setMinutes.propertyIsEnumerable(\'length\') is expected to be true' +); + +for (var x in Date.prototype.setMinutes) { + 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/setMinutes/arg-coercion-order.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-coercion-order.js new file mode 100644 index 0000000000..50d81c114f --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-coercion-order.js @@ -0,0 +1,51 @@ +// Copyright (C) 2021 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.setminutes +description: Order of coercion of provided argument vs NaN check +info: | + 1. Let t be ? thisTimeValue(this value). + 2. Let m be ? ToNumber(min). + 3. If sec is present, let s be ? ToNumber(sec). + 4. If ms is present, let milli be ? ToNumber(ms). + 5. If t is NaN, return NaN. + 6. Set t to LocalTime(t). + 7. If sec is not present, let s be SecFromTime(t). + 8. If ms is not present, let milli be msFromTime(t). + 9. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)). + 10. Let u be TimeClip(UTC(date)). + 11. Set the [[DateValue]] internal slot of this Date object to u. + 12. Return u. +includes: [compareArray.js] +---*/ + +var date = new Date(NaN); +var effects = []; +var argMin = { + valueOf: function() { + effects.push('valueOf min'); + return 0; + } +}; +var argSec = { + valueOf: function() { + effects.push('valueOf sec'); + return 0; + } +}; +var argMs = { + valueOf: function() { + effects.push('valueOf ms'); + return 0; + } +}; + +var returnValue = date.setMinutes(argMin, argSec, argMs); + +var expectedEffects = ['valueOf min', 'valueOf sec', 'valueOf ms']; + +assert.compareArray(effects, expectedEffects); +assert.sameValue(returnValue, NaN, 'argument is ignored when `this` is an invalid date'); +assert.sameValue(date.getTime(), NaN, 'argument is ignored when `this` is an invalid date'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number-err.js new file mode 100644 index 0000000000..dbcee5ffbb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number-err.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.prototype.setminutes +description: Abrupt completion during type coercion of provided "min" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setMinutes(obj, counter, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number.js new file mode 100644 index 0000000000..18a9bb5809 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-min-to-number.js @@ -0,0 +1,62 @@ +// 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.prototype.setminutes +description: Type coercion of provided "min" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 4. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 5. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)). + 6. Let u be TimeClip(UTC(date)). + 7. Set the [[DateValue]] internal slot of this Date object to u. + 8. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setMinutes(arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setMinutes(null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setMinutes(true); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 1).getTime(), 'true'); + +returnValue = date.setMinutes(false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setMinutes(' +00200.000E-0002 '); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 2).getTime(), 'string'); + +returnValue = date.setMinutes(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number-err.js new file mode 100644 index 0000000000..f2036235e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number-err.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.prototype.setminutes +description: Abrupt completion during type coercion of provided "ms" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 4. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). +---*/ + +var date = new Date(); +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setMinutes(0, 0, obj); +}); + +assert.sameValue(date.getTime(), originalValue); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number.js new file mode 100644 index 0000000000..84d4629baf --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-ms-to-number.js @@ -0,0 +1,66 @@ +// 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.prototype.setminutes +description: Type coercion of provided "ms" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 4. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 5. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)). + 6. Let u be TimeClip(UTC(date)). + 7. Set the [[DateValue]] internal slot of this Date object to u. + 8. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setMinutes(0, 0, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setMinutes(0, 0, null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setMinutes(0, 0, true); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 1).getTime(), 'true' +); + +returnValue = date.setMinutes(0, 0, false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setMinutes(0, 0, ' +00200.000E-0002 '); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), 'string' +); + +returnValue = date.setMinutes(0, 0, undefined); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number-err.js new file mode 100644 index 0000000000..d57bba3b71 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number-err.js @@ -0,0 +1,34 @@ +// 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.prototype.setminutes +description: Abrupt completion during type coercion of provided "sec" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). +---*/ + +var date = new Date(); +var callCount = 0; +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; +var counter = { + valueOf: function() { + callCount += 1; + } +}; + +assert.throws(Test262Error, function() { + date.setMinutes(0, 0, obj, counter); +}); + +assert.sameValue(date.getTime(), originalValue); +assert.sameValue(callCount, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number.js new file mode 100644 index 0000000000..dbb11d823a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/arg-sec-to-number.js @@ -0,0 +1,64 @@ +// 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.prototype.setminutes +description: Type coercion of provided "sec" +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 4. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 5. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)). + 6. Let u be TimeClip(UTC(date)). + 7. Set the [[DateValue]] internal slot of this Date object to u. + 8. Return u. +---*/ + +var date = new Date(2016, 6); +var callCount = 0; +var arg = { + valueOf: function() { + args = arguments; + thisValue = this; + callCount += 1; + return 2; + } +}; +var args, thisValue, returnValue; + +returnValue = date.setMinutes(0, arg); + +assert.sameValue(callCount, 1, 'invoked exactly once'); +assert.sameValue(args.length, 0, 'invoked without arguments'); +assert.sameValue(thisValue, arg, '"this" value'); +assert.sameValue( + returnValue, + new Date(2016, 6, 1, 0, 0, 2).getTime(), + 'application of specified value' +); + +returnValue = date.setMinutes(0, null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setMinutes(0, true); + +assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 0, 1).getTime(), 'true'); + +returnValue = date.setMinutes(0, false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setMinutes(0, ' +00200.000E-0002 '); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 2).getTime(), 'string' +); + +returnValue = date.setMinutes(0, undefined); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/browser.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/name.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/name.js new file mode 100644 index 0000000000..5b177e2027 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/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.setminutes +description: > + Date.prototype.setMinutes.name is "setMinutes". +info: | + Date.prototype.setMinutes ( min [ , sec [ , 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.prototype.setMinutes.name, "setMinutes"); + +verifyNotEnumerable(Date.prototype.setMinutes, "name"); +verifyNotWritable(Date.prototype.setMinutes, "name"); +verifyConfigurable(Date.prototype.setMinutes, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/new-value-time-clip.js new file mode 100644 index 0000000000..030a2b1998 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/new-value-time-clip.js @@ -0,0 +1,46 @@ +// 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.prototype.setminutes +description: Behavior when new value exceeds [[DateValue]] limits +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let m be ? ToNumber(min). + 3. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 4. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 5. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)). + 6. Let u be TimeClip(UTC(date)). + 7. Set the [[DateValue]] internal slot of this Date object to u. + 8. Return u. + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +var maxMs = 8.64e15; +var date = new Date(maxMs); +var returnValue; + +assert.notSameValue(date.getTime(), NaN); + +returnValue = date.setMinutes(24 * 60); + +assert.sameValue(returnValue, NaN, 'overflow due to minutes'); + +date = new Date(maxMs); + +returnValue = date.setMinutes(0, 24 * 60 * 60); + +assert.sameValue(returnValue, NaN, 'overflow due to seconds'); + +date = new Date(maxMs); + +returnValue = date.setMinutes(0, 0, 24 * 60 * 60 * 1000); + +assert.sameValue(returnValue, NaN, 'overflow due to milliseconds'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/not-a-constructor.js new file mode 100644 index 0000000000..c65d687fb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/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.setMinutes 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.setMinutes), + false, + 'isConstructor(Date.prototype.setMinutes) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setMinutes(); +}, '`let date = new Date(Date.now()); new date.setMinutes()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/shell.js diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-invalid-date.js new file mode 100644 index 0000000000..625e53d8f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-invalid-date.js @@ -0,0 +1,45 @@ +// 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.prototype.setminutes +description: > + Behavior when the "this" value is a Date object describing an invald date +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let h be ? ToNumber(hour). + 3. If min is not specified, let m be MinFromTime(t); otherwise, let m be ? + ToNumber(min). + 4. If sec is not specified, let s be SecFromTime(t); otherwise, let s be ? + ToNumber(sec). + 5. If ms is not specified, let milli be msFromTime(t); otherwise, let milli + be ? ToNumber(ms). + 6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)). + 7. Let u be TimeClip(UTC(date)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(NaN); +var result; + +result = date.setMinutes(0); + +assert.sameValue(result, NaN, 'return value (hour)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (hour)'); + +result = date.setMinutes(0, 0); + +assert.sameValue(result, NaN, 'return value (minute)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (minute)'); + +result = date.setMinutes(0, 0, 0); + +assert.sameValue(result, NaN, 'return value (second)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (second)'); + +result = date.setMinutes(0, 0, 0, 0); + +assert.sameValue(result, NaN, 'return value (ms)'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (ms)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-date.js new file mode 100644 index 0000000000..e6b5eff326 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-date.js @@ -0,0 +1,45 @@ +// 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.prototype.setminutes +description: > + Behavior when "this" value is an Object without a [[DateValue]] internal slot +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +---*/ + +var setMinutes = Date.prototype.setMinutes; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof setMinutes, 'function'); + +assert.throws(TypeError, function() { + setMinutes.call({}, arg); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + setMinutes.call([], arg); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + setMinutes.call(args, arg); +}, 'arguments exotic object'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-object.js new file mode 100644 index 0000000000..4a2e9da81a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-non-object.js @@ -0,0 +1,55 @@ +// 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.prototype.setminutes +description: Behavior when "this" value is not an Object +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + + The abstract operation thisTimeValue(value) performs the following steps: + + 1. If Type(value) is Object and value has a [[DateValue]] internal slot, then + a. Return value.[[DateValue]]. + 2. Throw a TypeError exception. +features: [Symbol] +---*/ + +var setMinutes = Date.prototype.setMinutes; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var symbol = Symbol(); + +assert.sameValue(typeof setMinutes, 'function'); + +assert.throws(TypeError, function() { + setMinutes.call(0, arg); +}, 'number'); + +assert.throws(TypeError, function() { + setMinutes.call(true, arg); +}, 'boolean'); + +assert.throws(TypeError, function() { + setMinutes.call(null, arg); +}, 'null'); + +assert.throws(TypeError, function() { + setMinutes.call(undefined, arg); +}, 'undefined'); + +assert.throws(TypeError, function() { + setMinutes.call('', arg); +}, 'string'); + +assert.throws(TypeError, function() { + setMinutes.call(symbol, arg); +}, 'symbol'); + +assert.sameValue(callCount, 0, 'validation precedes input coercion'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-valid-date.js new file mode 100644 index 0000000000..76b4f732d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMinutes/this-value-valid-date.js @@ -0,0 +1,131 @@ +// 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.prototype.setminutes +description: Return value for valid dates +info: | + 1. Let t be ? thisTimeValue(this value). + 2. If t is NaN, let t be +0; otherwise, let t be LocalTime(t). + 3. Let y be ? ToNumber(year). + 4. If month is not specified, let m be MonthFromTime(t); otherwise, let m be + ? ToNumber(month). + 5. If date is not specified, let dt be DateFromTime(t); otherwise, let dt be + ? ToNumber(date). + 6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)). + 7. Let u be TimeClip(UTC(newDate)). + 8. Set the [[DateValue]] internal slot of this Date object to u. + 9. Return u. +---*/ + +var date = new Date(2016, 6, 1); +var returnValue, expected; + +returnValue = date.setMinutes(23); + +expected = new Date(2016, 6, 1, 0, 23).getTime(); +assert.sameValue( + returnValue, expected, 'minute within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'minute within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(-1); + +expected = new Date(2016, 5, 30, 23, 59).getTime(); +assert.sameValue( + returnValue, expected, 'minute before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'minute before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(60); + +expected = new Date(2016, 6, 1).getTime(); +assert.sameValue( + returnValue, expected, 'minute after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'minute after time unit boundary ([[DateValue]] slot)' +); + +date = new Date(2016, 6, 1); + +returnValue = date.setMinutes(0, 45); + +expected = new Date(2016, 6, 1, 0, 0, 45).getTime(); +assert.sameValue( + returnValue, expected, 'second within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'second within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(0, -1); + +expected = new Date(2016, 5, 30, 23, 59, 59).getTime(); +assert.sameValue( + returnValue, expected, 'second before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'second before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(0, 60); + +expected = new Date(2016, 5, 30, 23, 1).getTime(); +assert.sameValue( + returnValue, expected, 'second after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'second after time unit boundary ([[DateValue]] slot)' +); + +date = new Date(2016, 6, 1); + +returnValue = date.setMinutes(0, 0, 345); + +expected = new Date(2016, 6, 1, 0, 0, 0, 345).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(0, 0, -1); + +expected = new Date(2016, 5, 30, 23, 59, 59, 999).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMinutes(0, 0, 1000); + +expected = new Date(2016, 5, 30, 23, 0, 1).getTime(); +assert.sameValue( + returnValue, expected, 'millisecond after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), + expected, + 'millisecond after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); |