From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../prototype/setMilliseconds/S15.9.5.28_A1_T1.js | 25 +++++++++ .../prototype/setMilliseconds/S15.9.5.28_A1_T2.js | 22 ++++++++ .../prototype/setMilliseconds/S15.9.5.28_A1_T3.js | 20 +++++++ .../prototype/setMilliseconds/S15.9.5.28_A2_T1.js | 21 ++++++++ .../prototype/setMilliseconds/S15.9.5.28_A3_T1.js | 24 +++++++++ .../prototype/setMilliseconds/S15.9.5.28_A3_T2.js | 24 +++++++++ .../prototype/setMilliseconds/S15.9.5.28_A3_T3.js | 22 ++++++++ .../setMilliseconds/arg-coercion-order.js | 32 +++++++++++ .../prototype/setMilliseconds/arg-to-number-err.js | 25 +++++++++ .../prototype/setMilliseconds/arg-to-number.js | 63 ++++++++++++++++++++++ .../Date/prototype/setMilliseconds/browser.js | 0 .../Date/prototype/setMilliseconds/name.js | 28 ++++++++++ .../setMilliseconds/new-value-time-clip.js | 30 +++++++++++ .../prototype/setMilliseconds/not-a-constructor.js | 35 ++++++++++++ .../Date/prototype/setMilliseconds/shell.js | 0 .../setMilliseconds/this-value-invalid-date.js | 25 +++++++++ .../setMilliseconds/this-value-non-date.js | 45 ++++++++++++++++ .../setMilliseconds/this-value-non-object.js | 55 +++++++++++++++++++ .../setMilliseconds/this-value-valid-date.js | 49 +++++++++++++++++ 19 files changed, 545 insertions(+) create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T1.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T2.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T3.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A2_T1.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T1.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T2.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T3.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-coercion-order.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number-err.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/browser.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/name.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/new-value-time-clip.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/not-a-constructor.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/shell.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-invalid-date.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-date.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-object.js create mode 100644 js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-valid-date.js (limited to 'js/src/tests/test262/built-ins/Date/prototype/setMilliseconds') diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T1.js new file mode 100644 index 0000000000..abd7ac57a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_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 "setMilliseconds" has { DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking absence of ReadOnly attribute +---*/ + +var x = Date.prototype.setMilliseconds; +if (x === 1) { + Date.prototype.setMilliseconds = 2; +} else { + Date.prototype.setMilliseconds = 1; +} + +assert.notSameValue( + Date.prototype.setMilliseconds, + x, + 'The value of Date.prototype.setMilliseconds 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/setMilliseconds/S15.9.5.28_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T2.js new file mode 100644 index 0000000000..3352f8071e --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_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 "setMilliseconds" has { DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking absence of DontDelete attribute +---*/ +assert.notSameValue( + delete Date.prototype.setMilliseconds, + false, + 'The value of delete Date.prototype.setMilliseconds is not false' +); + +assert( + !Date.prototype.hasOwnProperty('setMilliseconds'), + 'The value of !Date.prototype.hasOwnProperty(\'setMilliseconds\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A1_T3.js new file mode 100644 index 0000000000..e058353e2a --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_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 "setMilliseconds" has { DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking DontEnum attribute +---*/ +assert( + !Date.prototype.propertyIsEnumerable('setMilliseconds'), + 'The value of !Date.prototype.propertyIsEnumerable(\'setMilliseconds\') is expected to be true' +); + +for (var x in Date.prototype) { + assert.notSameValue(x, "setMilliseconds", 'The value of x is not "setMilliseconds"'); +} + +// TODO: Convert to verifyProperty() format. + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A2_T1.js new file mode 100644 index 0000000000..345a10bbd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_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 "setMilliseconds" is 1 +esid: sec-date.prototype.setmilliseconds +description: The "length" property of the "setMilliseconds" is 1 +---*/ +assert.sameValue( + Date.prototype.setMilliseconds.hasOwnProperty("length"), + true, + 'Date.prototype.setMilliseconds.hasOwnProperty("length") must return true' +); + +assert.sameValue( + Date.prototype.setMilliseconds.length, + 1, + 'The value of Date.prototype.setMilliseconds.length is expected to be 1' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T1.js new file mode 100644 index 0000000000..f8f2f3478b --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_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.setMilliseconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking ReadOnly attribute +includes: [propertyHelper.js] +---*/ + +var x = Date.prototype.setMilliseconds.length; +verifyNotWritable(Date.prototype.setMilliseconds, "length", null, 1); + +assert.sameValue( + Date.prototype.setMilliseconds.length, + x, + 'The value of Date.prototype.setMilliseconds.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/setMilliseconds/S15.9.5.28_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T2.js new file mode 100644 index 0000000000..fc4b43d39d --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_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.setMilliseconds property "length" has { ReadOnly, ! + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking DontDelete attribute +---*/ +assert.sameValue( + delete Date.prototype.setMilliseconds.length, + true, + 'The value of `delete Date.prototype.setMilliseconds.length` is expected to be true' +); + +assert( + !Date.prototype.setMilliseconds.hasOwnProperty('length'), + 'The value of !Date.prototype.setMilliseconds.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/setMilliseconds/S15.9.5.28_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_A3_T3.js new file mode 100644 index 0000000000..9e15b794be --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/S15.9.5.28_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.setMilliseconds property "length" has { ReadOnly, + DontDelete, DontEnum } attributes +esid: sec-date.prototype.setmilliseconds +description: Checking DontEnum attribute +---*/ +assert( + !Date.prototype.setMilliseconds.propertyIsEnumerable('length'), + 'The value of !Date.prototype.setMilliseconds.propertyIsEnumerable(\'length\') is expected to be true' +); + +for (var x in Date.prototype.setMilliseconds) { + 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/setMilliseconds/arg-coercion-order.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-coercion-order.js new file mode 100644 index 0000000000..38384ec1b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-coercion-order.js @@ -0,0 +1,32 @@ +// 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.setmilliseconds +description: Order of coercion of provided argument vs NaN check +info: | + 1. Let t be ? thisTimeValue(this value). + 2. Set ms to ? ToNumber(ms). + 3. If t is NaN, return NaN. + 4. Set t to LocalTime(t). + 5. Let time be MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms). + 6. Let u be TimeClip(UTC(MakeDate(Day(t), time))). + 7. Set the [[DateValue]] internal slot of this Date object to u. + 8. Return u. +---*/ + +var date = new Date(NaN); +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 0; + } +}; + +var returnValue = date.setMilliseconds(arg); + +assert.sameValue(callCount, 1, 'ToNumber invoked exactly once'); +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/setMilliseconds/arg-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number-err.js new file mode 100644 index 0000000000..0875605156 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number-err.js @@ -0,0 +1,25 @@ +// 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.setmilliseconds +description: Abrupt completion during type coercion of provided argument +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). +---*/ + +var date = new Date(); +var originalValue = date.getTime(); +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + date.setMilliseconds(obj); +}); + +assert.sameValue(date.getTime(), originalValue); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number.js new file mode 100644 index 0000000000..9e9d0270bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/arg-to-number.js @@ -0,0 +1,63 @@ +// 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.setmilliseconds +description: Type coercion of provided argument +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. 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.setMilliseconds(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.setMilliseconds(null); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null'); + +returnValue = date.setMilliseconds(true); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 1).getTime(), 'true' +); + +returnValue = date.setMilliseconds(false); + +assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false'); + +returnValue = date.setMilliseconds(' +00200.000E-0002 '); + +assert.sameValue( + returnValue, new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), 'string' +); + +returnValue = date.setMilliseconds(); + +assert.sameValue(returnValue, NaN, 'undefined'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/name.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/name.js new file mode 100644 index 0000000000..3430c5e216 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/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.setmilliseconds +description: > + Date.prototype.setMilliseconds.name is "setMilliseconds". +info: | + Date.prototype.setMilliseconds ( 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.setMilliseconds.name, "setMilliseconds"); + +verifyNotEnumerable(Date.prototype.setMilliseconds, "name"); +verifyNotWritable(Date.prototype.setMilliseconds, "name"); +verifyConfigurable(Date.prototype.setMilliseconds, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/new-value-time-clip.js new file mode 100644 index 0000000000..42a59468e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/new-value-time-clip.js @@ -0,0 +1,30 @@ +// 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.setmilliseconds +description: Behavior when new value exceeds [[DateValue]] limits +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. + + TimeClip (time) + + 1. If time is not finite, return NaN. + 2. If abs(time) > 8.64 × 1015, return NaN. +---*/ + +var date = new Date(8.64e15); +var returnValue; + +assert.notSameValue(date.getTime(), NaN); + +returnValue = date.setMilliseconds(1); + +assert.sameValue(returnValue, NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/not-a-constructor.js new file mode 100644 index 0000000000..3282e1a901 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/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.setMilliseconds 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.setMilliseconds), + false, + 'isConstructor(Date.prototype.setMilliseconds) must return false' +); + +assert.throws(TypeError, () => { + let date = new Date(Date.now()); new date.setMilliseconds(); +}, '`let date = new Date(Date.now()); new date.setMilliseconds()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-invalid-date.js new file mode 100644 index 0000000000..d0d4289699 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-invalid-date.js @@ -0,0 +1,25 @@ +// 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.setmilliseconds +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 dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. +---*/ + +var date = new Date(NaN); +var result; + +result = date.setMilliseconds(0); + +assert.sameValue(result, NaN, 'return value'); +assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-date.js new file mode 100644 index 0000000000..6c6c2de96c --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/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.setmilliseconds +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 setMilliseconds = Date.prototype.setMilliseconds; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var args = (function() { + return arguments; +}()); + +assert.sameValue(typeof setMilliseconds, 'function'); + +assert.throws(TypeError, function() { + setMilliseconds.call({}, arg); +}, 'ordinary object'); + +assert.throws(TypeError, function() { + setMilliseconds.call([], arg); +}, 'array exotic object'); + +assert.throws(TypeError, function() { + setMilliseconds.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/setMilliseconds/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-non-object.js new file mode 100644 index 0000000000..856d4cd3e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/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.setmilliseconds +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 setMilliseconds = Date.prototype.setMilliseconds; +var callCount = 0; +var arg = { + valueOf: function() { + callCount += 1; + return 1; + } +}; +var symbol = Symbol(); + +assert.sameValue(typeof setMilliseconds, 'function'); + +assert.throws(TypeError, function() { + setMilliseconds.call(0, arg); +}, 'number'); + +assert.throws(TypeError, function() { + setMilliseconds.call(true, arg); +}, 'boolean'); + +assert.throws(TypeError, function() { + setMilliseconds.call(null, arg); +}, 'null'); + +assert.throws(TypeError, function() { + setMilliseconds.call(undefined, arg); +}, 'undefined'); + +assert.throws(TypeError, function() { + setMilliseconds.call('', arg); +}, 'string'); + +assert.throws(TypeError, function() { + setMilliseconds.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/setMilliseconds/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-valid-date.js new file mode 100644 index 0000000000..4f1365abde --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/setMilliseconds/this-value-valid-date.js @@ -0,0 +1,49 @@ +// 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.setmilliseconds +description: Return value for valid dates +info: | + 1. Let t be LocalTime(? thisTimeValue(this value)). + 2. Let dt be ? ToNumber(date). + 3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), + TimeWithinDay(t)). + 4. Let u be TimeClip(UTC(newDate)). + 5. Set the [[DateValue]] internal slot of this Date object to u. + 6. Return u. +---*/ + +var date = new Date(2016, 6); +var returnValue, expected; + +returnValue = date.setMilliseconds(333); + +expected = new Date(2016, 6, 1, 0, 0, 0, 333).getTime(); +assert.sameValue( + returnValue, expected, 'within unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'within unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMilliseconds(-1); + +expected = new Date(2016, 5, 30, 23, 59, 59, 999).getTime(); +assert.sameValue( + returnValue, expected, 'before time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'before time unit boundary ([[DateValue]] slot)' +); + +returnValue = date.setMilliseconds(1000); + +expected = new Date(2016, 6, 1).getTime(); +assert.sameValue( + returnValue, expected, 'after time unit boundary (return value)' +); +assert.sameValue( + date.getTime(), expected, 'after time unit boundary ([[DateValue]] slot)' +); + +reportCompare(0, 0); -- cgit v1.2.3