BigInt: additional info frontmatter. Validated features (#1518)

This commit is contained in:
Rick Waldron 2018-04-18 16:56:06 -04:00 committed by Leo Balter
parent a1a4e2b1b8
commit cd6305155b
24 changed files with 123 additions and 54 deletions

View File

@ -7,7 +7,7 @@ info: |
BigInt.asIntN ( bits, bigint ) BigInt.asIntN ( bits, bigint )
2. Let bigint ? ToBigInt(bigint). 2. Let bigint ? ToBigInt(bigint).
features: [BigInt, Symbol, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
assert.throws(TypeError, function() { assert.throws(TypeError, function() {

View File

@ -7,7 +7,7 @@ info: |
BigInt.asIntN ( bits, bigint ) BigInt.asIntN ( bits, bigint )
2. Let bigint ? ToBigInt(bigint). 2. Let bigint ? ToBigInt(bigint).
features: [BigInt, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
function err() { function err() {

View File

@ -7,7 +7,7 @@ info: |
BigInt.asIntN ( bits, bigint ) BigInt.asIntN ( bits, bigint )
2. Let bigint ? ToBigInt(bigint). 2. Let bigint ? ToBigInt(bigint).
features: [BigInt, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
assert.sameValue(BigInt.asIntN(2, Object(0n)), 0n, "ToPrimitive: unbox object with internal slot"); assert.sameValue(BigInt.asIntN(2, Object(0n)), 0n, "ToPrimitive: unbox object with internal slot");

View File

@ -7,7 +7,7 @@ info: |
BigInt.asIntN ( bits, bigint ) BigInt.asIntN ( bits, bigint )
1. Let bits be ? ToIndex(bits). 1. Let bits be ? ToIndex(bits).
features: [BigInt, Symbol, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
assert.throws(RangeError, function() { assert.throws(RangeError, function() {

View File

@ -7,7 +7,7 @@ info: |
BigInt.asIntN ( bits, bigint ) BigInt.asIntN ( bits, bigint )
1. Let bits be ? ToIndex(bits). 1. Let bits be ? ToIndex(bits).
features: [BigInt, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
function err() { function err() {

View File

@ -7,7 +7,7 @@ info: |
BigInt.asIntN ( bits, bigint ) BigInt.asIntN ( bits, bigint )
1. Let bits be ? ToIndex(bits). 1. Let bits be ? ToIndex(bits).
features: [BigInt, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
assert.sameValue(BigInt.asIntN(Object(0), 1n), 0n, "ToPrimitive: unbox object with internal slot"); assert.sameValue(BigInt.asIntN(Object(0), 1n), 0n, "ToPrimitive: unbox object with internal slot");

View File

@ -7,7 +7,7 @@ info: |
BigInt.asUintN ( bits, bigint ) BigInt.asUintN ( bits, bigint )
2. Let bigint ? ToBigInt(bigint). 2. Let bigint ? ToBigInt(bigint).
features: [BigInt, Symbol, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
assert.throws(TypeError, function() { assert.throws(TypeError, function() {

View File

@ -7,7 +7,7 @@ info: |
BigInt.asUintN ( bits, bigint ) BigInt.asUintN ( bits, bigint )
2. Let bigint ? ToBigInt(bigint). 2. Let bigint ? ToBigInt(bigint).
features: [BigInt, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
function err() { function err() {

View File

@ -7,7 +7,7 @@ info: |
BigInt.asUintN ( bits, bigint ) BigInt.asUintN ( bits, bigint )
2. Let bigint ? ToBigInt(bigint). 2. Let bigint ? ToBigInt(bigint).
features: [BigInt, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
assert.sameValue(BigInt.asUintN(2, Object(0n)), 0n, "ToPrimitive: unbox object with internal slot"); assert.sameValue(BigInt.asUintN(2, Object(0n)), 0n, "ToPrimitive: unbox object with internal slot");

View File

@ -7,7 +7,7 @@ info: |
BigInt.asUintN ( bits, bigint ) BigInt.asUintN ( bits, bigint )
1. Let bits be ? ToIndex(bits). 1. Let bits be ? ToIndex(bits).
features: [BigInt, Symbol, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
assert.throws(RangeError, function() { assert.throws(RangeError, function() {

View File

@ -7,7 +7,7 @@ info: |
BigInt.asUintN ( bits, bigint ) BigInt.asUintN ( bits, bigint )
1. Let bits be ? ToIndex(bits). 1. Let bits be ? ToIndex(bits).
features: [BigInt, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
function err() { function err() {

View File

@ -7,7 +7,7 @@ info: |
BigInt.asUintN ( bits, bigint ) BigInt.asUintN ( bits, bigint )
1. Let bits be ? ToIndex(bits). 1. Let bits be ? ToIndex(bits).
features: [BigInt, Symbol.toPrimitive, computed-property-names] features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
---*/ ---*/
assert.sameValue(BigInt.asUintN(Object(0), 1n), 0n, "ToPrimitive: unbox object with internal slot"); assert.sameValue(BigInt.asUintN(Object(0), 1n), 0n, "ToPrimitive: unbox object with internal slot");

View File

@ -5,9 +5,17 @@
description: Empty String should in BigInt should result into 0n description: Empty String should in BigInt should result into 0n
esid: sec-string-to-bigint esid: sec-string-to-bigint
info: | info: |
Apply the algorithm in 3.1.3.1 with the following changes: ToBigInt ( argument )
EDITOR'S NOTE StringToBigInt("") is 0n according to the logic in 3.1.3.1. String:
Let n be StringToBigInt(prim).
If n is NaN, throw a SyntaxError exception.
Return n.
StringToBigInt ( argument )
Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents.
features: [BigInt] features: [BigInt]
---*/ ---*/

View File

@ -5,10 +5,17 @@
description: String should be parsed to BigInt according StringToBigInt description: String should be parsed to BigInt according StringToBigInt
esid: sec-string-to-bigint esid: sec-string-to-bigint
info: | info: |
Apply the algorithm in 3.1.3.1 with the following changes: ToBigInt ( argument )
- Replace the StrUnsignedDecimalLiteral production with DecimalDigits String:
to not allow decimal points or exponents.
Let n be StringToBigInt(prim).
If n is NaN, throw a SyntaxError exception.
Return n.
StringToBigInt ( argument )
Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents.
features: [BigInt] features: [BigInt]
---*/ ---*/

View File

@ -5,10 +5,17 @@
description: String should be parsed to BigInt according StringToBigInt description: String should be parsed to BigInt according StringToBigInt
esid: sec-string-to-bigint esid: sec-string-to-bigint
info: | info: |
Apply the algorithm in 3.1.3.1 with the following changes: ToBigInt ( argument )
- Replace the StrUnsignedDecimalLiteral production with DecimalDigits String:
to not allow decimal points or exponents.
Let n be StringToBigInt(prim).
If n is NaN, throw a SyntaxError exception.
Return n.
StringToBigInt ( argument )
Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents.
features: [BigInt] features: [BigInt]
---*/ ---*/

View File

@ -5,10 +5,17 @@
description: Hexdecimal prefixed String should be parsed to BigInt according StringToBigInt description: Hexdecimal prefixed String should be parsed to BigInt according StringToBigInt
esid: sec-string-to-bigint esid: sec-string-to-bigint
info: | info: |
Apply the algorithm in 3.1.3.1 with the following changes: ToBigInt ( argument )
- Replace the StrUnsignedDecimalLiteral production with DecimalDigits String:
to not allow decimal points or exponents.
Let n be StringToBigInt(prim).
If n is NaN, throw a SyntaxError exception.
Return n.
StringToBigInt ( argument )
Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents.
features: [BigInt] features: [BigInt]
---*/ ---*/

View File

@ -5,10 +5,17 @@
description: Octal prefixed String should be parsed to BigInt according StringToBigInt description: Octal prefixed String should be parsed to BigInt according StringToBigInt
esid: sec-string-to-bigint esid: sec-string-to-bigint
info: | info: |
Apply the algorithm in 3.1.3.1 with the following changes: ToBigInt ( argument )
- Replace the StrUnsignedDecimalLiteral production with DecimalDigits String:
to not allow decimal points or exponents.
Let n be StringToBigInt(prim).
If n is NaN, throw a SyntaxError exception.
Return n.
StringToBigInt ( argument )
Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents.
features: [BigInt] features: [BigInt]
---*/ ---*/

View File

@ -5,10 +5,17 @@
description: Invalid String into BigInt constructor should throw SyntaxError description: Invalid String into BigInt constructor should throw SyntaxError
esid: sec-string-to-bigint esid: sec-string-to-bigint
info: | info: |
Apply the algorithm in 3.1.3.1 with the following changes: ToBigInt ( argument )
- Replace the StrUnsignedDecimalLiteral production with DecimalDigits String:
to not allow decimal points or exponents.
Let n be StringToBigInt(prim).
If n is NaN, throw a SyntaxError exception.
Return n.
StringToBigInt ( argument )
Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents.
features: [BigInt] features: [BigInt]
---*/ ---*/

View File

@ -3,7 +3,7 @@
/*--- /*---
description: BigInt constructor called with integer argument description: BigInt constructor called with integer argument
esid: sec-bigint-constructor esid: sec-bigint-constructor-number-value
info: | info: |
BigInt ( value ) BigInt ( value )
@ -17,15 +17,20 @@ info: |
features: [BigInt] features: [BigInt]
---*/ ---*/
assert.sameValue(BigInt(Number.MAX_SAFE_INTEGER), 9007199254740991n); assert.sameValue(
BigInt(Number.MAX_SAFE_INTEGER), 9007199254740991n,
"BigInt(Number.MAX_SAFE_INTEGER) === 9007199254740991n"
);
assert.sameValue(BigInt(-Number.MAX_SAFE_INTEGER), -9007199254740991n); assert.sameValue(
BigInt(-Number.MAX_SAFE_INTEGER), -9007199254740991n,
"BigInt(-Number.MAX_SAFE_INTEGER) === -9007199254740991n"
);
var pos = Math.pow(2, 53); assert.throws(RangeError, function() {
var neg = -pos; BigInt(Number.MAX_SAFE_INTEGER + 1);
}, "BigInt(Number.MAX_SAFE_INTEGER + 1) throws RangeError");
assert.sameValue(BigInt(pos), 9007199254740992n, assert.throws(RangeError, function() {
"BigInt(2**53) === 9007199254740992n"); BigInt(-Number.MAX_SAFE_INTEGER - 1);
}, "BigInt(-Number.MAX_SAFE_INTEGER - 1) throws RangeError");
assert.sameValue(BigInt(neg), -9007199254740992n,
"BigInt(2**53) === -9007199254740992n");

View File

@ -2,13 +2,21 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: Tariling/Leading spaces should be ignored in BigInt constructor should description: Trailing/Leading spaces should be ignored in BigInt constructor
esid: sec-string-to-bigint esid: sec-string-to-bigint
info: | info: |
Apply the algorithm in 3.1.3.1 with the following changes: ToBigInt ( argument )
String:
Let n be StringToBigInt(prim).
If n is NaN, throw a SyntaxError exception.
Return n.
StringToBigInt ( argument )
Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents.
- Replace the StrUnsignedDecimalLiteral production with DecimalDigits
to not allow decimal points or exponents.
features: [BigInt] features: [BigInt]
---*/ ---*/

View File

@ -11,7 +11,7 @@ info: |
This property has the attributes { [[Writable]]: false, [[Enumerable]]: This property has the attributes { [[Writable]]: false, [[Enumerable]]:
false, [[Configurable]]: true }. false, [[Configurable]]: true }.
includes: [propertyHelper.js] includes: [propertyHelper.js]
features: [Symbol.toStringTag, BigInt, Symbol] features: [BigInt, Symbol, Symbol.toStringTag]
---*/ ---*/
verifyProperty(BigInt.prototype, Symbol.toStringTag, { verifyProperty(BigInt.prototype, Symbol.toStringTag, {

View File

@ -16,7 +16,7 @@ info: |
2. If Type(value) is Object and value has a [[BigIntData]] internal slot, then 2. If Type(value) is Object and value has a [[BigIntData]] internal slot, then
... ...
3. Throw a TypeError exception. 3. Throw a TypeError exception.
features: [BigInt, Symbol.toPrimitive] features: [BigInt, Symbol, Symbol.toPrimitive]
---*/ ---*/
var toString = BigInt.prototype.toString; var toString = BigInt.prototype.toString;

View File

@ -2,7 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
description: Throws exception in BigIntConstructor if valueOf/toString does that description: Throws exception in BigIntConstructor if toString throws
esid: sec-bigint-constructor-number-value esid: sec-bigint-constructor-number-value
info: | info: |
1. If NewTarget is not undefined, throw a TypeError exception. 1. If NewTarget is not undefined, throw a TypeError exception.
@ -12,14 +12,6 @@ info: |
features: [BigInt] features: [BigInt]
---*/ ---*/
assert.throws(Test262Error, function() {
BigInt({
valueOf: function() {
throw new Test262Error();
}
});
});
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
BigInt({ BigInt({
toString: function() { toString: function() {

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Caio Lima. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Throws exception in BigIntConstructor if valueOf throws
esid: sec-bigint-constructor-number-value
info: |
1. If NewTarget is not undefined, throw a TypeError exception.
2. Let prim be ? ToPrimitive(value, hint Number).
3. If Type(prim) is Number, return ? NumberToBigInt(prim).
4. Otherwise, return ? ToBigInt(value).
features: [BigInt]
---*/
assert.throws(Test262Error, function() {
BigInt({
valueOf: function() {
throw new Test262Error();
}
});
});