1 // Copyright (C) 2019 Aleksey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 esid: sec-date.prototype.tojson
6 Abrupt completion from ToPrimitive.
8 Date.prototype.toJSON ( key )
11 2. Let tv be ? ToPrimitive(O, hint Number).
13 ToPrimitive ( input [ , PreferredType ] )
15 1. Assert: input is an ECMAScript language value.
16 2. If Type(input) is Object, then
18 g. Return ? OrdinaryToPrimitive(input, hint).
20 OrdinaryToPrimitive ( O, hint )
23 5. For each name in methodNames in List order, do
24 a. Let method be ? Get(O, name).
25 b. If IsCallable(method) is true, then
26 i. Let result be ? Call(method, O).
27 ii. If Type(result) is not Object, return result.
28 6. Throw a TypeError exception.
31 var toJSON = Date.prototype.toJSON;
34 throw new Test262Error();
38 assert.throws(Test262Error, function() {
39 toJSON.call(getAbrupt);
43 toString: function() {
44 throw new Test262Error();
48 assert.throws(Test262Error, function() {
49 toJSON.call(callAbrupt);
52 var notCoercible = Object.create(null);
54 assert.throws(TypeError, function() {
55 toJSON.call(notCoercible);