From cd6305155b9419d4e1e5caac42fe5820ff82eae9 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Wed, 18 Apr 2018 16:56:06 -0400 Subject: [PATCH] BigInt: additional info frontmatter. Validated features (#1518) --- .../BigInt/asIntN/bigint-tobigint-errors.js | 2 +- .../asIntN/bigint-tobigint-toprimitive.js | 2 +- .../asIntN/bigint-tobigint-wrapped-values.js | 2 +- .../BigInt/asIntN/bits-toindex-errors.js | 2 +- .../BigInt/asIntN/bits-toindex-toprimitive.js | 2 +- .../asIntN/bits-toindex-wrapped-values.js | 2 +- .../BigInt/asUintN/bigint-tobigint-errors.js | 2 +- .../asUintN/bigint-tobigint-toprimitive.js | 2 +- .../asUintN/bigint-tobigint-wrapped-values.js | 2 +- .../BigInt/asUintN/bits-toindex-errors.js | 2 +- .../asUintN/bits-toindex-toprimitive.js | 2 +- .../asUintN/bits-toindex-wrapped-values.js | 2 +- .../BigInt/constructor-empty-string.js | 12 +++++++-- .../BigInt/constructor-from-binary-string.js | 13 +++++++--- .../BigInt/constructor-from-decimal-string.js | 13 +++++++--- .../BigInt/constructor-from-hex-string.js | 13 +++++++--- .../BigInt/constructor-from-octal-string.js | 13 +++++++--- .../constructor-from-string-syntax-errors.js | 13 +++++++--- test/built-ins/BigInt/constructor-integer.js | 25 +++++++++++-------- .../constructor-trailing-leading-spaces.js | 16 +++++++++--- .../BigInt/prototype/Symbol.toStringTag.js | 2 +- .../thisbigintvalue-not-valid-throws.js | 2 +- ...{value-of-throws.js => tostring-throws.js} | 10 +------- test/built-ins/BigInt/valueof-throws.js | 21 ++++++++++++++++ 24 files changed, 123 insertions(+), 54 deletions(-) rename test/built-ins/BigInt/{value-of-throws.js => tostring-throws.js} (72%) create mode 100644 test/built-ins/BigInt/valueof-throws.js diff --git a/test/built-ins/BigInt/asIntN/bigint-tobigint-errors.js b/test/built-ins/BigInt/asIntN/bigint-tobigint-errors.js index b1e2d3f7b9..950cda9f6e 100644 --- a/test/built-ins/BigInt/asIntN/bigint-tobigint-errors.js +++ b/test/built-ins/BigInt/asIntN/bigint-tobigint-errors.js @@ -7,7 +7,7 @@ info: | BigInt.asIntN ( bits, 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() { diff --git a/test/built-ins/BigInt/asIntN/bigint-tobigint-toprimitive.js b/test/built-ins/BigInt/asIntN/bigint-tobigint-toprimitive.js index e2663a00b6..fe0a702faf 100644 --- a/test/built-ins/BigInt/asIntN/bigint-tobigint-toprimitive.js +++ b/test/built-ins/BigInt/asIntN/bigint-tobigint-toprimitive.js @@ -7,7 +7,7 @@ info: | BigInt.asIntN ( bits, bigint ) 2. Let bigint ? ToBigInt(bigint). -features: [BigInt, Symbol.toPrimitive, computed-property-names] +features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive] ---*/ function err() { diff --git a/test/built-ins/BigInt/asIntN/bigint-tobigint-wrapped-values.js b/test/built-ins/BigInt/asIntN/bigint-tobigint-wrapped-values.js index 2ee3a6c6bb..5b2a3956c3 100644 --- a/test/built-ins/BigInt/asIntN/bigint-tobigint-wrapped-values.js +++ b/test/built-ins/BigInt/asIntN/bigint-tobigint-wrapped-values.js @@ -7,7 +7,7 @@ info: | BigInt.asIntN ( bits, 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"); diff --git a/test/built-ins/BigInt/asIntN/bits-toindex-errors.js b/test/built-ins/BigInt/asIntN/bits-toindex-errors.js index 892c480175..9f2fabb1c1 100644 --- a/test/built-ins/BigInt/asIntN/bits-toindex-errors.js +++ b/test/built-ins/BigInt/asIntN/bits-toindex-errors.js @@ -7,7 +7,7 @@ info: | BigInt.asIntN ( bits, bigint ) 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() { diff --git a/test/built-ins/BigInt/asIntN/bits-toindex-toprimitive.js b/test/built-ins/BigInt/asIntN/bits-toindex-toprimitive.js index c6b874a84e..10ffd610f8 100644 --- a/test/built-ins/BigInt/asIntN/bits-toindex-toprimitive.js +++ b/test/built-ins/BigInt/asIntN/bits-toindex-toprimitive.js @@ -7,7 +7,7 @@ info: | BigInt.asIntN ( bits, bigint ) 1. Let bits be ? ToIndex(bits). -features: [BigInt, Symbol.toPrimitive, computed-property-names] +features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive] ---*/ function err() { diff --git a/test/built-ins/BigInt/asIntN/bits-toindex-wrapped-values.js b/test/built-ins/BigInt/asIntN/bits-toindex-wrapped-values.js index cb9a5832a1..94e5635e06 100644 --- a/test/built-ins/BigInt/asIntN/bits-toindex-wrapped-values.js +++ b/test/built-ins/BigInt/asIntN/bits-toindex-wrapped-values.js @@ -7,7 +7,7 @@ info: | BigInt.asIntN ( bits, bigint ) 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"); diff --git a/test/built-ins/BigInt/asUintN/bigint-tobigint-errors.js b/test/built-ins/BigInt/asUintN/bigint-tobigint-errors.js index 3df6cf7144..924e3decb1 100644 --- a/test/built-ins/BigInt/asUintN/bigint-tobigint-errors.js +++ b/test/built-ins/BigInt/asUintN/bigint-tobigint-errors.js @@ -7,7 +7,7 @@ info: | BigInt.asUintN ( bits, 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() { diff --git a/test/built-ins/BigInt/asUintN/bigint-tobigint-toprimitive.js b/test/built-ins/BigInt/asUintN/bigint-tobigint-toprimitive.js index 15bfa47759..1aff2080c3 100644 --- a/test/built-ins/BigInt/asUintN/bigint-tobigint-toprimitive.js +++ b/test/built-ins/BigInt/asUintN/bigint-tobigint-toprimitive.js @@ -7,7 +7,7 @@ info: | BigInt.asUintN ( bits, bigint ) 2. Let bigint ? ToBigInt(bigint). -features: [BigInt, Symbol.toPrimitive, computed-property-names] +features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive] ---*/ function err() { diff --git a/test/built-ins/BigInt/asUintN/bigint-tobigint-wrapped-values.js b/test/built-ins/BigInt/asUintN/bigint-tobigint-wrapped-values.js index 49741b9397..3362b284d9 100644 --- a/test/built-ins/BigInt/asUintN/bigint-tobigint-wrapped-values.js +++ b/test/built-ins/BigInt/asUintN/bigint-tobigint-wrapped-values.js @@ -7,7 +7,7 @@ info: | BigInt.asUintN ( bits, 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"); diff --git a/test/built-ins/BigInt/asUintN/bits-toindex-errors.js b/test/built-ins/BigInt/asUintN/bits-toindex-errors.js index 9b42b295d1..3967dab25d 100644 --- a/test/built-ins/BigInt/asUintN/bits-toindex-errors.js +++ b/test/built-ins/BigInt/asUintN/bits-toindex-errors.js @@ -7,7 +7,7 @@ info: | BigInt.asUintN ( bits, bigint ) 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() { diff --git a/test/built-ins/BigInt/asUintN/bits-toindex-toprimitive.js b/test/built-ins/BigInt/asUintN/bits-toindex-toprimitive.js index 68a0421a90..4933da2fbf 100644 --- a/test/built-ins/BigInt/asUintN/bits-toindex-toprimitive.js +++ b/test/built-ins/BigInt/asUintN/bits-toindex-toprimitive.js @@ -7,7 +7,7 @@ info: | BigInt.asUintN ( bits, bigint ) 1. Let bits be ? ToIndex(bits). -features: [BigInt, Symbol.toPrimitive, computed-property-names] +features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive] ---*/ function err() { diff --git a/test/built-ins/BigInt/asUintN/bits-toindex-wrapped-values.js b/test/built-ins/BigInt/asUintN/bits-toindex-wrapped-values.js index 3b78835cd0..ac754ee4e7 100644 --- a/test/built-ins/BigInt/asUintN/bits-toindex-wrapped-values.js +++ b/test/built-ins/BigInt/asUintN/bits-toindex-wrapped-values.js @@ -7,7 +7,7 @@ info: | BigInt.asUintN ( bits, bigint ) 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"); diff --git a/test/built-ins/BigInt/constructor-empty-string.js b/test/built-ins/BigInt/constructor-empty-string.js index e8b2fb52b4..5eb5def02c 100644 --- a/test/built-ins/BigInt/constructor-empty-string.js +++ b/test/built-ins/BigInt/constructor-empty-string.js @@ -5,9 +5,17 @@ description: Empty String should in BigInt should result into 0n esid: sec-string-to-bigint 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] ---*/ diff --git a/test/built-ins/BigInt/constructor-from-binary-string.js b/test/built-ins/BigInt/constructor-from-binary-string.js index 35cfda0acb..1b675b4727 100644 --- a/test/built-ins/BigInt/constructor-from-binary-string.js +++ b/test/built-ins/BigInt/constructor-from-binary-string.js @@ -5,10 +5,17 @@ description: String should be parsed to BigInt according StringToBigInt esid: sec-string-to-bigint info: | - Apply the algorithm in 3.1.3.1 with the following changes: + ToBigInt ( argument ) - - Replace the StrUnsignedDecimalLiteral production with DecimalDigits - to not allow decimal points or exponents. + 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] ---*/ diff --git a/test/built-ins/BigInt/constructor-from-decimal-string.js b/test/built-ins/BigInt/constructor-from-decimal-string.js index c732b7f7aa..ecb128feed 100644 --- a/test/built-ins/BigInt/constructor-from-decimal-string.js +++ b/test/built-ins/BigInt/constructor-from-decimal-string.js @@ -5,10 +5,17 @@ description: String should be parsed to BigInt according StringToBigInt esid: sec-string-to-bigint info: | - Apply the algorithm in 3.1.3.1 with the following changes: + ToBigInt ( argument ) - - Replace the StrUnsignedDecimalLiteral production with DecimalDigits - to not allow decimal points or exponents. + 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] ---*/ diff --git a/test/built-ins/BigInt/constructor-from-hex-string.js b/test/built-ins/BigInt/constructor-from-hex-string.js index f26b9d2698..1841559d2a 100644 --- a/test/built-ins/BigInt/constructor-from-hex-string.js +++ b/test/built-ins/BigInt/constructor-from-hex-string.js @@ -5,10 +5,17 @@ description: Hexdecimal prefixed String should be parsed to BigInt according StringToBigInt esid: sec-string-to-bigint info: | - Apply the algorithm in 3.1.3.1 with the following changes: + ToBigInt ( argument ) - - Replace the StrUnsignedDecimalLiteral production with DecimalDigits - to not allow decimal points or exponents. + 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] ---*/ diff --git a/test/built-ins/BigInt/constructor-from-octal-string.js b/test/built-ins/BigInt/constructor-from-octal-string.js index 59d18c64d1..f4093fa96a 100644 --- a/test/built-ins/BigInt/constructor-from-octal-string.js +++ b/test/built-ins/BigInt/constructor-from-octal-string.js @@ -5,10 +5,17 @@ description: Octal prefixed String should be parsed to BigInt according StringToBigInt esid: sec-string-to-bigint info: | - Apply the algorithm in 3.1.3.1 with the following changes: + ToBigInt ( argument ) - - Replace the StrUnsignedDecimalLiteral production with DecimalDigits - to not allow decimal points or exponents. + 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] ---*/ diff --git a/test/built-ins/BigInt/constructor-from-string-syntax-errors.js b/test/built-ins/BigInt/constructor-from-string-syntax-errors.js index 6bdd6f3cbc..0e5defa0d9 100644 --- a/test/built-ins/BigInt/constructor-from-string-syntax-errors.js +++ b/test/built-ins/BigInt/constructor-from-string-syntax-errors.js @@ -5,10 +5,17 @@ description: Invalid String into BigInt constructor should throw SyntaxError esid: sec-string-to-bigint info: | - Apply the algorithm in 3.1.3.1 with the following changes: + ToBigInt ( argument ) - - Replace the StrUnsignedDecimalLiteral production with DecimalDigits - to not allow decimal points or exponents. + 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] ---*/ diff --git a/test/built-ins/BigInt/constructor-integer.js b/test/built-ins/BigInt/constructor-integer.js index 36e37e60e6..b416e43ecc 100644 --- a/test/built-ins/BigInt/constructor-integer.js +++ b/test/built-ins/BigInt/constructor-integer.js @@ -3,7 +3,7 @@ /*--- description: BigInt constructor called with integer argument -esid: sec-bigint-constructor +esid: sec-bigint-constructor-number-value info: | BigInt ( value ) @@ -17,15 +17,20 @@ info: | 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); -var neg = -pos; +assert.throws(RangeError, function() { + BigInt(Number.MAX_SAFE_INTEGER + 1); +}, "BigInt(Number.MAX_SAFE_INTEGER + 1) throws RangeError"); -assert.sameValue(BigInt(pos), 9007199254740992n, - "BigInt(2**53) === 9007199254740992n"); - -assert.sameValue(BigInt(neg), -9007199254740992n, - "BigInt(2**53) === -9007199254740992n"); +assert.throws(RangeError, function() { + BigInt(-Number.MAX_SAFE_INTEGER - 1); +}, "BigInt(-Number.MAX_SAFE_INTEGER - 1) throws RangeError"); diff --git a/test/built-ins/BigInt/constructor-trailing-leading-spaces.js b/test/built-ins/BigInt/constructor-trailing-leading-spaces.js index 8db1a76ea6..9ffdc45f46 100644 --- a/test/built-ins/BigInt/constructor-trailing-leading-spaces.js +++ b/test/built-ins/BigInt/constructor-trailing-leading-spaces.js @@ -2,13 +2,21 @@ // 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 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] ---*/ diff --git a/test/built-ins/BigInt/prototype/Symbol.toStringTag.js b/test/built-ins/BigInt/prototype/Symbol.toStringTag.js index ab55f21253..a64ff70bf2 100644 --- a/test/built-ins/BigInt/prototype/Symbol.toStringTag.js +++ b/test/built-ins/BigInt/prototype/Symbol.toStringTag.js @@ -11,7 +11,7 @@ info: | This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] -features: [Symbol.toStringTag, BigInt, Symbol] +features: [BigInt, Symbol, Symbol.toStringTag] ---*/ verifyProperty(BigInt.prototype, Symbol.toStringTag, { diff --git a/test/built-ins/BigInt/prototype/toString/thisbigintvalue-not-valid-throws.js b/test/built-ins/BigInt/prototype/toString/thisbigintvalue-not-valid-throws.js index 92eee1c683..1e4a1bd6b2 100644 --- a/test/built-ins/BigInt/prototype/toString/thisbigintvalue-not-valid-throws.js +++ b/test/built-ins/BigInt/prototype/toString/thisbigintvalue-not-valid-throws.js @@ -16,7 +16,7 @@ info: | 2. If Type(value) is Object and value has a [[BigIntData]] internal slot, then ... 3. Throw a TypeError exception. -features: [BigInt, Symbol.toPrimitive] +features: [BigInt, Symbol, Symbol.toPrimitive] ---*/ var toString = BigInt.prototype.toString; diff --git a/test/built-ins/BigInt/value-of-throws.js b/test/built-ins/BigInt/tostring-throws.js similarity index 72% rename from test/built-ins/BigInt/value-of-throws.js rename to test/built-ins/BigInt/tostring-throws.js index 671a9b94ca..031a85e1ea 100644 --- a/test/built-ins/BigInt/value-of-throws.js +++ b/test/built-ins/BigInt/tostring-throws.js @@ -2,7 +2,7 @@ // 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 info: | 1. If NewTarget is not undefined, throw a TypeError exception. @@ -12,14 +12,6 @@ info: | features: [BigInt] ---*/ -assert.throws(Test262Error, function() { - BigInt({ - valueOf: function() { - throw new Test262Error(); - } - }); -}); - assert.throws(Test262Error, function() { BigInt({ toString: function() { diff --git a/test/built-ins/BigInt/valueof-throws.js b/test/built-ins/BigInt/valueof-throws.js new file mode 100644 index 0000000000..7e3cef1f39 --- /dev/null +++ b/test/built-ins/BigInt/valueof-throws.js @@ -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(); + } + }); +});