From d88d1fb2ddea450ace82ca90aa9620c818d8dc61 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg <littledan@chromium.org> Date: Thu, 26 Oct 2017 15:06:46 +0200 Subject: [PATCH] BigInt: Add test for BigInt.prototype[Symbol.toStringTag] Tests the fix for https://github.com/tc39/proposal-bigint/issues/92 --- .../BigInt/prototype/Symbol.toStringTag.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/built-ins/BigInt/prototype/Symbol.toStringTag.js diff --git a/test/built-ins/BigInt/prototype/Symbol.toStringTag.js b/test/built-ins/BigInt/prototype/Symbol.toStringTag.js new file mode 100644 index 0000000000..7700bc4fd5 --- /dev/null +++ b/test/built-ins/BigInt/prototype/Symbol.toStringTag.js @@ -0,0 +1,37 @@ +// Copyright (C) 2017 Igalia, S. L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-bigint-@@tostringtag +description: > + `Symbol.toStringTag` property descriptor +info: > + The initial value of the @@toStringTag property is the String value + "BigInt". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toStringTag, BigInt, Symbol] +---*/ + +verifyProperty(BigInt.prototype, Symbol.toStringTag, { + value: "BigInt", + writable: false, + enumerable: false, + configurable: true +}); + +assertEquals("[object BigInt]", Object.prototype.toString.call(3n)); +assertEquals("[object BigInt]", Object.prototype.toString.call(Object(3n))); + +// Verify that Object.prototype.toString does not have special casing for BigInt +// as it does for most other primitive types +Object.defineProperty(BigInt.prototype, { + value: "FooBar", + writable: false, + enumerable: false, + configurable: true +}); + +assertEquals("[object FooBar]", Object.prototype.toString.call(3n)); +assertEquals("[object FooBar]", Object.prototype.toString.call(Object(3n))); -- GitLab