Skip to content
Snippets Groups Projects
Commit 5f338a30 authored by Robin Templeton's avatar Robin Templeton Committed by Leo Balter
Browse files

Add tests for BigInt.prototype.valueOf (#1234)

* BigInt valueOf tests

* add features from typeCoercion.js
parent 2889100f
No related branches found
No related tags found
No related merge requests found
......@@ -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({});
}
// 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
});
// 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
});
// 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
});
// 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))
);
// 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))
);
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