diff --git a/harness/typeCoercion.js b/harness/typeCoercion.js index 7cd6a9de3c..76d366d762 100644 --- a/harness/typeCoercion.js +++ b/harness/typeCoercion.js @@ -407,3 +407,19 @@ function testNotCoercibleToBigInt(test) { testStringValue("0xg"); testStringValue("1n"); } + +function testCoercibleToBigIntThisValue(value, test) { + test(value); + test(Object(value)); +} + +function testNotCoercibleToBigIntThisValue(test) { + test(undefined); + test(null); + test(true); + test(false); + test(""); + test(Symbol("")); + test(0); + test({}); +} diff --git a/test/built-ins/BigInt/prototype/valueOf/length.js b/test/built-ins/BigInt/prototype/valueOf/length.js new file mode 100644 index 0000000000..bf61b877f0 --- /dev/null +++ b/test/built-ins/BigInt/prototype/valueOf/length.js @@ -0,0 +1,20 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-bigint.prototype.valueof +description: BigInt.prototype.valueOf.length property descriptor +info: > + BigInt.prototype.valueOf ( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [BigInt] +---*/ + +verifyProperty(BigInt.prototype.valueOf, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/built-ins/BigInt/prototype/valueOf/name.js b/test/built-ins/BigInt/prototype/valueOf/name.js new file mode 100644 index 0000000000..c179e0c145 --- /dev/null +++ b/test/built-ins/BigInt/prototype/valueOf/name.js @@ -0,0 +1,20 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-bigint.prototype.valueof +description: BigInt.prototype.valueOf.name property descriptor +info: > + BigInt.prototype.valueOf ( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [BigInt] +---*/ + +verifyProperty(BigInt.prototype.valueOf, "name", { + value: "valueOf", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/built-ins/BigInt/prototype/valueOf/prop-desc.js b/test/built-ins/BigInt/prototype/valueOf/prop-desc.js new file mode 100644 index 0000000000..324fc8f304 --- /dev/null +++ b/test/built-ins/BigInt/prototype/valueOf/prop-desc.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-bigint.prototype.valueof +description: BigInt.prototype.valueOf property descriptor +info: > + BigInt.prototype.valueOf ( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [BigInt] +---*/ + +verifyProperty(BigInt.prototype, "valueOf", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/built-ins/BigInt/prototype/valueOf/this-value-err.js b/test/built-ins/BigInt/prototype/valueOf/this-value-err.js new file mode 100644 index 0000000000..b707455e64 --- /dev/null +++ b/test/built-ins/BigInt/prototype/valueOf/this-value-err.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-bigint.prototype.valueof +description: BigInt.prototype.valueOf this value coercion +info: > + BigInt.prototype.valueOf ( ) + + Return ? thisBigIntValue(this value). +includes: [typeCoercion.js] +features: [BigInt, arrow-function, Symbol, Symbol.toPrimitive] +---*/ + +testNotCoercibleToBigIntThisValue( + (x) => assert.throws(TypeError, () => BigInt.prototype.valueOf.call(x)) +); diff --git a/test/built-ins/BigInt/prototype/valueOf/this-value.js b/test/built-ins/BigInt/prototype/valueOf/this-value.js new file mode 100644 index 0000000000..4d383aa9cf --- /dev/null +++ b/test/built-ins/BigInt/prototype/valueOf/this-value.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-bigint.prototype.valueof +description: BigInt.prototype.valueOf this value coercion +info: > + BigInt.prototype.valueOf ( ) + + Return ? thisBigIntValue(this value). +includes: [typeCoercion.js] +features: [BigInt, arrow-function, Symbol, Symbol.toPrimitive] +---*/ + +testCoercibleToBigIntThisValue( + 0n, + (x) => assert.sameValue(0n, BigInt.prototype.valueOf.call(x)) +);