summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Date/prototype/setDate
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Date/prototype/setDate')
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T1.js25
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T2.js18
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T3.js20
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A2_T1.js17
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T1.js24
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T2.js24
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T3.js22
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/arg-coercion-order.js32
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number-err.js25
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number.js57
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/name.js28
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/new-value-time-clip.js30
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/not-a-constructor.js35
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-invalid-date.js25
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-non-date.js45
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-non-object.js55
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-valid-date.js49
19 files changed, 531 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T1.js
new file mode 100644
index 0000000000..801ffd0e17
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_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 "setDate" has { DontEnum } attributes
+esid: sec-date.prototype.setdate
+description: Checking absence of ReadOnly attribute
+---*/
+
+var x = Date.prototype.setDate;
+if (x === 1) {
+ Date.prototype.setDate = 2;
+} else {
+ Date.prototype.setDate = 1;
+}
+
+assert.notSameValue(
+ Date.prototype.setDate,
+ x,
+ 'The value of Date.prototype.setDate 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/setDate/S15.9.5.36_A1_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T2.js
new file mode 100644
index 0000000000..d0ad33c7de
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_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 "setDate" has { DontEnum } attributes
+esid: sec-date.prototype.setdate
+description: Checking absence of DontDelete attribute
+---*/
+assert.notSameValue(delete Date.prototype.setDate, false, 'The value of delete Date.prototype.setDate is not false');
+
+assert(
+ !Date.prototype.hasOwnProperty('setDate'),
+ 'The value of !Date.prototype.hasOwnProperty(\'setDate\') is expected to be true'
+);
+
+// TODO: Convert to verifyProperty() format.
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A1_T3.js
new file mode 100644
index 0000000000..f6f9ffd930
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_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 "setDate" has { DontEnum } attributes
+esid: sec-date.prototype.setdate
+description: Checking DontEnum attribute
+---*/
+assert(
+ !Date.prototype.propertyIsEnumerable('setDate'),
+ 'The value of !Date.prototype.propertyIsEnumerable(\'setDate\') is expected to be true'
+);
+
+for (var x in Date.prototype) {
+ assert.notSameValue(x, "setDate", 'The value of x is not "setDate"');
+}
+
+// TODO: Convert to verifyProperty() format.
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A2_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A2_T1.js
new file mode 100644
index 0000000000..a54d6a167d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_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 "setDate" is 1
+esid: sec-date.prototype.setdate
+description: The "length" property of the "setDate" is 1
+---*/
+assert.sameValue(
+ Date.prototype.setDate.hasOwnProperty("length"),
+ true,
+ 'Date.prototype.setDate.hasOwnProperty("length") must return true'
+);
+
+assert.sameValue(Date.prototype.setDate.length, 1, 'The value of Date.prototype.setDate.length is expected to be 1');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T1.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T1.js
new file mode 100644
index 0000000000..97e9613bb6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_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.setDate property "length" has { ReadOnly, DontDelete,
+ DontEnum } attributes
+esid: sec-date.prototype.setdate
+description: Checking ReadOnly attribute
+includes: [propertyHelper.js]
+---*/
+
+var x = Date.prototype.setDate.length;
+verifyNotWritable(Date.prototype.setDate, "length", null, 1);
+
+assert.sameValue(
+ Date.prototype.setDate.length,
+ x,
+ 'The value of Date.prototype.setDate.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/setDate/S15.9.5.36_A3_T2.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T2.js
new file mode 100644
index 0000000000..5b82b4c5d2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_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.setDate property "length" has { ReadOnly, !
+ DontDelete, DontEnum } attributes
+esid: sec-date.prototype.setdate
+description: Checking DontDelete attribute
+---*/
+assert.sameValue(
+ delete Date.prototype.setDate.length,
+ true,
+ 'The value of `delete Date.prototype.setDate.length` is expected to be true'
+);
+
+assert(
+ !Date.prototype.setDate.hasOwnProperty('length'),
+ 'The value of !Date.prototype.setDate.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/setDate/S15.9.5.36_A3_T3.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_A3_T3.js
new file mode 100644
index 0000000000..7bc1624b0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/S15.9.5.36_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.setDate property "length" has { ReadOnly, DontDelete,
+ DontEnum } attributes
+esid: sec-date.prototype.setdate
+description: Checking DontEnum attribute
+---*/
+assert(
+ !Date.prototype.setDate.propertyIsEnumerable('length'),
+ 'The value of !Date.prototype.setDate.propertyIsEnumerable(\'length\') is expected to be true'
+);
+
+for (var x in Date.prototype.setDate) {
+ 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/setDate/arg-coercion-order.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-coercion-order.js
new file mode 100644
index 0000000000..094bec4454
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/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.setdate
+description: Order of coercion of provided argument vs NaN check
+info: |
+ 1. Let t be ? thisTimeValue(this value).
+ 2. Let dt be ? ToNumber(date).
+ 3. If t is NaN, return NaN.
+ 4. Set t to LocalTime(t).
+ 5. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), TimeWithinDay(t)).
+ 6. Let u be TimeClip(UTC(newDate)).
+ 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.setDate(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/setDate/arg-to-number-err.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number-err.js
new file mode 100644
index 0000000000..487518b9b7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/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.setdate
+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.setDate(obj);
+});
+
+assert.sameValue(date.getTime(), originalValue);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number.js
new file mode 100644
index 0000000000..84997779ce
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/arg-to-number.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype.setdate
+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.setDate(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, 2).getTime(), 'application of specified value'
+);
+
+returnValue = date.setDate(null);
+
+assert.sameValue(returnValue, new Date(2016, 5, 30).getTime(), 'null');
+
+returnValue = date.setDate(true);
+
+assert.sameValue(returnValue, new Date(2016, 5, 1).getTime(), 'true');
+
+returnValue = date.setDate(false);
+
+assert.sameValue(returnValue, new Date(2016, 4, 31).getTime(), 'false');
+
+returnValue = date.setDate(' +00200.000E-0002 ');
+
+assert.sameValue(returnValue, new Date(2016, 4, 2).getTime(), 'string');
+
+returnValue = date.setDate();
+
+assert.sameValue(returnValue, NaN, 'undefined');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/browser.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/browser.js
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/name.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/name.js
new file mode 100644
index 0000000000..15ba085ab7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/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.setdate
+description: >
+ Date.prototype.setDate.name is "setDate".
+info: |
+ Date.prototype.setDate ( date )
+
+ 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.setDate.name, "setDate");
+
+verifyNotEnumerable(Date.prototype.setDate, "name");
+verifyNotWritable(Date.prototype.setDate, "name");
+verifyConfigurable(Date.prototype.setDate, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/new-value-time-clip.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/new-value-time-clip.js
new file mode 100644
index 0000000000..d0c25070ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/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.setdate
+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.setDate(28);
+
+assert.sameValue(returnValue, NaN);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/not-a-constructor.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/not-a-constructor.js
new file mode 100644
index 0000000000..cc4d2bca46
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/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.setDate 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.setDate),
+ false,
+ 'isConstructor(Date.prototype.setDate) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let date = new Date(Date.now()); new date.setDate();
+}, '`let date = new Date(Date.now()); new date.setDate()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/shell.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/shell.js
diff --git a/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-invalid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-invalid-date.js
new file mode 100644
index 0000000000..e3e8e953b9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/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.setdate
+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.setDate(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/setDate/this-value-non-date.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-non-date.js
new file mode 100644
index 0000000000..66fd4e6881
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/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.setdate
+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 setDate = Date.prototype.setDate;
+var callCount = 0;
+var arg = {
+ valueOf: function() {
+ callCount += 1;
+ return 1;
+ }
+};
+var args = (function() {
+ return arguments;
+}());
+
+assert.sameValue(typeof setDate, 'function');
+
+assert.throws(TypeError, function() {
+ setDate.call({}, arg);
+}, 'ordinary object');
+
+assert.throws(TypeError, function() {
+ setDate.call([], arg);
+}, 'array exotic object');
+
+assert.throws(TypeError, function() {
+ setDate.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/setDate/this-value-non-object.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-non-object.js
new file mode 100644
index 0000000000..6033b0c9aa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/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.setdate
+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 setDate = Date.prototype.setDate;
+var callCount = 0;
+var arg = {
+ valueOf: function() {
+ callCount += 1;
+ return 1;
+ }
+};
+var symbol = Symbol();
+
+assert.sameValue(typeof setDate, 'function');
+
+assert.throws(TypeError, function() {
+ setDate.call(0, arg);
+}, 'number');
+
+assert.throws(TypeError, function() {
+ setDate.call(true, arg);
+}, 'boolean');
+
+assert.throws(TypeError, function() {
+ setDate.call(null, arg);
+}, 'null');
+
+assert.throws(TypeError, function() {
+ setDate.call(undefined, arg);
+}, 'undefined');
+
+assert.throws(TypeError, function() {
+ setDate.call('', arg);
+}, 'string');
+
+assert.throws(TypeError, function() {
+ setDate.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/setDate/this-value-valid-date.js b/js/src/tests/test262/built-ins/Date/prototype/setDate/this-value-valid-date.js
new file mode 100644
index 0000000000..8ce10fc6ef
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/setDate/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.setdate
+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.setDate(6);
+
+expected = new Date(2016, 6, 6).getTime();
+assert.sameValue(
+ returnValue, expected, 'within unit boundary (return value)'
+);
+assert.sameValue(
+ date.getTime(), expected, 'within unit boundary ([[DateValue]] slot)'
+);
+
+returnValue = date.setDate(0);
+
+expected = new Date(2016, 5, 30).getTime();
+assert.sameValue(
+ returnValue, expected, 'before time unit boundary (return value)'
+);
+assert.sameValue(
+ date.getTime(), expected, 'before time unit boundary ([[DateValue]] slot)'
+);
+
+returnValue = date.setDate(31);
+
+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);