diff --git a/test/built-ins/BigInt/asIntN.js b/test/built-ins/BigInt/asIntN.js new file mode 100644 index 00000000000..75338b420c6 --- /dev/null +++ b/test/built-ins/BigInt/asIntN.js @@ -0,0 +1,10 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt.asIntN +esid: pending +features: [BigInt] +---*/ + +assert.sameValue(BigInt.asIntN(1, 3n), -1n); diff --git a/test/built-ins/BigInt/asUintN.js b/test/built-ins/BigInt/asUintN.js new file mode 100644 index 00000000000..21a59d5d960 --- /dev/null +++ b/test/built-ins/BigInt/asUintN.js @@ -0,0 +1,10 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt.asUintN +esid: pending +features: [BigInt] +---*/ + +assert.sameValue(BigInt.asUintN(1, 3n), 1n); diff --git a/test/built-ins/BigInt/constructor-prototype.js b/test/built-ins/BigInt/constructor-prototype.js new file mode 100644 index 00000000000..6bc52c8839c --- /dev/null +++ b/test/built-ins/BigInt/constructor-prototype.js @@ -0,0 +1,10 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Prototype of BigInt constructor +esid: pending +features: [BigInt] +---*/ + +assert.sameValue(Object.getPrototypeOf(BigInt), Function.prototype); diff --git a/test/built-ins/BigInt/constructor.js b/test/built-ins/BigInt/constructor.js new file mode 100644 index 00000000000..7e6fc788bf1 --- /dev/null +++ b/test/built-ins/BigInt/constructor.js @@ -0,0 +1,16 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt constructor +esid: pending +features: [BigInt] +---*/ + +assert.throws(TypeError, () => new BigInt(0)); +for (let x of [NaN, Infinity, 0.5, 2**53]) { + assert.throws(RangeError, () => BigInt(x)); + assert.throws(RangeError, () => BigInt(-x)); +} +assert.sameValue(BigInt(9007199254740991), 9007199254740991n); +assert.sameValue(BigInt(-9007199254740991), -9007199254740991n); diff --git a/test/built-ins/BigInt/parseInt.js b/test/built-ins/BigInt/parseInt.js new file mode 100644 index 00000000000..e41681d66c7 --- /dev/null +++ b/test/built-ins/BigInt/parseInt.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. + +/*--- +description: BigInt string parsing +esid: pending +features: [BigInt] +---*/ + +assert.throws(SyntaxError, () => BigInt.parseInt("")); +assert.throws(SyntaxError, () => BigInt.parseInt("@")); +assert.throws(SyntaxError, () => BigInt.parseInt("1", 1)); +assert.throws(SyntaxError, () => BigInt.parseInt("1", 37)); +assert.sameValue(BigInt.parseInt("0xf", 0), 0xfn); +assert.sameValue(BigInt.parseInt("-0"), 0n); +assert.sameValue(BigInt.parseInt(" 0@"), 0n); +assert.sameValue(BigInt.parseInt("kf12oikf12oikf12oi", 36), + 5849853453554480289462428370n); diff --git a/test/built-ins/BigInt/prototype/attributes.js b/test/built-ins/BigInt/prototype/attributes.js new file mode 100644 index 00000000000..dab18f374db --- /dev/null +++ b/test/built-ins/BigInt/prototype/attributes.js @@ -0,0 +1,13 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt prototype object attributes +esid: pending +features: [BigInt] +includes: [propertyHelper.js] +---*/ + +verifyNotWritable(BigInt, "prototype"); +verifyNotEnumerable(BigInt, "prototype"); +verifyNotConfigurable(BigInt, "prototype"); diff --git a/test/built-ins/BigInt/prototype/prototype-is-object.js b/test/built-ins/BigInt/prototype/prototype-is-object.js new file mode 100644 index 00000000000..83dddf1474d --- /dev/null +++ b/test/built-ins/BigInt/prototype/prototype-is-object.js @@ -0,0 +1,10 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Prototype of BigInt.prototype +esid: pending +features: [BigInt] +---*/ + +assert.sameValue(Object.getPrototypeOf(BigInt.prototype), Object.prototype); diff --git a/test/built-ins/BigInt/prototype/toString.js b/test/built-ins/BigInt/prototype/toString.js new file mode 100644 index 00000000000..88586dbaba6 --- /dev/null +++ b/test/built-ins/BigInt/prototype/toString.js @@ -0,0 +1,61 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt toString method +esid: pending +features: [BigInt] +---*/ + +const n = 1234567890n; +const strs = { + 2: "1001001100101100000001011010010", + 3: "10012001001112202200", + 4: "1021211200023102", + 5: "10012022133030", + 6: "322301024030", + 7: "42410440203", + 8: "11145401322", + 9: "3161045680", + 10: "1234567890", + 11: "583977146", + 12: "2a5555016", + 13: "168a0865a", + 14: "b9d6b5aa", + 15: "735b7d60", + 16: "499602d2", + 17: "30288g3a", + 18: "20568ad0", + 19: "174b57c7", + 20: "j5g0jea", + 21: "e8605e3", + 22: "ajc3e26", + 23: "87ifcgi", + 24: "6b1230i", + 25: "51ac8ff", + 26: "3pnfhma", + 27: "3511eki", + 28: "2fkfbqa", + 29: "225ep2g", + 30: "1ko4m30", + 31: "1c3ou0k", + 32: "14pc0mi", + 33: "vi0m56", + 34: "r5spaa", + 35: "nhokia", + 36: "kf12oi" +}; + +assert.throws(TypeError, () => BigInt.prototype.toString.call(null)); +assert.sameValue(n.toString(), n.toString(10)); +assert.sameValue(n.toString(undefined), n.toString(10)); +for (let radix of [1, 37, NaN, 0, Infinity]) { + assert.throws(RangeError, () => n.toString(radix)); + assert.throws(RangeError, () => n.toString(-radix)); +} +for (let i = 2; i < 37; i++) { + for (let x of [n, Object(n)]) { + assert.sameValue(x.toString(i), strs[i]); + assert.sameValue(x.toString(i + 0.5), strs[i]); + } +} diff --git a/test/built-ins/BigInt/prototype/valueOf.js b/test/built-ins/BigInt/prototype/valueOf.js new file mode 100644 index 00000000000..87f7cdd657d --- /dev/null +++ b/test/built-ins/BigInt/prototype/valueOf.js @@ -0,0 +1,12 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt valueOf method and thisBigIntValue operation +esid: pending +features: [BigInt] +---*/ + +assert.sameValue(BigInt.prototype.valueOf.call(0n), 0n); +assert.sameValue(BigInt.prototype.valueOf.call(Object(0n)), 0n); +assert.throws(TypeError, () => BigInt.prototype.valueOf.call(null)); diff --git a/test/built-ins/JSON/stringify/bigint.js b/test/built-ins/JSON/stringify/bigint.js new file mode 100644 index 00000000000..7aa38a3220f --- /dev/null +++ b/test/built-ins/JSON/stringify/bigint.js @@ -0,0 +1,10 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: JSON serialization of BigInt values +esid: pending +features: [BigInt] +---*/ + +assert.throws(TypeError, () => JSON.stringify(0n)); diff --git a/test/built-ins/Number/bigint-conversion.js b/test/built-ins/Number/bigint-conversion.js new file mode 100644 index 00000000000..12fe032295c --- /dev/null +++ b/test/built-ins/Number/bigint-conversion.js @@ -0,0 +1,11 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt to Number conversion +esid: pending +features: [BigInt] +---*/ + +assert.sameValue(Number(0n), 0); +assert.sameValue(+(new Number(0n)), +(new Number(0))); diff --git a/test/built-ins/Object/bigint.js b/test/built-ins/Object/bigint.js new file mode 100644 index 00000000000..810247da66c --- /dev/null +++ b/test/built-ins/Object/bigint.js @@ -0,0 +1,11 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Conversion of BigInt values to Objects +esid: pending +features: [BigInt] +---*/ + +assert(Object(0n) instanceof BigInt); +assert.sameValue(Object(0n).valueOf(), 0n); diff --git a/test/built-ins/Object/setPrototypeOf/bigint.js b/test/built-ins/Object/setPrototypeOf/bigint.js new file mode 100644 index 00000000000..63545034f82 --- /dev/null +++ b/test/built-ins/Object/setPrototypeOf/bigint.js @@ -0,0 +1,16 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: RequireObjectCoercible for BigInt values +esid: pending +features: [BigInt] +---*/ + +try { + let {} = 0n; +} catch (e) { + $ERROR('Expected RequireObjectCoercible to succeed for BigInt values'); +} + +assert.sameValue(Object.setPrototypeOf(0n, null), 0n); diff --git a/test/language/expressions/addition/bigint-to-string.js b/test/language/expressions/addition/bigint-to-string.js new file mode 100644 index 00000000000..f8f42ae7183 --- /dev/null +++ b/test/language/expressions/addition/bigint-to-string.js @@ -0,0 +1,16 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ToString for BigInt values +esid: pending +features: [BigInt] +---*/ + +const ToString = (x) => x + ""; + +assert.sameValue(ToString(-1n), "-1"); +assert.sameValue(ToString(0n), "0"); +assert.sameValue(ToString(1n), "1"); +assert.sameValue(ToString(1234567890n), "1234567890"); +assert.sameValue(ToString(-1234567890n), "-1234567890"); diff --git a/test/language/expressions/division/bigint.js b/test/language/expressions/division/bigint.js new file mode 100644 index 00000000000..2fa351c79f0 --- /dev/null +++ b/test/language/expressions/division/bigint.js @@ -0,0 +1,10 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt division +esid: pending +features: [BigInt] +---*/ + +assert.throws(RangeError, () => 1n / 0n); diff --git a/test/language/expressions/does-not-equals/bigint.js b/test/language/expressions/does-not-equals/bigint.js new file mode 100644 index 00000000000..40d44ab9600 --- /dev/null +++ b/test/language/expressions/does-not-equals/bigint.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. + +/*--- +description: BigInt equality +esid: pending +features: [BigInt] +---*/ + +assert("x" != 0n); +assert(0n != "x"); +assert(true != 0n); +assert(false != 1n); +assert(0n != true); +assert(1n != false); +assert(0n != NaN); +assert(0n != Infinity); +assert(0n != -Infinity); diff --git a/test/language/expressions/equals/bigint.js b/test/language/expressions/equals/bigint.js new file mode 100644 index 00000000000..a70c2397d5b --- /dev/null +++ b/test/language/expressions/equals/bigint.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. + +/*--- +description: BigInt equality +esid: pending +features: [BigInt] +---*/ + +assert("" == 0n); +assert("0" == 0n); +assert(0n == ""); +assert(0n == "0"); +assert(true == 1n); +assert(false == 0n); +assert(1n == true); +assert(0n == false); +assert(0n == 0); +assert(0 == 0n); diff --git a/test/language/expressions/exponentiation/bigint.js b/test/language/expressions/exponentiation/bigint.js new file mode 100644 index 00000000000..86561acca48 --- /dev/null +++ b/test/language/expressions/exponentiation/bigint.js @@ -0,0 +1,11 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt exponentiation +esid: pending +features: [BigInt] +---*/ + +assert.throws(RangeError, () => 1n ** -1n); +assert.sameValue(0n ** 0n, 1n); diff --git a/test/language/expressions/greater-than-or-equal/bigint.js b/test/language/expressions/greater-than-or-equal/bigint.js new file mode 100644 index 00000000000..3477960b321 --- /dev/null +++ b/test/language/expressions/greater-than-or-equal/bigint.js @@ -0,0 +1,13 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt comparison +esid: pending +features: [BigInt] +---*/ + +assert(1n >= 0); +assert(1 >= 0n); +assert(1n >= 1); +assert(1 >= 1n); diff --git a/test/language/expressions/greater-than/bigint.js b/test/language/expressions/greater-than/bigint.js new file mode 100644 index 00000000000..72b2dacab72 --- /dev/null +++ b/test/language/expressions/greater-than/bigint.js @@ -0,0 +1,11 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt comparison +esid: pending +features: [BigInt] +---*/ + +assert(1 > 0n); +assert(1n > 0); diff --git a/test/language/expressions/less-than-or-equal/bigint.js b/test/language/expressions/less-than-or-equal/bigint.js new file mode 100644 index 00000000000..c096f15f5f0 --- /dev/null +++ b/test/language/expressions/less-than-or-equal/bigint.js @@ -0,0 +1,13 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt comparison +esid: pending +features: [BigInt] +---*/ + +assert(0n <= 1); +assert(0 <= 1n); +assert(1n <= 1); +assert(1 <= 1n); diff --git a/test/language/expressions/less-than/bigint.js b/test/language/expressions/less-than/bigint.js new file mode 100644 index 00000000000..7dc2e4bd0b9 --- /dev/null +++ b/test/language/expressions/less-than/bigint.js @@ -0,0 +1,11 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt comparison +esid: pending +features: [BigInt] +---*/ + +assert(0n < 1); +assert(0 < 1n); diff --git a/test/language/expressions/logical-not/bigint.js b/test/language/expressions/logical-not/bigint.js new file mode 100644 index 00000000000..6d08e146af2 --- /dev/null +++ b/test/language/expressions/logical-not/bigint.js @@ -0,0 +1,11 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Conversion of BigInt values to booleans +esid: pending +features: [BigInt] +---*/ + +assert.sameValue(!!0n, false, "Expected ToBoolean(0n) to be false"); +assert.sameValue(!!1n, true, "Expected ToBoolean(1n) to be true"); diff --git a/test/language/expressions/modulus/bigint.js b/test/language/expressions/modulus/bigint.js new file mode 100644 index 00000000000..5e396b17615 --- /dev/null +++ b/test/language/expressions/modulus/bigint.js @@ -0,0 +1,10 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt modulus +esid: pending +features: [BigInt] +---*/ + +assert.throws(RangeError, () => 1n % 0n); diff --git a/test/language/expressions/unary-plus/bigint.js b/test/language/expressions/unary-plus/bigint.js new file mode 100644 index 00000000000..f62109034d7 --- /dev/null +++ b/test/language/expressions/unary-plus/bigint.js @@ -0,0 +1,10 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Conversion of BigInt values to numbers +esid: pending +features: [BigInt] +---*/ + +assert.throws(TypeError, () => +0n); diff --git a/test/language/literals/bigint/binary-invalid-digit.js b/test/language/literals/bigint/binary-invalid-digit.js new file mode 100644 index 00000000000..a447930a699 --- /dev/null +++ b/test/language/literals/bigint/binary-invalid-digit.js @@ -0,0 +1,13 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Binary BigInt literal containing an invalid digit +esid: pending +features: [BigInt] +negative: + phase: early + type: SyntaxError +---*/ + +0b2n; diff --git a/test/language/literals/bigint/exponent-part.js b/test/language/literals/bigint/exponent-part.js new file mode 100644 index 00000000000..1936d817862 --- /dev/null +++ b/test/language/literals/bigint/exponent-part.js @@ -0,0 +1,13 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: BigInt literal containing an exponent part +esid: pending +features: [BigInt] +negative: + phase: early + type: SyntaxError +---*/ + +0e0n; diff --git a/test/language/literals/bigint/hexadecimal-invalid-digit.js b/test/language/literals/bigint/hexadecimal-invalid-digit.js new file mode 100644 index 00000000000..93b3543e6e0 --- /dev/null +++ b/test/language/literals/bigint/hexadecimal-invalid-digit.js @@ -0,0 +1,13 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Hexadecimal BigInt literal containing an invalid digit +esid: pending +features: [BigInt] +negative: + phase: early + type: SyntaxError +---*/ + +0xgn; diff --git a/test/language/literals/bigint/octal-invalid-digit.js b/test/language/literals/bigint/octal-invalid-digit.js new file mode 100644 index 00000000000..486054fcaf5 --- /dev/null +++ b/test/language/literals/bigint/octal-invalid-digit.js @@ -0,0 +1,13 @@ +// Copyright (C) 2017 Robin Templeton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Octal BigInt literal containing an invalid digit +esid: pending +features: [BigInt] +negative: + phase: early + type: SyntaxError +---*/ + +0o9n;