mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Add tests for BigInt.prototype.valueOf (#1234)
* BigInt valueOf tests * add features from typeCoercion.js
This commit is contained in:
parent
2889100f21
commit
5f338a30a1
@ -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({});
|
||||
}
|
||||
|
20
test/built-ins/BigInt/prototype/valueOf/length.js
vendored
Normal file
20
test/built-ins/BigInt/prototype/valueOf/length.js
vendored
Normal file
@ -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
|
||||
});
|
20
test/built-ins/BigInt/prototype/valueOf/name.js
vendored
Normal file
20
test/built-ins/BigInt/prototype/valueOf/name.js
vendored
Normal file
@ -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
|
||||
});
|
19
test/built-ins/BigInt/prototype/valueOf/prop-desc.js
vendored
Normal file
19
test/built-ins/BigInt/prototype/valueOf/prop-desc.js
vendored
Normal file
@ -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
|
||||
});
|
17
test/built-ins/BigInt/prototype/valueOf/this-value-err.js
vendored
Normal file
17
test/built-ins/BigInt/prototype/valueOf/this-value-err.js
vendored
Normal file
@ -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))
|
||||
);
|
18
test/built-ins/BigInt/prototype/valueOf/this-value.js
vendored
Normal file
18
test/built-ins/BigInt/prototype/valueOf/this-value.js
vendored
Normal file
@ -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))
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user