Skip to content
Snippets Groups Projects
Commit 904d90d0 authored by Robin Templeton's avatar Robin Templeton
Browse files

Add Object.prototype.toString tests for BigInt.

Reported by André Bargull in
<https://bugzilla.mozilla.org/show_bug.cgi?id=1464758>.
parent 92003a3e
No related branches found
No related tags found
No related merge requests found
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.prototype.tostring
description: Non-string values of `@@toStringTag` property are ignored
info: |
14. Else, let builtinTag be "Object".
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, let tag be builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [BigInt, Symbol.toStringTag]
---*/
let custom1 = BigInt(0);
let custom2 = Object(BigInt(0));
Object.defineProperty(BigInt.prototype, Symbol.toStringTag, {value: undefined});
assert.sameValue(Object.prototype.toString.call(custom1), '[object Object]');
assert.sameValue(Object.prototype.toString.call(custom2), '[object Object]');
Object.defineProperty(BigInt.prototype, Symbol.toStringTag, {value: null});
assert.sameValue(Object.prototype.toString.call(custom1), '[object Object]');
assert.sameValue(Object.prototype.toString.call(custom2), '[object Object]');
Object.defineProperty(BigInt.prototype, Symbol.toStringTag, {value: Symbol.toStringTag});
assert.sameValue(Object.prototype.toString.call(custom1), '[object Object]');
assert.sameValue(Object.prototype.toString.call(custom2), '[object Object]');
Object.defineProperty(BigInt.prototype, Symbol.toStringTag, {value: 86});
assert.sameValue(Object.prototype.toString.call(custom1), '[object Object]');
assert.sameValue(Object.prototype.toString.call(custom2), '[object Object]');
Object.defineProperty(BigInt.prototype, Symbol.toStringTag, {value: new String('test262')});
assert.sameValue(Object.prototype.toString.call(custom1), '[object Object]');
assert.sameValue(Object.prototype.toString.call(custom2), '[object Object]');
Object.defineProperty(BigInt.prototype, Symbol.toStringTag, {value: {}});
assert.sameValue(Object.prototype.toString.call(custom1), '[object Object]');
assert.sameValue(Object.prototype.toString.call(custom2), '[object Object]');
Object.defineProperty(BigInt.prototype, Symbol.toStringTag, {value: _ => 'str'});
assert.sameValue(Object.prototype.toString.call(custom1), '[object Object]');
assert.sameValue(Object.prototype.toString.call(custom2), '[object Object]');
// Copyright (C) 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.prototype.tostring
description: String values of `@@toStringTag` property override built-in tags
info: |
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, let tag be builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [BigInt, Symbol.toStringTag]
---*/
let custom1 = BigInt(0);
let custom2 = Object(BigInt(0));
Object.defineProperty(BigInt.prototype, Symbol.toStringTag, {value: 'test262'});
assert.sameValue(Object.prototype.toString.call(custom1), '[object test262]');
assert.sameValue(Object.prototype.toString.call(custom2), '[object test262]');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment