summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/BigInt/asIntN
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/BigInt/asIntN
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/BigInt/asIntN')
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/arithmetic.js68
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/asIntN.js23
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-errors.js173
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-toprimitive.js168
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-wrapped-values.js64
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint.js51
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-errors.js88
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-toprimitive.js169
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-wrapped-values.js111
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex.js37
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/length.js22
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/name.js22
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/not-a-constructor.js28
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/order-of-steps.js34
-rw-r--r--js/src/tests/test262/built-ins/BigInt/asIntN/shell.js0
16 files changed, 1058 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/arithmetic.js b/js/src/tests/test262/built-ins/BigInt/asIntN/arithmetic.js
new file mode 100644
index 0000000000..e12acd828e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/arithmetic.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-bigint.asintn
+description: BigInt.asIntN arithmetic test cases
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 3. Let mod be a BigInt representing bigint modulo 2**bits.
+ 4. If mod ≥ 2**bits - 1, return mod - 2**bits; otherwise, return mod.
+
+features: [BigInt]
+---*/
+
+assert.sameValue(BigInt.asIntN(0, -2n), 0n);
+assert.sameValue(BigInt.asIntN(0, -1n), 0n);
+assert.sameValue(BigInt.asIntN(0, 0n), 0n);
+assert.sameValue(BigInt.asIntN(0, 1n), 0n);
+assert.sameValue(BigInt.asIntN(0, 2n), 0n);
+
+assert.sameValue(BigInt.asIntN(1, -3n), -1n);
+assert.sameValue(BigInt.asIntN(1, -2n), 0n);
+assert.sameValue(BigInt.asIntN(1, -1n), -1n);
+assert.sameValue(BigInt.asIntN(1, 0n), 0n);
+assert.sameValue(BigInt.asIntN(1, 1n), -1n);
+assert.sameValue(BigInt.asIntN(1, 2n), 0n);
+assert.sameValue(BigInt.asIntN(1, 3n), -1n);
+assert.sameValue(BigInt.asIntN(1, -123456789012345678901n), -1n);
+assert.sameValue(BigInt.asIntN(1, -123456789012345678900n), 0n);
+assert.sameValue(BigInt.asIntN(1, 123456789012345678900n), 0n);
+assert.sameValue(BigInt.asIntN(1, 123456789012345678901n), -1n);
+
+assert.sameValue(BigInt.asIntN(2, -3n), 1n);
+assert.sameValue(BigInt.asIntN(2, -2n), -2n);
+assert.sameValue(BigInt.asIntN(2, -1n), -1n);
+assert.sameValue(BigInt.asIntN(2, 0n), 0n);
+assert.sameValue(BigInt.asIntN(2, 1n), 1n);
+assert.sameValue(BigInt.asIntN(2, 2n), -2n);
+assert.sameValue(BigInt.asIntN(2, 3n), -1n);
+assert.sameValue(BigInt.asIntN(2, -123456789012345678901n), -1n);
+assert.sameValue(BigInt.asIntN(2, -123456789012345678900n), 0n);
+assert.sameValue(BigInt.asIntN(2, 123456789012345678900n), 0n);
+assert.sameValue(BigInt.asIntN(2, 123456789012345678901n), 1n);
+
+assert.sameValue(BigInt.asIntN(8, 0xabn), -0x55n);
+assert.sameValue(BigInt.asIntN(8, 0xabcdn), -0x33n);
+assert.sameValue(BigInt.asIntN(8, 0xabcdef01n), 0x01n);
+assert.sameValue(BigInt.asIntN(8, 0xabcdef0123456789abcdef0123n), 0x23n);
+assert.sameValue(BigInt.asIntN(8, 0xabcdef0123456789abcdef0183n), -0x7dn);
+
+assert.sameValue(BigInt.asIntN(64, 0xabcdef0123456789abcdefn), 0x0123456789abcdefn);
+assert.sameValue(BigInt.asIntN(65, 0xabcdef0123456789abcdefn), -0xfedcba9876543211n);
+
+assert.sameValue(BigInt.asIntN(200,
+ 0xcffffffffffffffffffffffffffffffffffffffffffffffffffn), -0x00000000000000000000000000000000000000000000000001n);
+assert.sameValue(BigInt.asIntN(201,
+ 0xcffffffffffffffffffffffffffffffffffffffffffffffffffn),
+ 0xffffffffffffffffffffffffffffffffffffffffffffffffffn
+);
+
+assert.sameValue(BigInt.asIntN(200,
+ 0xc89e081df68b65fedb32cffea660e55df9605650a603ad5fc54n), -0x761f7e209749a0124cd3001599f1aa2069fa9af59fc52a03acn);
+assert.sameValue(BigInt.asIntN(201,
+ 0xc89e081df68b65fedb32cffea660e55df9605650a603ad5fc54n),
+ 0x89e081df68b65fedb32cffea660e55df9605650a603ad5fc54n
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/asIntN.js b/js/src/tests/test262/built-ins/BigInt/asIntN/asIntN.js
new file mode 100644
index 0000000000..24536e95e1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/asIntN.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-bigint.asintn
+description: BigInt.asIntN property descriptor
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [BigInt]
+---*/
+
+assert.sameValue(typeof BigInt.asIntN, 'function');
+
+verifyProperty(BigInt, "asIntN", {
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-errors.js b/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-errors.js
new file mode 100644
index 0000000000..ec4b9c273f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-errors.js
@@ -0,0 +1,173 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: BigInt.asIntN type coercion for bigint parameter
+esid: sec-bigint.asintn
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 2. Let bigint ? ToBigInt(bigint).
+features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
+---*/
+assert.sameValue(typeof BigInt, 'function');
+assert.sameValue(typeof BigInt.asIntN, 'function');
+
+assert.throws(TypeError, function () {
+ BigInt.asIntN();
+}, "ToBigInt: no argument => undefined => TypeError");
+assert.throws(TypeError, function () {
+ BigInt.asIntN(0);
+}, "ToBigInt: no argument => undefined => TypeError");
+
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, undefined);
+}, "ToBigInt: undefined => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ [Symbol.toPrimitive]: function() {
+ return undefined;
+ }
+ });
+}, "ToBigInt: @@toPrimitive => undefined => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ valueOf: function() {
+ return undefined;
+ }
+ });
+}, "ToBigInt: valueOf => undefined => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ toString: function() {
+ return undefined;
+ }
+ });
+}, "ToBigInt: toString => undefined => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, null);
+}, "ToBigInt: null => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ [Symbol.toPrimitive]: function() {
+ return null;
+ }
+ });
+}, "ToBigInt: @@toPrimitive => null => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ valueOf: function() {
+ return null;
+ }
+ });
+}, "ToBigInt: valueOf => null => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ toString: function() {
+ return null;
+ }
+ });
+}, "ToBigInt: toString => null => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, 0);
+}, "ToBigInt: Number => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, Object(0));
+}, "ToBigInt: unbox object with internal slot => Number => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ [Symbol.toPrimitive]: function() {
+ return 0;
+ }
+ });
+}, "ToBigInt: @@toPrimitive => Number => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ valueOf: function() {
+ return 0;
+ }
+ });
+}, "ToBigInt: valueOf => Number => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ toString: function() {
+ return 0;
+ }
+ });
+}, "ToBigInt: toString => Number => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, NaN);
+}, "ToBigInt: Number => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, Infinity);
+}, "ToBigInt: Number => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, Symbol("1"));
+}, "ToBigInt: Symbol => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, Object(Symbol("1")));
+}, "ToBigInt: unbox object with internal slot => Symbol => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ [Symbol.toPrimitive]: function() {
+ return Symbol("1");
+ }
+ });
+}, "ToBigInt: @@toPrimitive => Symbol => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ valueOf: function() {
+ return Symbol("1");
+ }
+ });
+}, "ToBigInt: valueOf => Symbol => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ toString: function() {
+ return Symbol("1");
+ }
+ });
+}, "ToBigInt: toString => Symbol => TypeError");
+assert.throws(SyntaxError, function() {
+ BigInt.asIntN(0, "a");
+}, "ToBigInt: unparseable BigInt");
+assert.throws(SyntaxError, function() {
+ BigInt.asIntN(0, "0b2");
+}, "ToBigInt: unparseable BigInt binary");
+assert.throws(SyntaxError, function() {
+ BigInt.asIntN(0, Object("0b2"));
+}, "ToBigInt: unbox object with internal slot => unparseable BigInt binary");
+assert.throws(SyntaxError, function() {
+ BigInt.asIntN(0, {
+ [Symbol.toPrimitive]: function() {
+ return "0b2";
+ }
+ });
+}, "ToBigInt: @@toPrimitive => unparseable BigInt binary");
+assert.throws(SyntaxError, function() {
+ BigInt.asIntN(0, {
+ valueOf: function() {
+ return "0b2";
+ }
+ });
+}, "ToBigInt: valueOf => unparseable BigInt binary");
+assert.throws(SyntaxError, function() {
+ BigInt.asIntN(0, {
+ toString: function() {
+ return "0b2";
+ }
+ });
+}, "ToBigInt: toString => unparseable BigInt binary");
+assert.throws(SyntaxError, function() {
+ BigInt.asIntN(0, " 0b2 ");
+}, "ToBigInt: unparseable BigInt with leading/trailing whitespace");
+assert.throws(SyntaxError, function() {
+ BigInt.asIntN(0, "0o8");
+}, "ToBigInt: unparseable BigInt octal");
+assert.throws(SyntaxError, function() {
+ BigInt.asIntN(0, "0xg");
+}, "ToBigInt: unparseable BigInt hex");
+assert.throws(SyntaxError, function() {
+ BigInt.asIntN(0, "1n");
+}, "ToBigInt: unparseable BigInt due to literal suffix");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-toprimitive.js b/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-toprimitive.js
new file mode 100644
index 0000000000..7e2e322eea
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-toprimitive.js
@@ -0,0 +1,168 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: BigInt.asIntN type coercion for bigint parameter
+esid: sec-bigint.asintn
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 2. Let bigint ? ToBigInt(bigint).
+features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
+---*/
+assert.sameValue(typeof BigInt, 'function');
+assert.sameValue(typeof BigInt.asIntN, 'function');
+function err() {
+ throw new Test262Error();
+}
+
+function MyError() {}
+
+assert.sameValue(BigInt.asIntN(2, {
+ [Symbol.toPrimitive]: function() {
+ return "1";
+ },
+ valueOf: err,
+ toString: err
+}), 1n, "ToPrimitive: @@toPrimitive takes precedence");
+assert.sameValue(BigInt.asIntN(2, {
+ valueOf: function() {
+ return "1";
+ },
+ toString: err
+}), 1n, "ToPrimitive: valueOf takes precedence over toString");
+assert.sameValue(BigInt.asIntN(2, {
+ toString: function() {
+ return "1";
+ }
+}), 1n, "ToPrimitive: toString with no valueOf");
+assert.sameValue(BigInt.asIntN(2, {
+ [Symbol.toPrimitive]: undefined,
+ valueOf: function() {
+ return "1";
+ }
+}), 1n, "ToPrimitive: skip @@toPrimitive when it's undefined");
+assert.sameValue(BigInt.asIntN(2, {
+ [Symbol.toPrimitive]: null,
+ valueOf: function() {
+ return "1";
+ }
+}), 1n, "ToPrimitive: skip @@toPrimitive when it's null");
+assert.sameValue(BigInt.asIntN(2, {
+ valueOf: null,
+ toString: function() {
+ return "1";
+ }
+}), 1n, "ToPrimitive: skip valueOf when it's not callable");
+assert.sameValue(BigInt.asIntN(2, {
+ valueOf: 1,
+ toString: function() {
+ return "1";
+ }
+}), 1n, "ToPrimitive: skip valueOf when it's not callable");
+assert.sameValue(BigInt.asIntN(2, {
+ valueOf: {},
+ toString: function() {
+ return "1";
+ }
+}), 1n, "ToPrimitive: skip valueOf when it's not callable");
+assert.sameValue(BigInt.asIntN(2, {
+ valueOf: function() {
+ return {};
+ },
+ toString: function() {
+ return "1";
+ }
+}), 1n, "ToPrimitive: skip valueOf when it returns an object");
+assert.sameValue(BigInt.asIntN(2, {
+ valueOf: function() {
+ return Object(12345);
+ },
+ toString: function() {
+ return "1";
+ }
+}), 1n, "ToPrimitive: skip valueOf when it returns an object");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ [Symbol.toPrimitive]: 1
+ });
+}, "ToPrimitive: throw when @@toPrimitive is not callable");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ [Symbol.toPrimitive]: {}
+ });
+}, "ToPrimitive: throw when @@toPrimitive is not callable");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ [Symbol.toPrimitive]: function() {
+ return Object(1);
+ }
+ });
+}, "ToPrimitive: throw when @@toPrimitive returns an object");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ [Symbol.toPrimitive]: function() {
+ return {};
+ }
+ });
+}, "ToPrimitive: throw when @@toPrimitive returns an object");
+assert.throws(MyError, function() {
+ BigInt.asIntN(0, {
+ [Symbol.toPrimitive]: function() {
+ throw new MyError();
+ }
+ });
+}, "ToPrimitive: propagate errors from @@toPrimitive");
+assert.throws(MyError, function() {
+ BigInt.asIntN(0, {
+ valueOf: function() {
+ throw new MyError();
+ }
+ });
+}, "ToPrimitive: propagate errors from valueOf");
+assert.throws(MyError, function() {
+ BigInt.asIntN(0, {
+ toString: function() {
+ throw new MyError();
+ }
+ });
+}, "ToPrimitive: propagate errors from toString");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ valueOf: null,
+ toString: null
+ });
+}, "ToPrimitive: throw when skipping both valueOf and toString");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ valueOf: 1,
+ toString: 1
+ });
+}, "ToPrimitive: throw when skipping both valueOf and toString");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ valueOf: {},
+ toString: {}
+ });
+}, "ToPrimitive: throw when skipping both valueOf and toString");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ valueOf: function() {
+ return Object(1);
+ },
+ toString: function() {
+ return Object(1);
+ }
+ });
+}, "ToPrimitive: throw when skipping both valueOf and toString");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0, {
+ valueOf: function() {
+ return {};
+ },
+ toString: function() {
+ return {};
+ }
+ });
+}, "ToPrimitive: throw when skipping both valueOf and toString");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-wrapped-values.js b/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-wrapped-values.js
new file mode 100644
index 0000000000..8b5801c65d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint-wrapped-values.js
@@ -0,0 +1,64 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: BigInt.asIntN type coercion for bigint parameter
+esid: sec-bigint.asintn
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 2. Let bigint ? ToBigInt(bigint).
+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, {
+ [Symbol.toPrimitive]: function() {
+ return 0n;
+ }
+}), 0n, "ToPrimitive: @@toPrimitive");
+assert.sameValue(BigInt.asIntN(2, {
+ valueOf: function() {
+ return 0n;
+ }
+}), 0n, "ToPrimitive: valueOf");
+assert.sameValue(BigInt.asIntN(2, {
+ toString: function() {
+ return 0n;
+ }
+}), 0n, "ToPrimitive: toString");
+assert.sameValue(BigInt.asIntN(2, Object(true)), 1n,
+ "ToBigInt: unbox object with internal slot => true => 1n");
+assert.sameValue(BigInt.asIntN(2, {
+ [Symbol.toPrimitive]: function() {
+ return true;
+ }
+}), 1n, "ToBigInt: @@toPrimitive => true => 1n");
+assert.sameValue(BigInt.asIntN(2, {
+ valueOf: function() {
+ return true;
+ }
+}), 1n, "ToBigInt: valueOf => true => 1n");
+assert.sameValue(BigInt.asIntN(2, {
+ toString: function() {
+ return true;
+ }
+}), 1n, "ToBigInt: toString => true => 1n");
+assert.sameValue(BigInt.asIntN(2, Object("1")), 1n,
+ "ToBigInt: unbox object with internal slot => parse BigInt");
+assert.sameValue(BigInt.asIntN(2, {
+ [Symbol.toPrimitive]: function() {
+ return "1";
+ }
+}), 1n, "ToBigInt: @@toPrimitive => parse BigInt");
+assert.sameValue(BigInt.asIntN(2, {
+ valueOf: function() {
+ return "1";
+ }
+}), 1n, "ToBigInt: valueOf => parse BigInt");
+assert.sameValue(BigInt.asIntN(2, {
+ toString: function() {
+ return "1";
+ }
+}), 1n, "ToBigInt: toString => parse BigInt");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint.js b/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint.js
new file mode 100644
index 0000000000..143245b835
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/bigint-tobigint.js
@@ -0,0 +1,51 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: BigInt.asIntN type coercion for bigint parameter
+esid: sec-bigint.asintn
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 2. Let bigint ? ToBigInt(bigint).
+features: [BigInt]
+---*/
+
+assert.sameValue(BigInt.asIntN(2, 0n), 0n);
+assert.sameValue(BigInt.asIntN(2, -0n), 0n);
+assert.sameValue(BigInt.asIntN(2, false), 0n, "ToBigInt: false => 0n");
+assert.sameValue(BigInt.asIntN(2, true), 1n, "ToBigInt: true => 1n");
+assert.sameValue(BigInt.asIntN(2, "1"), 1n, "ToBigInt: parse BigInt");
+assert.sameValue(BigInt.asIntN(2, "-0"), 0n, "ToBigInt: parse BigInt");
+assert.sameValue(BigInt.asIntN(2, ""), 0n, "ToBigInt: empty String => 0n");
+assert.sameValue(BigInt.asIntN(2, " "), 0n, "ToBigInt: String with only whitespace => 0n");
+assert.sameValue(BigInt.asIntN(2, []), 0n, "ToBigInt: .toString() => empty String => 0n");
+assert.sameValue(BigInt.asIntN(2, [1]), 1n, "ToBigInt: .toString() => parse BigInt");
+assert.sameValue(BigInt.asIntN(3, 10n), 2n);
+assert.sameValue(BigInt.asIntN(3, "10"), 2n, "ToBigInt: parse BigInt");
+assert.sameValue(BigInt.asIntN(3, "0b1010"), 2n, "ToBigInt: parse BigInt binary");
+assert.sameValue(BigInt.asIntN(3, "0o12"), 2n, "ToBigInt: parse BigInt octal");
+assert.sameValue(BigInt.asIntN(3, "0xa"), 2n, "ToBigInt: parse BigInt hex");
+assert.sameValue(BigInt.asIntN(3, " 0xa "), 2n,
+ "ToBigInt: parse BigInt ignore leading/trailing whitespace");
+assert.sameValue(BigInt.asIntN(3, " 10 "), 2n,
+ "ToBigInt: parse BigInt ignore leading/trailing whitespace");
+assert.sameValue(BigInt.asIntN(3, [10n]), 2n, "ToBigInt: .toString() => parse BigInt");
+assert.sameValue(BigInt.asIntN(3, ["10"]), 2n, "ToBigInt: .toString() => parse BigInt");
+assert.sameValue(BigInt.asIntN(4, 12345678901234567890003n), 3n);
+assert.sameValue(BigInt.asIntN(4, "12345678901234567890003"), 3n, "ToBigInt: parse BigInt");
+assert.sameValue(BigInt.asIntN(4,
+ "0b10100111010100001010110110010011100111011001110001010000100100010001010011"), 3n,
+ "ToBigInt: parse BigInt binary");
+assert.sameValue(BigInt.asIntN(4, "0o2472412662347316120442123"), 3n,
+ "ToBigInt: parse BigInt octal");
+assert.sameValue(BigInt.asIntN(4, "0x29d42b64e7671424453"), 3n, "ToBigInt: parse BigInt hex");
+assert.sameValue(BigInt.asIntN(4, " 0x29d42b64e7671424453 "), 3n,
+ "ToBigInt: parse BigInt ignore leading/trailing whitespace");
+assert.sameValue(BigInt.asIntN(4, " 12345678901234567890003 "), 3n,
+ "ToBigInt: parse BigInt ignore leading/trailing whitespace");
+assert.sameValue(BigInt.asIntN(4, [12345678901234567890003n]), 3n,
+ "ToBigInt: .toString() => parse BigInt");
+assert.sameValue(BigInt.asIntN(4, ["12345678901234567890003"]), 3n,
+ "ToBigInt: .toString() => parse BigInt");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-errors.js b/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-errors.js
new file mode 100644
index 0000000000..79ab560538
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-errors.js
@@ -0,0 +1,88 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: BigInt.asIntN type coercion for bits parameter
+esid: sec-bigint.asintn
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 1. Let bits be ? ToIndex(bits).
+features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
+---*/
+assert.sameValue(typeof BigInt, 'function');
+assert.sameValue(typeof BigInt.asIntN, 'function');
+
+assert.throws(RangeError, function() {
+ BigInt.asIntN(-1, 0n);
+}, "ToIndex: throw when integerIndex < 0");
+assert.throws(RangeError, function() {
+ BigInt.asIntN(-2.5, 0n);
+}, "ToIndex: throw when integerIndex < 0");
+assert.throws(RangeError, function() {
+ BigInt.asIntN("-2.5", 0n);
+}, "ToIndex: parse Number => throw when integerIndex < 0");
+assert.throws(RangeError, function() {
+ BigInt.asIntN(-Infinity, 0n);
+}, "ToIndex: throw when integerIndex < 0");
+assert.throws(RangeError, function() {
+ BigInt.asIntN(9007199254740992, 0n);
+}, "ToIndex: throw when integerIndex > 2**53-1");
+assert.throws(RangeError, function() {
+ BigInt.asIntN(Infinity, 0n);
+}, "ToIndex: throw when integerIndex > 2**53-1");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(0n, 0n);
+}, "ToIndex: BigInt => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(Object(0n), 0n);
+}, "ToIndex: unbox object with internal slot => BigInt => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ return 0n;
+ }
+ }, 0n);
+}, "ToIndex: @@toPrimitive => BigInt => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ valueOf: function() {
+ return 0n;
+ }
+ }, 0n);
+}, "ToIndex: valueOf => BigInt => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ toString: function() {
+ return 0n;
+ }
+ }, 0n);
+}, "ToIndex: toString => BigInt => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(Symbol("1"), 0n);
+}, "ToIndex: Symbol => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN(Object(Symbol("1")), 0n);
+}, "ToIndex: unbox object with internal slot => Symbol => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ return Symbol("1");
+ }
+ }, 0n);
+}, "ToIndex: @@toPrimitive => Symbol => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ valueOf: function() {
+ return Symbol("1");
+ }
+ }, 0n);
+}, "ToIndex: valueOf => Symbol => TypeError");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ toString: function() {
+ return Symbol("1");
+ }
+ }, 0n);
+}, "ToIndex: toString => Symbol => TypeError");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-toprimitive.js b/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-toprimitive.js
new file mode 100644
index 0000000000..0e7ae76341
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-toprimitive.js
@@ -0,0 +1,169 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: BigInt.asIntN type coercion for bits parameter
+esid: sec-bigint.asintn
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 1. Let bits be ? ToIndex(bits).
+features: [BigInt, computed-property-names, Symbol, Symbol.toPrimitive]
+---*/
+assert.sameValue(typeof BigInt, 'function');
+assert.sameValue(typeof BigInt.asIntN, 'function');
+
+function err() {
+ throw new Test262Error();
+}
+
+function MyError() {}
+
+assert.sameValue(BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ return 1;
+ },
+ valueOf: err,
+ toString: err
+}, 1n), -1n, "ToPrimitive: @@toPrimitive takes precedence");
+assert.sameValue(BigInt.asIntN({
+ valueOf: function() {
+ return 1;
+ },
+ toString: err
+}, 1n), -1n, "ToPrimitive: valueOf takes precedence over toString");
+assert.sameValue(BigInt.asIntN({
+ toString: function() {
+ return 1;
+ }
+}, 1n), -1n, "ToPrimitive: toString with no valueOf");
+assert.sameValue(BigInt.asIntN({
+ [Symbol.toPrimitive]: undefined,
+ valueOf: function() {
+ return 1;
+ }
+}, 1n), -1n, "ToPrimitive: skip @@toPrimitive when it's undefined");
+assert.sameValue(BigInt.asIntN({
+ [Symbol.toPrimitive]: null,
+ valueOf: function() {
+ return 1;
+ }
+}, 1n), -1n, "ToPrimitive: skip @@toPrimitive when it's null");
+assert.sameValue(BigInt.asIntN({
+ valueOf: null,
+ toString: function() {
+ return 1;
+ }
+}, 1n), -1n, "ToPrimitive: skip valueOf when it's not callable");
+assert.sameValue(BigInt.asIntN({
+ valueOf: 1,
+ toString: function() {
+ return 1;
+ }
+}, 1n), -1n, "ToPrimitive: skip valueOf when it's not callable");
+assert.sameValue(BigInt.asIntN({
+ valueOf: {},
+ toString: function() {
+ return 1;
+ }
+}, 1n), -1n, "ToPrimitive: skip valueOf when it's not callable");
+assert.sameValue(BigInt.asIntN({
+ valueOf: function() {
+ return {};
+ },
+ toString: function() {
+ return 1;
+ }
+}, 1n), -1n, "ToPrimitive: skip valueOf when it returns an object");
+assert.sameValue(BigInt.asIntN({
+ valueOf: function() {
+ return Object(12345);
+ },
+ toString: function() {
+ return 1;
+ }
+}, 1n), -1n, "ToPrimitive: skip valueOf when it returns an object");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ [Symbol.toPrimitive]: 1
+ }, 0n);
+}, "ToPrimitive: throw when @@toPrimitive is not callable");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ [Symbol.toPrimitive]: {}
+ }, 0n);
+}, "ToPrimitive: throw when @@toPrimitive is not callable");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ return Object(1);
+ }
+ }, 0n);
+}, "ToPrimitive: throw when @@toPrimitive returns an object");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ return {};
+ }
+ }, 0n);
+}, "ToPrimitive: throw when @@toPrimitive returns an object");
+assert.throws(MyError, function() {
+ BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ throw new MyError();
+ }
+ }, 0n);
+}, "ToPrimitive: propagate errors from @@toPrimitive");
+assert.throws(MyError, function() {
+ BigInt.asIntN({
+ valueOf: function() {
+ throw new MyError();
+ }
+ }, 0n);
+}, "ToPrimitive: propagate errors from valueOf");
+assert.throws(MyError, function() {
+ BigInt.asIntN({
+ toString: function() {
+ throw new MyError();
+ }
+ }, 0n);
+}, "ToPrimitive: propagate errors from toString");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ valueOf: null,
+ toString: null
+ }, 0n);
+}, "ToPrimitive: throw when skipping both valueOf and toString");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ valueOf: 1,
+ toString: 1
+ }, 0n);
+}, "ToPrimitive: throw when skipping both valueOf and toString");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ valueOf: {},
+ toString: {}
+ }, 0n);
+}, "ToPrimitive: throw when skipping both valueOf and toString");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ valueOf: function() {
+ return Object(1);
+ },
+ toString: function() {
+ return Object(1);
+ }
+ }, 0n);
+}, "ToPrimitive: throw when skipping both valueOf and toString");
+assert.throws(TypeError, function() {
+ BigInt.asIntN({
+ valueOf: function() {
+ return {};
+ },
+ toString: function() {
+ return {};
+ }
+ }, 0n);
+}, "ToPrimitive: throw when skipping both valueOf and toString");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-wrapped-values.js b/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-wrapped-values.js
new file mode 100644
index 0000000000..ad7dcb50e4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex-wrapped-values.js
@@ -0,0 +1,111 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: BigInt.asIntN type coercion for bits parameter
+esid: sec-bigint.asintn
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 1. Let bits be ? ToIndex(bits).
+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({
+ [Symbol.toPrimitive]: function() {
+ return 0;
+ }
+}, 1n), 0n, "ToPrimitive: @@toPrimitive");
+assert.sameValue(BigInt.asIntN({
+ valueOf: function() {
+ return 0;
+ }
+}, 1n), 0n, "ToPrimitive: valueOf");
+assert.sameValue(BigInt.asIntN({
+ toString: function() {
+ return 0;
+ }
+}, 1n), 0n, "ToPrimitive: toString");
+assert.sameValue(BigInt.asIntN(Object(NaN), 1n), 0n,
+ "ToIndex: unbox object with internal slot => NaN => 0");
+assert.sameValue(BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ return NaN;
+ }
+}, 1n), 0n, "ToIndex: @@toPrimitive => NaN => 0");
+assert.sameValue(BigInt.asIntN({
+ valueOf: function() {
+ return NaN;
+ }
+}, 1n), 0n, "ToIndex: valueOf => NaN => 0");
+assert.sameValue(BigInt.asIntN({
+ toString: function() {
+ return NaN;
+ }
+}, 1n), 0n, "ToIndex: toString => NaN => 0");
+assert.sameValue(BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ return undefined;
+ }
+}, 1n), 0n, "ToIndex: @@toPrimitive => undefined => NaN => 0");
+assert.sameValue(BigInt.asIntN({
+ valueOf: function() {
+ return undefined;
+ }
+}, 1n), 0n, "ToIndex: valueOf => undefined => NaN => 0");
+assert.sameValue(BigInt.asIntN({
+ toString: function() {
+ return undefined;
+ }
+}, 1n), 0n, "ToIndex: toString => undefined => NaN => 0");
+assert.sameValue(BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ return null;
+ }
+}, 1n), 0n, "ToIndex: @@toPrimitive => null => 0");
+assert.sameValue(BigInt.asIntN({
+ valueOf: function() {
+ return null;
+ }
+}, 1n), 0n, "ToIndex: valueOf => null => 0");
+assert.sameValue(BigInt.asIntN({
+ toString: function() {
+ return null;
+ }
+}, 1n), 0n, "ToIndex: toString => null => 0");
+assert.sameValue(BigInt.asIntN(Object(true), 1n), -1n,
+ "ToIndex: unbox object with internal slot => true => 1");
+assert.sameValue(BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ return true;
+ }
+}, 1n), -1n, "ToIndex: @@toPrimitive => true => 1");
+assert.sameValue(BigInt.asIntN({
+ valueOf: function() {
+ return true;
+ }
+}, 1n), -1n, "ToIndex: valueOf => true => 1");
+assert.sameValue(BigInt.asIntN({
+ toString: function() {
+ return true;
+ }
+}, 1n), -1n, "ToIndex: toString => true => 1");
+assert.sameValue(BigInt.asIntN(Object("1"), 1n), -1n,
+ "ToIndex: unbox object with internal slot => parse Number");
+assert.sameValue(BigInt.asIntN({
+ [Symbol.toPrimitive]: function() {
+ return "1";
+ }
+}, 1n), -1n, "ToIndex: @@toPrimitive => parse Number");
+assert.sameValue(BigInt.asIntN({
+ valueOf: function() {
+ return "1";
+ }
+}, 1n), -1n, "ToIndex: valueOf => parse Number");
+assert.sameValue(BigInt.asIntN({
+ toString: function() {
+ return "1";
+ }
+}, 1n), -1n, "ToIndex: toString => parse Number");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex.js b/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex.js
new file mode 100644
index 0000000000..85a99c6abf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/bits-toindex.js
@@ -0,0 +1,37 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: BigInt.asIntN type coercion for bits parameter
+esid: sec-bigint.asintn
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 1. Let bits be ? ToIndex(bits).
+features: [BigInt]
+---*/
+
+assert.sameValue(BigInt.asIntN(0, 1n), 0n);
+assert.sameValue(BigInt.asIntN(1, 1n), -1n);
+assert.sameValue(BigInt.asIntN(-0.9, 1n), 0n, "ToIndex: truncate towards 0");
+assert.sameValue(BigInt.asIntN(0.9, 1n), 0n, "ToIndex: truncate towards 0");
+assert.sameValue(BigInt.asIntN(NaN, 1n), 0n, "ToIndex: NaN => 0");
+assert.sameValue(BigInt.asIntN(undefined, 1n), 0n, "ToIndex: undefined => NaN => 0");
+assert.sameValue(BigInt.asIntN(null, 1n), 0n, "ToIndex: null => 0");
+assert.sameValue(BigInt.asIntN(false, 1n), 0n, "ToIndex: false => 0");
+assert.sameValue(BigInt.asIntN(true, 1n), -1n, "ToIndex: true => 1");
+assert.sameValue(BigInt.asIntN("0", 1n), 0n, "ToIndex: parse Number");
+assert.sameValue(BigInt.asIntN("1", 1n), -1n, "ToIndex: parse Number");
+assert.sameValue(BigInt.asIntN("", 1n), 0n, "ToIndex: parse Number => NaN => 0");
+assert.sameValue(BigInt.asIntN("foo", 1n), 0n, "ToIndex: parse Number => NaN => 0");
+assert.sameValue(BigInt.asIntN("true", 1n), 0n, "ToIndex: parse Number => NaN => 0");
+assert.sameValue(BigInt.asIntN(3, 10n), 2n);
+assert.sameValue(BigInt.asIntN("3", 10n), 2n, "toIndex: parse Number");
+assert.sameValue(BigInt.asIntN(3.9, 10n), 2n, "toIndex: truncate towards 0");
+assert.sameValue(BigInt.asIntN("3.9", 10n), 2n, "toIndex: parse Number => truncate towards 0");
+assert.sameValue(BigInt.asIntN([0], 1n), 0n, 'ToIndex: [0].toString() => "0" => 0');
+assert.sameValue(BigInt.asIntN(["1"], 1n), -1n, 'ToIndex: ["1"].toString() => "1" => 1');
+assert.sameValue(BigInt.asIntN({}, 1n), 0n,
+ 'ToIndex: ({}).toString() => "[object Object]" => NaN => 0');
+assert.sameValue(BigInt.asIntN([], 1n), 0n, 'ToIndex: [].toString() => "" => NaN => 0');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/browser.js b/js/src/tests/test262/built-ins/BigInt/asIntN/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/browser.js
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/length.js b/js/src/tests/test262/built-ins/BigInt/asIntN/length.js
new file mode 100644
index 0000000000..57e6347ddc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/length.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-bigint.asintn
+description: BigInt.asIntN.length descriptor
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [BigInt]
+---*/
+
+verifyProperty(BigInt.asIntN, "length", {
+ value: 2,
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/name.js b/js/src/tests/test262/built-ins/BigInt/asIntN/name.js
new file mode 100644
index 0000000000..d1a4bc77a7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/name.js
@@ -0,0 +1,22 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-bigint.asintn
+description: BigInt.asIntN.name descriptor
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 17 ECMAScript Standard Built-in Objects
+
+includes: [propertyHelper.js]
+features: [BigInt]
+---*/
+
+verifyProperty(BigInt.asIntN, "name", {
+ value: "asIntN",
+ enumerable: false,
+ writable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/not-a-constructor.js b/js/src/tests/test262/built-ins/BigInt/asIntN/not-a-constructor.js
new file mode 100644
index 0000000000..7875347fcf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/not-a-constructor.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+ BigInt.asIntN does not implement [[Construct]], is not new-able
+info: |
+ ECMAScript Function Objects
+
+ Built-in function objects that are not identified as constructors do not
+ implement the [[Construct]] internal method unless otherwise specified in
+ the description of a particular function.
+
+ sec-evaluatenew
+
+ ...
+ 7. If IsConstructor(constructor) is false, throw a TypeError exception.
+ ...
+includes: [isConstructor.js]
+features: [Reflect.construct, BigInt, arrow-function]
+---*/
+assert.sameValue(isConstructor(BigInt.asIntN), false, 'isConstructor(BigInt.asIntN) must return false');
+
+assert.throws(TypeError, () => {
+ new BigInt.asIntN(64, 1n);
+}, '`new BigInt.asIntN(64, 1n)` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/order-of-steps.js b/js/src/tests/test262/built-ins/BigInt/asIntN/order-of-steps.js
new file mode 100644
index 0000000000..1311379be8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/order-of-steps.js
@@ -0,0 +1,34 @@
+// Copyright (C) 2017 Josh Wolfe. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-bigint.asintn
+description: BigInt.asIntN order of parameter type coercion
+info: |
+ BigInt.asIntN ( bits, bigint )
+
+ 1. Let bits be ? ToIndex(bits).
+ 2. Let bigint ? ToBigInt(bigint).
+
+features: [BigInt]
+---*/
+
+var i = 0;
+var bits = {
+ valueOf() {
+ assert.sameValue(i, 0);
+ i++;
+ return 0;
+ }
+};
+var bigint = {
+ valueOf() {
+ assert.sameValue(i, 1);
+ i++;
+ return 0n;
+ }
+};
+
+BigInt.asIntN(bits, bigint);
+assert.sameValue(i, 2);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/asIntN/shell.js b/js/src/tests/test262/built-ins/BigInt/asIntN/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/asIntN/shell.js