summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Date/prototype/setHours
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Date/prototype/setHours')
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T1.js25
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T2.js18
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T3.js20
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A2_T1.js17
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T1.js24
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T2.js24
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T3.js22
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/arg-coercion-order.js59
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-to-number-err.js32
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-to-number.js64
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number-err.js34
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number.js64
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number-err.js31
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number.js68
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number-err.js36
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number.js66
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/name.js28
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/new-value-time-clip.js54
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-invalid-date.js45
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-non-date.js45
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-non-object.js55
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-hour.js58
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-min.js58
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-ms.js60
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-sec.js58
28 files changed, 1100 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T1.js
new file mode 100644
index 0000000000..522a7a554a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_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 "setHours" has { DontEnum } attributes
+esid: sec-date.prototype.sethours
+description: Checking absence of ReadOnly attribute
+---*/
+
+var x = Date.prototype.setHours;
+if (x === 1) {
+ Date.prototype.setHours = 2;
+} else {
+ Date.prototype.setHours = 1;
+}
+
+assert.notSameValue(
+ Date.prototype.setHours,
+ x,
+ 'The value of Date.prototype.setHours 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/setHours/S15.9.5.34_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T2.js
new file mode 100644
index 0000000000..6cf45d93cd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T2.js
@@ -0,0 +1,18 @@
+// 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 "setHours" has { DontEnum } attributes
+esid: sec-date.prototype.sethours
+description: Checking absence of DontDelete attribute
+---*/
+assert.notSameValue(delete Date.prototype.setHours, false, 'The value of delete Date.prototype.setHours is not false');
+
+assert(
+ !Date.prototype.hasOwnProperty('setHours'),
+ 'The value of !Date.prototype.hasOwnProperty(\'setHours\') is expected to be true'
+);
+
+// TODO: Convert to verifyProperty() format.
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A1_T3.js
new file mode 100644
index 0000000000..7211067494
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_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 "setHours" has { DontEnum } attributes
+esid: sec-date.prototype.sethours
+description: Checking DontEnum attribute
+---*/
+assert(
+ !Date.prototype.propertyIsEnumerable('setHours'),
+ 'The value of !Date.prototype.propertyIsEnumerable(\'setHours\') is expected to be true'
+);
+
+for (var x in Date.prototype) {
+ assert.notSameValue(x, "setHours", 'The value of x is not "setHours"');
+}
+
+// TODO: Convert to verifyProperty() format.
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A2_T1.js
new file mode 100644
index 0000000000..ccdabfa8fc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A2_T1.js
@@ -0,0 +1,17 @@
+// 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 "setHours" is 4
+esid: sec-date.prototype.sethours
+description: The "length" property of the "setHours" is 4
+---*/
+assert.sameValue(
+ Date.prototype.setHours.hasOwnProperty("length"),
+ true,
+ 'Date.prototype.setHours.hasOwnProperty("length") must return true'
+);
+
+assert.sameValue(Date.prototype.setHours.length, 4, 'The value of Date.prototype.setHours.length is expected to be 4');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T1.js
new file mode 100644
index 0000000000..9d5b7750df
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_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.setHours property "length" has { ReadOnly, DontDelete,
+ DontEnum } attributes
+esid: sec-date.prototype.sethours
+description: Checking ReadOnly attribute
+includes: [propertyHelper.js]
+---*/
+
+var x = Date.prototype.setHours.length;
+verifyNotWritable(Date.prototype.setHours, "length", null, 1);
+
+assert.sameValue(
+ Date.prototype.setHours.length,
+ x,
+ 'The value of Date.prototype.setHours.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/setHours/S15.9.5.34_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T2.js
new file mode 100644
index 0000000000..ac6a60cf7d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_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.setHours property "length" has { ReadOnly, !
+ DontDelete, DontEnum } attributes
+esid: sec-date.prototype.sethours
+description: Checking DontDelete attribute
+---*/
+assert.sameValue(
+ delete Date.prototype.setHours.length,
+ true,
+ 'The value of `delete Date.prototype.setHours.length` is expected to be true'
+);
+
+assert(
+ !Date.prototype.setHours.hasOwnProperty('length'),
+ 'The value of !Date.prototype.setHours.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/setHours/S15.9.5.34_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_A3_T3.js
new file mode 100644
index 0000000000..5b7172510a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/S15.9.5.34_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.setHours property "length" has { ReadOnly, DontDelete,
+ DontEnum } attributes
+esid: sec-date.prototype.sethours
+description: Checking DontEnum attribute
+---*/
+assert(
+ !Date.prototype.setHours.propertyIsEnumerable('length'),
+ 'The value of !Date.prototype.setHours.propertyIsEnumerable(\'length\') is expected to be true'
+);
+
+for (var x in Date.prototype.setHours) {
+ 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/setHours/arg-coercion-order.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-coercion-order.js
new file mode 100644
index 0000000000..48bd259079
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-coercion-order.js
@@ -0,0 +1,59 @@
+// 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.sethours
+description: Order of coercion of provided arguments vs NaN check
+info: |
+ 1. Let t be ? thisTimeValue(this value).
+ 2. Let h be ? ToNumber(hour).
+ 3. If min is present, let m be ? ToNumber(min).
+ 4. If sec is present, let s be ? ToNumber(sec).
+ 5. If ms is present, let milli be ? ToNumber(ms).
+ 6. If t is NaN, return NaN.
+ 7. Set t to LocalTime(t).
+ 8. If min is not present, let m be MinFromTime(t).
+ 9. If sec is not present, let s be SecFromTime(t).
+ 10. If ms is not present, let milli be msFromTime(t).
+ 11. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)).
+ 12. Let u be TimeClip(UTC(date)).
+ 13. Set the [[DateValue]] internal slot of this Date object to u.
+ 14. Return u.
+includes: [compareArray.js]
+---*/
+
+var date = new Date(NaN);
+var effects = [];
+var argHour = {
+ valueOf: function() {
+ effects.push('valueOf hour');
+ return 0;
+ }
+};
+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.setHours(argHour, argMin, argSec, argMs);
+
+var expectedEffects = ['valueOf hour', '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/setHours/arg-hour-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-to-number-err.js
new file mode 100644
index 0000000000..73dabb4639
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-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.sethours
+description: Abrupt completion during type coercion of provided "hour"
+info: |
+ 1. Let t be LocalTime(? thisTimeValue(this value)).
+ 2. Let dt be ? ToNumber(hour).
+---*/
+
+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.setHours(obj, counter, 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/setHours/arg-hour-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-to-number.js
new file mode 100644
index 0000000000..216be0e17c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-hour-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.sethours
+description: Type coercion of provided "hour"
+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(2016, 6);
+var callCount = 0;
+var arg = {
+ valueOf: function() {
+ args = arguments;
+ thisValue = this;
+ callCount += 1;
+ return 2;
+ }
+};
+var args, thisValue, returnValue;
+
+returnValue = date.setHours(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, 2).getTime(),
+ 'application of specified value'
+);
+
+returnValue = date.setHours(null);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1, 0).getTime(), 'null');
+
+returnValue = date.setHours(true);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1, 1).getTime(), 'true');
+
+returnValue = date.setHours(false);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1, 0).getTime(), 'false');
+
+returnValue = date.setHours(' +00200.000E-0002 ');
+
+assert.sameValue(returnValue, new Date(2016, 6, 1, 2).getTime(), 'string');
+
+returnValue = date.setHours();
+
+assert.sameValue(returnValue, NaN, 'undefined');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number-err.js
new file mode 100644
index 0000000000..4182ad87d6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-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.sethours
+description: Abrupt completion during type coercion of provided "min"
+info: |
+ 1. Let t be LocalTime(? thisTimeValue(this value)).
+ 2. Let dt be ? ToNumber(hour).
+ 3. If min is not specified, let m be MinFromTime(t); otherwise, 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.setHours(0, 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/setHours/arg-min-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-to-number.js
new file mode 100644
index 0000000000..a8436d2555
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-min-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.sethours
+description: Type coercion of provided "min"
+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(2016, 6);
+var callCount = 0;
+var arg = {
+ valueOf: function() {
+ args = arguments;
+ thisValue = this;
+ callCount += 1;
+ return 2;
+ }
+};
+var args, thisValue, returnValue;
+
+returnValue = date.setHours(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, 2).getTime(),
+ 'application of specified value'
+);
+
+returnValue = date.setHours(0, null);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null');
+
+returnValue = date.setHours(0, true);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 1).getTime(), 'true');
+
+returnValue = date.setHours(0, false);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false');
+
+returnValue = date.setHours(0, ' +00200.000E-0002 ');
+
+assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 2).getTime(), 'string');
+
+returnValue = date.setHours();
+
+assert.sameValue(returnValue, NaN, 'undefined');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number-err.js
new file mode 100644
index 0000000000..b8a62f59f6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number-err.js
@@ -0,0 +1,31 @@
+// 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.sethours
+description: Abrupt completion during type coercion of provided "ms"
+info: |
+ 1. Let t be LocalTime(? thisTimeValue(this value)).
+ 2. Let dt 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).
+---*/
+
+var date = new Date();
+var originalValue = date.getTime();
+var obj = {
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+assert.throws(Test262Error, function() {
+ date.setHours(0, 0, 0, obj);
+});
+
+assert.sameValue(date.getTime(), originalValue);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number.js
new file mode 100644
index 0000000000..8ea3112632
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-ms-to-number.js
@@ -0,0 +1,68 @@
+// 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.sethours
+description: Type coercion of provided "ms"
+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(2016, 6);
+var callCount = 0;
+var arg = {
+ valueOf: function() {
+ args = arguments;
+ thisValue = this;
+ callCount += 1;
+ return 2;
+ }
+};
+var args, thisValue, returnValue;
+
+returnValue = date.setHours(0, 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.setHours(0, 0, 0, null);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null');
+
+returnValue = date.setHours(0, 0, 0, true);
+
+assert.sameValue(
+ returnValue, new Date(2016, 6, 1, 0, 0, 0, 1).getTime(), 'true'
+);
+
+returnValue = date.setHours(0, 0, 0, false);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false');
+
+returnValue = date.setHours(0, 0, 0, ' +00200.000E-0002 ');
+
+assert.sameValue(
+ returnValue, new Date(2016, 6, 1, 0, 0, 0, 2).getTime(), 'string'
+);
+
+returnValue = date.setHours();
+
+assert.sameValue(returnValue, NaN, 'undefined');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number-err.js
new file mode 100644
index 0000000000..c0ba88235e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number-err.js
@@ -0,0 +1,36 @@
+// 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.sethours
+description: Abrupt completion during type coercion of provided "sec"
+info: |
+ 1. Let t be LocalTime(? thisTimeValue(this value)).
+ 2. Let dt 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).
+---*/
+
+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.setHours(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/setHours/arg-sec-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-to-number.js
new file mode 100644
index 0000000000..7171a1cb31
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/arg-sec-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.sethours
+description: Type coercion of provided "sec"
+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(2016, 6);
+var callCount = 0;
+var arg = {
+ valueOf: function() {
+ args = arguments;
+ thisValue = this;
+ callCount += 1;
+ return 2;
+ }
+};
+var args, thisValue, returnValue;
+
+returnValue = date.setHours(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, 2).getTime(),
+ 'application of specified value'
+);
+
+returnValue = date.setHours(0, 0, null);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'null');
+
+returnValue = date.setHours(0, 0, true);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1, 0, 0, 1).getTime(), 'true');
+
+returnValue = date.setHours(0, 0, false);
+
+assert.sameValue(returnValue, new Date(2016, 6, 1).getTime(), 'false');
+
+returnValue = date.setHours(0, 0, ' +00200.000E-0002 ');
+
+assert.sameValue(
+ returnValue, new Date(2016, 6, 1, 0, 0, 2).getTime(), 'string'
+);
+
+returnValue = date.setHours();
+
+assert.sameValue(returnValue, NaN, 'undefined');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/browser.js
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/name.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/name.js
new file mode 100644
index 0000000000..9626594fc3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/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.sethours
+description: >
+ Date.prototype.setHours.name is "setHours".
+info: |
+ Date.prototype.setHours ( hour [ , 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.setHours.name, "setHours");
+
+verifyNotEnumerable(Date.prototype.setHours, "name");
+verifyNotWritable(Date.prototype.setHours, "name");
+verifyConfigurable(Date.prototype.setHours, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/new-value-time-clip.js
new file mode 100644
index 0000000000..2c08a9fb54
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/new-value-time-clip.js
@@ -0,0 +1,54 @@
+// 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.sethours
+description: Behavior when new value exceeds [[DateValue]] limits
+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.
+
+ 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.setHours(24);
+
+assert.sameValue(returnValue, NaN, 'overflow due to hours');
+
+date = new Date(maxMs);
+
+returnValue = date.setHours(0, 24 * 60);
+
+assert.sameValue(returnValue, NaN, 'overflow due to minutes');
+
+date = new Date(maxMs);
+
+returnValue = date.setHours(0, 0, 24 * 60 * 60);
+
+assert.sameValue(returnValue, NaN, 'overflow due to seconds');
+
+date = new Date(maxMs);
+
+returnValue = date.setHours(0, 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/setHours/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/not-a-constructor.js
new file mode 100644
index 0000000000..767fe264d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/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.setHours 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.setHours),
+ false,
+ 'isConstructor(Date.prototype.setHours) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let date = new Date(Date.now()); new date.setHours();
+}, '`let date = new Date(Date.now()); new date.setHours()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/shell.js
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-invalid-date.js
new file mode 100644
index 0000000000..d31e9479c7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/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.sethours
+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.setHours(0);
+
+assert.sameValue(result, NaN, 'return value (hour)');
+assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (hour)');
+
+result = date.setHours(0, 0);
+
+assert.sameValue(result, NaN, 'return value (minute)');
+assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (minute)');
+
+result = date.setHours(0, 0, 0);
+
+assert.sameValue(result, NaN, 'return value (second)');
+assert.sameValue(date.getTime(), NaN, '[[DateValue]] internal slot (second)');
+
+result = date.setHours(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/setHours/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-non-date.js
new file mode 100644
index 0000000000..0112bd38ad
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/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.sethours
+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 setHours = Date.prototype.setHours;
+var callCount = 0;
+var arg = {
+ valueOf: function() {
+ callCount += 1;
+ return 1;
+ }
+};
+var args = (function() {
+ return arguments;
+}());
+
+assert.sameValue(typeof setHours, 'function');
+
+assert.throws(TypeError, function() {
+ setHours.call({}, arg);
+}, 'ordinary object');
+
+assert.throws(TypeError, function() {
+ setHours.call([], arg);
+}, 'array exotic object');
+
+assert.throws(TypeError, function() {
+ setHours.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/setHours/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-non-object.js
new file mode 100644
index 0000000000..6eee33d9cb
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/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.sethours
+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 setHours = Date.prototype.setHours;
+var callCount = 0;
+var arg = {
+ valueOf: function() {
+ callCount += 1;
+ return 1;
+ }
+};
+var symbol = Symbol();
+
+assert.sameValue(typeof setHours, 'function');
+
+assert.throws(TypeError, function() {
+ setHours.call(0, arg);
+}, 'number');
+
+assert.throws(TypeError, function() {
+ setHours.call(true, arg);
+}, 'boolean');
+
+assert.throws(TypeError, function() {
+ setHours.call(null, arg);
+}, 'null');
+
+assert.throws(TypeError, function() {
+ setHours.call(undefined, arg);
+}, 'undefined');
+
+assert.throws(TypeError, function() {
+ setHours.call('', arg);
+}, 'string');
+
+assert.throws(TypeError, function() {
+ setHours.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/setHours/this-value-valid-date-hour.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-hour.js
new file mode 100644
index 0000000000..da27e3a00b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-hour.js
@@ -0,0 +1,58 @@
+// 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.sethours
+description: Return value for valid dates (setting hour)
+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(2016, 6);
+var returnValue, expected;
+
+returnValue = date.setHours(6);
+
+expected = new Date(2016, 6, 1, 6).getTime();
+assert.sameValue(
+ returnValue, expected, 'hour within unit boundary (return value)'
+);
+assert.sameValue(
+ date.getTime(), expected, 'hour within unit boundary ([[DateValue]] slot)'
+);
+
+returnValue = date.setHours(-1);
+
+expected = new Date(2016, 5, 30, 23).getTime();
+assert.sameValue(
+ returnValue, expected, 'hour before time unit boundary (return value)'
+);
+assert.sameValue(
+ date.getTime(),
+ expected,
+ 'hour before time unit boundary ([[DateValue]] slot)'
+);
+
+returnValue = date.setHours(24);
+
+expected = new Date(2016, 6, 1).getTime();
+assert.sameValue(
+ returnValue, expected, 'hour after time unit boundary (return value)'
+);
+assert.sameValue(
+ date.getTime(),
+ expected,
+ 'hour after time unit boundary ([[DateValue]] slot)'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-min.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-min.js
new file mode 100644
index 0000000000..9469513e35
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-min.js
@@ -0,0 +1,58 @@
+// 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.sethours
+description: Return value for valid dates (setting min)
+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(2016, 6);
+var returnValue, expected;
+
+returnValue = date.setHours(0, 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.setHours(0, -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.setHours(0, 60);
+
+expected = new Date(2016, 5, 30, 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)'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-ms.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-ms.js
new file mode 100644
index 0000000000..00de558d9a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-ms.js
@@ -0,0 +1,60 @@
+// 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.sethours
+description: Return value for valid dates (setting ms)
+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(2016, 6);
+var returnValue, expected;
+
+returnValue = date.setHours(0, 0, 0, 543);
+
+expected = new Date(2016, 6, 1, 0, 0, 0, 543).getTime();
+assert.sameValue(
+ returnValue, expected, 'millisecond within unit boundary (return value)'
+);
+assert.sameValue(
+ date.getTime(),
+ expected,
+ 'millisecond within unit boundary ([[DateValue]] slot)'
+);
+
+returnValue = date.setHours(0, 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.setHours(0, 0, 0, 1000);
+
+expected = new Date(2016, 5, 30, 0, 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);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-sec.js b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-sec.js
new file mode 100644
index 0000000000..edfbe86f27
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setHours/this-value-valid-date-sec.js
@@ -0,0 +1,58 @@
+// 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.sethours
+description: Return value for valid dates (setting sec)
+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(2016, 6);
+var returnValue, expected;
+
+returnValue = date.setHours(0, 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.setHours(0, 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.setHours(0, 0, 60);
+
+expected = new Date(2016, 5, 30, 0, 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)'
+);
+
+reportCompare(0, 0);