diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Date/prototype/toJSON/to-object.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Date/prototype/toJSON/to-object.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-object.js b/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-object.js new file mode 100644 index 0000000000..579cc102a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Date/prototype/toJSON/to-object.js @@ -0,0 +1,31 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-date.prototype.tojson +description: > + This value is coerced to an object. +info: | + Date.prototype.toJSON ( key ) + + 1. Let O be ? ToObject(this value). +features: [Symbol] +---*/ + +var toJSON = Date.prototype.toJSON; +this.toISOString = function() { return 'global'; }; + +assert.throws(TypeError, function() { + toJSON.call(undefined); +}); + +assert.throws(TypeError, function() { + toJSON.call(null); +}); + +Number.prototype.toISOString = function() { return 'str'; }; +assert.sameValue(toJSON.call(10), 'str'); + +Symbol.prototype.toISOString = function() { return 10; }; +assert.sameValue(toJSON.call(Symbol()), 10); + +reportCompare(0, 0); |