summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive')
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/called-as-function.js35
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-invalid.js40
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-non-callable.js35
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-valid.js38
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-no-callables.js28
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-invalid.js57
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-invalid.js40
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-non-callable.js35
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-valid.js38
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-no-callables.js28
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-invalid.js40
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-non-callable.js35
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-valid.js38
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-no-callables.js28
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js29
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js28
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/prop-desc.js18
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/this-val-non-obj.js34
20 files changed, 624 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/browser.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/browser.js
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/called-as-function.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/called-as-function.js
new file mode 100644
index 0000000000..fcdf27ee65
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/called-as-function.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ `this` value is resolved using strict mode semantics,
+ throwing TypeError if called as top-level function.
+info: |
+ Date.prototype [ @@toPrimitive ] ( hint )
+
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+
+ ToObject ( argument )
+
+ Argument Type: Undefined
+ Result: Throw a TypeError exception.
+features: [Symbol, Symbol.toPrimitive]
+---*/
+
+["toString", "valueOf"].forEach(function(key) {
+ Object.defineProperty(this, key, {
+ get: function() {
+ throw new Test262Error(key + " lookup should not be performed");
+ },
+ });
+}, this);
+
+var toPrimitive = Date.prototype[Symbol.toPrimitive];
+assert.throws(TypeError, function() {
+ toPrimitive("default");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-invalid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-invalid.js
new file mode 100644
index 0000000000..5d17cdd87d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-invalid.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "default" and first try returns an invalid value
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var voCallCount = 0;
+var tsCallCount = 0;
+var obj = {
+ valueOf: function() {
+ voCallCount += 1;
+ return 'valueOf test262';
+ },
+ toString: function() {
+ tsCallCount += 1;
+ return {};
+ }
+};
+
+assert.sameValue(
+ Date.prototype[Symbol.toPrimitive].call(obj, 'default'),
+ 'valueOf test262',
+ '`valueOf` is used as a fallback when `toString` returns an object'
+);
+assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once');
+assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-non-callable.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-non-callable.js
new file mode 100644
index 0000000000..16a7430b84
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-non-callable.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "default" and first try is not callable
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var voCallCount = 0;
+var obj = {
+ valueOf: function() {
+ voCallCount += 1;
+ return 'valueOf test262';
+ },
+ toString: null
+};
+
+assert.sameValue(
+ Date.prototype[Symbol.toPrimitive].call(obj, 'default'),
+ 'valueOf test262',
+ '`valueOf` is used as a fallback when `toString` is not callable'
+);
+assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-valid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-valid.js
new file mode 100644
index 0000000000..3512ecb52d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-first-valid.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "default" and first try returns a valid value
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var voAccessCount = 0;
+var tsCallCount = 0;;
+var obj = {
+ get valueOf() {
+ voAccessCount += 1;
+ },
+ toString: function() {
+ tsCallCount += 1;
+ return 'toString test262';
+ }
+};
+
+assert.sameValue(
+ Date.prototype[Symbol.toPrimitive].call(obj, 'default'),
+ 'toString test262'
+);
+assert.sameValue(voAccessCount, 0, '`valueOf` method was not referenced');
+assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-no-callables.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-no-callables.js
new file mode 100644
index 0000000000..7950211228
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-default-no-callables.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "default" and neither first nor second try are callable.
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var obj = {
+ valueOf: null,
+ toString: null
+};
+
+assert.throws(TypeError, function() {
+ Date.prototype[Symbol.toPrimitive].call(obj, 'default');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-invalid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-invalid.js
new file mode 100644
index 0000000000..243a4ef206
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-invalid.js
@@ -0,0 +1,57 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: Behavior when an invalid `hint` argument is specified
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+features: [Symbol.toPrimitive]
+---*/
+
+var d = new Date();
+
+assert.sameValue(typeof d[Symbol.toPrimitive], 'function');
+
+assert.throws(TypeError, function() {
+ d[Symbol.toPrimitive]();
+});
+
+assert.throws(TypeError, function() {
+ d[Symbol.toPrimitive](undefined);
+});
+
+assert.throws(TypeError, function() {
+ d[Symbol.toPrimitive](null);
+});
+
+assert.throws(TypeError, function() {
+ d[Symbol.toPrimitive]('');
+});
+
+assert.throws(TypeError, function() {
+ d[Symbol.toPrimitive]('String');
+});
+
+assert.throws(TypeError, function() {
+ d[Symbol.toPrimitive]('defaultnumber');
+});
+
+assert.throws(TypeError, function() {
+ d[Symbol.toPrimitive](new String('number'));
+});
+
+assert.throws(TypeError, function() {
+ d[Symbol.toPrimitive]({
+ toString: function() {
+ 'number';
+ }
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-invalid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-invalid.js
new file mode 100644
index 0000000000..d151a2cbec
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-invalid.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "number" and first try returns an invalid value
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var voCallCount = 0;
+var tsCallCount = 0;
+var obj = {
+ valueOf: function() {
+ voCallCount += 1;
+ return {};
+ },
+ toString: function() {
+ tsCallCount += 1;
+ return 'toString test262';
+ }
+};
+
+assert.sameValue(
+ Date.prototype[Symbol.toPrimitive].call(obj, 'number'),
+ 'toString test262',
+ '`toString` is used as a fallback when `valueOf` returns an object'
+);
+assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once');
+assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-non-callable.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-non-callable.js
new file mode 100644
index 0000000000..a4071061e5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-non-callable.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "number" and first try is not callable
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var tsCallCount = 0;
+var obj = {
+ valueOf: null,
+ toString: function() {
+ tsCallCount += 1;
+ return 'toString test262';
+ }
+};
+
+assert.sameValue(
+ Date.prototype[Symbol.toPrimitive].call(obj, 'number'),
+ 'toString test262',
+ '`toString` is used as a fallback when `valueOf` is not callable'
+);
+assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-valid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-valid.js
new file mode 100644
index 0000000000..249e9e5bf9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-first-valid.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "number" and first try returns a valid value
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var voCallCount = 0;
+var tsAccessCount = 0;
+var obj = {
+ valueOf: function() {
+ voCallCount += 1;
+ return 'valueOf test262';
+ },
+ get toString() {
+ tsAccessCount += 1;
+ }
+};
+
+assert.sameValue(
+ Date.prototype[Symbol.toPrimitive].call(obj, 'number'),
+ 'valueOf test262'
+);
+assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once');
+assert.sameValue(tsAccessCount, 0, '`toString` method was not referenced');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-no-callables.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-no-callables.js
new file mode 100644
index 0000000000..c2eaba27ed
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-number-no-callables.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "number" and neither first nor second try are callable.
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var obj = {
+ valueOf: null,
+ toString: null
+};
+
+assert.throws(TypeError, function() {
+ Date.prototype[Symbol.toPrimitive].call(obj, 'number');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-invalid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-invalid.js
new file mode 100644
index 0000000000..714410b032
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-invalid.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "string" and first try returns an invalid value
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var voCallCount = 0;
+var tsCallCount = 0;
+var obj = {
+ valueOf: function() {
+ voCallCount += 1;
+ return 'valueOf test262';
+ },
+ toString: function() {
+ tsCallCount += 1;
+ return {};
+ }
+};
+
+assert.sameValue(
+ Date.prototype[Symbol.toPrimitive].call(obj, 'string'),
+ 'valueOf test262',
+ '`valueOf` is used as a fallback when `toString` returns an object'
+);
+assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once');
+assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-non-callable.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-non-callable.js
new file mode 100644
index 0000000000..2619af0be7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-non-callable.js
@@ -0,0 +1,35 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "string" and first try is not callable
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var voCallCount = 0;
+var obj = {
+ valueOf: function() {
+ voCallCount += 1;
+ return 'valueOf test262';
+ },
+ toString: null
+};
+
+assert.sameValue(
+ Date.prototype[Symbol.toPrimitive].call(obj, 'string'),
+ 'valueOf test262',
+ '`valueOf` is used as a fallback when `toString` is not callable'
+);
+assert.sameValue(voCallCount, 1, '`valueOf` method was invoked exactly once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-valid.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-valid.js
new file mode 100644
index 0000000000..dee4c72897
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-first-valid.js
@@ -0,0 +1,38 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "string" and first try returns a valid value
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var voAccessCount = 0;
+var tsCallCount = 0;
+var obj = {
+ get valueOf() {
+ voAccessCount += 1;
+ },
+ toString: function() {
+ tsCallCount += 1;
+ return 'toString test262';
+ }
+};
+
+assert.sameValue(
+ Date.prototype[Symbol.toPrimitive].call(obj, 'string'),
+ 'toString test262'
+);
+assert.sameValue(voAccessCount, 0, '`valueOf` method was not referenced');
+assert.sameValue(tsCallCount, 1, '`toString` method was invoked exactly once');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-no-callables.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-no-callables.js
new file mode 100644
index 0000000000..3ff8fb1bf6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/hint-string-no-callables.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: >
+ Behavior when `hint` is "string" and neither first nor second try are callable.
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+ 3. If hint is the String value "string" or the String value "default", then
+ a. Let tryFirst be "string".
+ 4. Else if hint is the String value "number", then
+ a. Let tryFirst be "number".
+ 5. Else, throw a TypeError exception.
+ 6. Return OrdinaryToPrimitive(O, tryFirst).
+features: [Symbol.toPrimitive]
+---*/
+
+var obj = {
+ valueOf: null,
+ toString: null
+};
+
+assert.throws(TypeError, function() {
+ Date.prototype[Symbol.toPrimitive].call(obj, 'string');
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js
new file mode 100644
index 0000000000..1e46f05120
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/length.js
@@ -0,0 +1,29 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: Date.prototype[Symbol.toPrimitive] `length` property
+info: |
+ ES6 section 17:
+
+ Every built-in Function object, including constructors, has a length
+ property whose value is an integer. Unless otherwise specified, this value
+ is equal to the largest number of named arguments shown in the subclause
+ headings for the function description, including optional parameters.
+
+ [...]
+
+ Unless otherwise specified, the length property of a built-in Function
+ object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+features: [Symbol.toPrimitive]
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Date.prototype[Symbol.toPrimitive].length, 1);
+
+verifyNotEnumerable(Date.prototype[Symbol.toPrimitive], 'length');
+verifyNotWritable(Date.prototype[Symbol.toPrimitive], 'length');
+verifyConfigurable(Date.prototype[Symbol.toPrimitive], 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js
new file mode 100644
index 0000000000..e1e40be0fe
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/name.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: Date.prototype[Symbol.toPrimitive] `name` property
+info: |
+ The value of the name property of this function is "[Symbol.toPrimitive]".
+
+ ES6 Section 17:
+
+ [...]
+
+ Unless otherwise specified, the name property of a built-in Function
+ object, if it exists, has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+features: [Symbol.toPrimitive]
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(
+ Date.prototype[Symbol.toPrimitive].name, '[Symbol.toPrimitive]'
+);
+
+verifyNotEnumerable(Date.prototype[Symbol.toPrimitive], 'name');
+verifyNotWritable(Date.prototype[Symbol.toPrimitive], 'name');
+verifyConfigurable(Date.prototype[Symbol.toPrimitive], 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/prop-desc.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/prop-desc.js
new file mode 100644
index 0000000000..88fa1fffc5
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/prop-desc.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: Date.prototype[Symbol.toPrimitive] property descriptor
+info: |
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]:
+ false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Symbol.toPrimitive]
+---*/
+
+verifyNotEnumerable(Date.prototype, Symbol.toPrimitive);
+verifyNotWritable(Date.prototype, Symbol.toPrimitive);
+verifyConfigurable(Date.prototype, Symbol.toPrimitive);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/shell.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/shell.js
diff --git a/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/this-val-non-obj.js b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/this-val-non-obj.js
new file mode 100644
index 0000000000..ae8cc55b6a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Date/prototype/Symbol.toPrimitive/this-val-non-obj.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2015 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-date.prototype-@@toprimitive
+description: Behavior when `this` value is not an Object
+info: |
+ 1. Let O be the this value.
+ 2. If Type(O) is not Object, throw a TypeError exception.
+features: [Symbol.toPrimitive]
+---*/
+
+assert.sameValue(typeof Date.prototype[Symbol.toPrimitive], 'function');
+
+assert.throws(TypeError, function() {
+ Date.prototype[Symbol.toPrimitive].call(undefined, 'string');
+});
+
+assert.throws(TypeError, function() {
+ Date.prototype[Symbol.toPrimitive].call(null, 'string');
+});
+
+assert.throws(TypeError, function() {
+ Date.prototype[Symbol.toPrimitive].call(86, 'string');
+});
+
+assert.throws(TypeError, function() {
+ Date.prototype[Symbol.toPrimitive].call('', 'string');
+});
+
+assert.throws(TypeError, function() {
+ Date.prototype[Symbol.toPrimitive].call(true, 'string');
+});
+
+reportCompare(0, 0);