summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/BigInt/prototype
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/prototype
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/prototype')
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/Symbol.toStringTag.js24
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/constructor.js31
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/prop-desc.js20
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/proto.js16
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/not-a-constructor.js33
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/a-z.js23
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/default-radix.js21
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/length.js22
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/name.js22
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/not-a-constructor.js33
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/prototype-call.js24
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/radix-2-to-36.js26
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/radix-err.js29
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/string-is-code-units-of-decimal-digits-only.js22
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/toString/thisbigintvalue-not-valid-throws.js79
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/cross-realm.js16
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/length.js22
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/name.js22
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/not-a-constructor.js33
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/prop-desc.js21
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/return.js20
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-object-throws.js33
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-primitive-throws.js67
32 files changed, 680 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/Symbol.toStringTag.js b/js/src/tests/test262/built-ins/BigInt/prototype/Symbol.toStringTag.js
new file mode 100644
index 0000000000..33e806a2e6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/Symbol.toStringTag.js
@@ -0,0 +1,24 @@
+// Copyright (C) 2017 Igalia, S. L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-bigint-@@tostringtag
+description: >
+ `Symbol.toStringTag` property descriptor
+info: |
+ The initial value of the @@toStringTag property is the String value
+ "BigInt".
+
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]:
+ false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [BigInt, Symbol, Symbol.toStringTag]
+---*/
+
+verifyProperty(BigInt.prototype, Symbol.toStringTag, {
+ value: "BigInt",
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/browser.js b/js/src/tests/test262/built-ins/BigInt/prototype/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/browser.js
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/constructor.js b/js/src/tests/test262/built-ins/BigInt/prototype/constructor.js
new file mode 100644
index 0000000000..c36f2e266e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/constructor.js
@@ -0,0 +1,31 @@
+// 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.constructor
+description: BigInt.prototype.constructor property descriptor
+info: |
+ BigInt.prototype.constructor
+
+ The initial value of BigInt.prototype.constructor is the intrinsic
+ object %BigInt%.
+
+ The BigInt Constructor
+
+ The BigInt constructor is the %BigInt% intrinsic object and the
+ initial value of the BigInt property of the global object. When BigInt
+ is called as a function, it performs a type conversion.
+
+ 17 ECMAScript Standard Built-in Objects
+includes: [propertyHelper.js]
+features: [BigInt]
+---*/
+
+verifyProperty(BigInt.prototype, "constructor", {
+ value: BigInt,
+ writable: true,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/prop-desc.js b/js/src/tests/test262/built-ins/BigInt/prototype/prop-desc.js
new file mode 100644
index 0000000000..f8ac507a95
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/prop-desc.js
@@ -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.
+
+/*---
+description: The property descriptor BigInt.prototype
+esid: sec-bigint.prototype
+info: |
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: false }.
+features: [BigInt]
+includes: [propertyHelper.js]
+---*/
+
+verifyProperty(BigInt, "prototype", {
+ writable: false,
+ enumerable: false,
+ configurable: false
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/proto.js b/js/src/tests/test262/built-ins/BigInt/prototype/proto.js
new file mode 100644
index 0000000000..df0b8edeaf
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/proto.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: The prototype of BigInt.prototype is Object.prototype
+esid: sec-properties-of-the-bigint-prototype-object
+info: |
+ The value of the [[Prototype]] internal slot of the BigInt prototype object
+ is the intrinsic object %ObjectPrototype%.
+features: [BigInt]
+---*/
+
+var proto = Object.getPrototypeOf(BigInt.prototype);
+assert.sameValue(proto, Object.prototype);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/shell.js b/js/src/tests/test262/built-ins/BigInt/prototype/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/shell.js
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/browser.js b/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/browser.js
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/not-a-constructor.js b/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/not-a-constructor.js
new file mode 100644
index 0000000000..e51206920a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/not-a-constructor.js
@@ -0,0 +1,33 @@
+// 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.prototype.toLocaleString 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.prototype.toLocaleString),
+ false,
+ 'isConstructor(BigInt.prototype.toLocaleString) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let n = 1n;
+ new n.toLocaleString();
+}, '`let n = 1n; new n.toLocaleString()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/shell.js b/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toLocaleString/shell.js
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/a-z.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/a-z.js
new file mode 100644
index 0000000000..c6b50f1943
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/a-z.js
@@ -0,0 +1,23 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-bigint.prototype.tostring
+description: >
+ Letters a-z are used for digits with values 10 through 35
+info: |
+ 6. Return the String representation of this Number value using
+ the radix specified by radixNumber. Letters a-z are used for
+ digits with values 10 through 35. The precise algorithm is
+ implementation-dependent, however the algorithm should be a
+ generalization of that specified in 6.1.6.2.23.
+features: [BigInt]
+---*/
+
+for (let radix = 11; radix <= 36; radix++) {
+ for (let i = 10n; i < radix; i++) {
+ assert.sameValue(i.toString(radix), String.fromCharCode(Number(i + 87n)));
+ }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/browser.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/browser.js
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/default-radix.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/default-radix.js
new file mode 100644
index 0000000000..3ec85a7d95
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/default-radix.js
@@ -0,0 +1,21 @@
+// Copyright 2018 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-bigint.prototype.tostring
+description: toString with default radix
+features: [BigInt]
+---*/
+
+assert.sameValue((-100n).toString(), "-100", "(-100n).toString() === '-100'");
+assert.sameValue((0n).toString(), "0", "(0n).toString() === '0'");
+assert.sameValue((100n).toString(), "100", "(100n).toString() === '100'");
+
+assert.sameValue((-100n).toString(undefined), "-100",
+ "(-100n).toString(undefined) === '-100'");
+assert.sameValue((0n).toString(undefined), "0",
+ "(0n).toString(undefined) === '0'");
+assert.sameValue((100n).toString(undefined), "100",
+ "(100n).toString(undefined) === '100'");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/length.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/length.js
new file mode 100644
index 0000000000..add932d601
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/length.js
@@ -0,0 +1,22 @@
+// 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.tostring
+description: BigInt.prototype.toString.length property descriptor
+info: |
+ BigInt.prototype.toString ( [ radix ] )
+
+ 17 ECMAScript Standard Built-in Objects
+includes: [propertyHelper.js]
+features: [BigInt]
+---*/
+
+verifyProperty(BigInt.prototype.toString, "length", {
+ value: 0,
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/name.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/name.js
new file mode 100644
index 0000000000..b5da17dff6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/name.js
@@ -0,0 +1,22 @@
+// 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.tostring
+description: BigInt.prototype.toString.name property descriptor
+info: |
+ BigInt.prototype.toString ( [ radix ] )
+
+ 17 ECMAScript Standard Built-in Objects
+includes: [propertyHelper.js]
+features: [BigInt]
+---*/
+
+verifyProperty(BigInt.prototype.toString, "name", {
+ value: "toString",
+ writable: false,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/not-a-constructor.js
new file mode 100644
index 0000000000..ffa6c1491c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/not-a-constructor.js
@@ -0,0 +1,33 @@
+// 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.prototype.toString 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.prototype.toString),
+ false,
+ 'isConstructor(BigInt.prototype.toString) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let n = 1n;
+ new n.toString();
+}, '`let n = 1n; new n.toString()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/prop-desc.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/prop-desc.js
new file mode 100644
index 0000000000..50d85e610a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/prop-desc.js
@@ -0,0 +1,21 @@
+// Copyright (C) 2016 Robin Templeton. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-bigint.prototype.tostring
+description: BigInt.prototype.toString property descriptor
+info: |
+ BigInt.prototype.toString ( [ radix ] )
+
+ 17 ECMAScript Standard Built-in Objects
+includes: [propertyHelper.js]
+features: [BigInt]
+---*/
+
+verifyProperty(BigInt.prototype, "toString", {
+ writable: true,
+ enumerable: false,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/prototype-call.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/prototype-call.js
new file mode 100644
index 0000000000..6de3725ea6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/prototype-call.js
@@ -0,0 +1,24 @@
+// Copyright 2017 Robin Templeton. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-bigint.prototype.tostring
+description: Direct toString on BigInt prototype
+info: |
+ BigInt.prototype.toString ( [ radix ] )
+
+ Let x be ? thisBigIntValue(this value).
+
+ Properties of the BigInt Prototype Object
+
+ The BigInt prototype is not a BigInt object; it does not have a
+ [[BigIntData]] internal slot.
+features: [BigInt]
+---*/
+assert.sameValue(typeof BigInt, 'function');
+
+assert.throws(TypeError, function() {
+ BigInt.prototype.toString(1);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/radix-2-to-36.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/radix-2-to-36.js
new file mode 100644
index 0000000000..24a95b0972
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/radix-2-to-36.js
@@ -0,0 +1,26 @@
+// Copyright 2017 Robin Templeton. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-bigint.prototype.tostring
+description: toString with radix between 2 and 36
+info: |
+ BigInt.prototype.toString ( [ radix ] )
+
+ [...]
+ 6. If radixNumber = 10, return ! ToString(x).
+ 7. Return the String representation of this Number value using the
+ radix specified by radixNumber. Letters a-z are used for digits
+ with values 10 through 35. The precise algorithm is
+ implementation-dependent, however the algorithm should be a
+ generalization of that specified in 3.1.4.1.
+features: [BigInt]
+---*/
+
+for (let r = 2; r <= 36; r++) {
+ assert.sameValue((0n).toString(r), "0", "0, radix " + r);
+ assert.sameValue((-1n).toString(r), "-1", "-1, radix " + r);
+ assert.sameValue((1n).toString(r), "1", "1, radix " + r);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/radix-err.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/radix-err.js
new file mode 100644
index 0000000000..e5ef637606
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/radix-err.js
@@ -0,0 +1,29 @@
+// Copyright 2017 Robin Templeton. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-bigint.prototype.tostring
+description: toString with invalid radix
+info: |
+ BigInt.prototype.toString ( [ radix ] )
+
+ [...]
+ 4. Else, let radixNumber be ? ToInteger(radix).
+ 5. If radixNumber < 2 or radixNumber > 36, throw a RangeError
+ exception.
+features: [BigInt]
+---*/
+
+for (let r of [0, 1, 37, null]) {
+ assert.throws(RangeError, function() {
+ (0n).toString(r);
+ }, "0, radix " + r);
+ assert.throws(RangeError, function() {
+ (-1n).toString(r);
+ }, "-1, radix " + r);
+ assert.throws(RangeError, function() {
+ (1n).toString(r);
+ }, "1, radix " + r);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/shell.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/shell.js
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/string-is-code-units-of-decimal-digits-only.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/string-is-code-units-of-decimal-digits-only.js
new file mode 100644
index 0000000000..a3c11c2396
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/string-is-code-units-of-decimal-digits-only.js
@@ -0,0 +1,22 @@
+// Copyright 2017 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-tostring-applied-to-the-bigint-type
+description: BigInt .toString() returns only decimal digits, does not include BigIntLiteralSuffix
+info: |
+ ToString Applied to the BigInt Type
+
+ The abstract operation ToString converts a BigInt i to String format as follows:
+
+ ...
+ Return the String consisting of the code units of the digits of the decimal representation of i.
+
+features: [BigInt]
+---*/
+
+assert.sameValue(BigInt(0).toString(), "0", "BigInt(0).toString() === '0'");
+assert.sameValue(BigInt(0n).toString(), "0", "BigInt(0n).toString() === '0'");
+assert.sameValue(0n.toString(), "0", "0n.toString() === '0'");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/toString/thisbigintvalue-not-valid-throws.js b/js/src/tests/test262/built-ins/BigInt/prototype/toString/thisbigintvalue-not-valid-throws.js
new file mode 100644
index 0000000000..d9aaed49c8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/toString/thisbigintvalue-not-valid-throws.js
@@ -0,0 +1,79 @@
+// Copyright 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-bigint.prototype.tostring
+description: Throws a TypeError if the this value is not a BigInt
+info: |
+ BigInt.prototype.toString ( [ radix ] )
+
+ 1. Let x be ? thisBigIntValue(this value).
+ ...
+
+ The abstract operation thisBigIntValue(value) performs the following steps:
+
+ 1. If Type(value) is BigInt, return value.
+ 2. If Type(value) is Object and value has a [[BigIntData]] internal slot, then
+ ...
+ 3. Throw a TypeError exception.
+features: [BigInt, Symbol, Symbol.toPrimitive]
+---*/
+
+var toString = BigInt.prototype.toString;
+
+assert.sameValue(typeof toString, 'function');
+
+assert.throws(TypeError, function() {
+ toString.call({
+ x: 1n
+ });
+}, '{x: 1n}');
+
+assert.throws(TypeError, function() {
+ toString.call([1n]);
+}, '[1n]');
+
+var obj = {
+ valueOf: function() {
+ throw new Test262Error('no [[BigIntData]]')
+ },
+ toString: function() {
+ throw new Test262Error('no [[BigIntData]]')
+ },
+ [Symbol.toPrimitive]: function() {
+ throw new Test262Error('no [[BigIntData]]')
+ }
+};
+assert.throws(TypeError, function() {
+ toString.call(obj);
+}, '{valueOf, toString, toPrimitive}');
+
+assert.throws(TypeError, function() {
+ toString.call(0);
+}, '0');
+
+assert.throws(TypeError, function() {
+ toString.call(1);
+}, '1');
+
+assert.throws(TypeError, function() {
+ toString.call(NaN);
+}, 'NaN');
+
+assert.throws(TypeError, function() {
+ toString.call(undefined);
+}, 'undefined');
+
+assert.throws(TypeError, function() {
+ toString.call(null);
+}, 'null');
+
+assert.throws(TypeError, function() {
+ toString.call(true);
+}, 'true');
+
+assert.throws(TypeError, function() {
+ toString.call(false);
+}, 'false');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/browser.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/browser.js
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/cross-realm.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/cross-realm.js
new file mode 100644
index 0000000000..96cb49dd2f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/cross-realm.js
@@ -0,0 +1,16 @@
+// Copyright 2018 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-bigint.prototype.valueof
+description: valueOf called with a BigInt object from another realm
+features: [BigInt, cross-realm]
+---*/
+
+var other = $262.createRealm().global;
+var wrapped = other.Object(other.BigInt(0));
+
+assert.sameValue(BigInt.prototype.valueOf.call(wrapped), 0n,
+ "cross-realm valueOf");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/length.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/length.js
new file mode 100644
index 0000000000..871b9d030c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/length.js
@@ -0,0 +1,22 @@
+// 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
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/name.js
new file mode 100644
index 0000000000..eb632fb265
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/name.js
@@ -0,0 +1,22 @@
+// 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
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/not-a-constructor.js
new file mode 100644
index 0000000000..1476cd46dd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/not-a-constructor.js
@@ -0,0 +1,33 @@
+// 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.prototype.valueOf 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.prototype.valueOf),
+ false,
+ 'isConstructor(BigInt.prototype.valueOf) must return false'
+);
+
+assert.throws(TypeError, () => {
+ let n = 1n;
+ new n.valueOf();
+}, '`let n = 1n; new n.valueOf()` throws TypeError');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/prop-desc.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/prop-desc.js
new file mode 100644
index 0000000000..22776b6d1b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/prop-desc.js
@@ -0,0 +1,21 @@
+// 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
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/return.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/return.js
new file mode 100644
index 0000000000..c9a0472bcc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/return.js
@@ -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 returns the primitive BigInt value.
+info: |
+ BigInt.prototype.valueOf ( )
+
+ Return ? thisBigIntValue(this value).
+features: [BigInt]
+---*/
+
+var valueOf = BigInt.prototype.valueOf;
+
+assert.sameValue(valueOf.call(0n), 0n, "0n");
+assert.sameValue(valueOf.call(Object(0n)), 0n, "Object(0n)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/shell.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/shell.js
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-object-throws.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-object-throws.js
new file mode 100644
index 0000000000..994587d325
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-object-throws.js
@@ -0,0 +1,33 @@
+// 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: >
+ Throws a TypeError if this is an Object without a [[BigIntData]] internal.
+info: |
+ BigInt.prototype.valueOf ( )
+
+ 1. Return ? thisBigIntValue(this value).
+
+ The abstract operation thisBigIntValue(value) performs the following steps:
+
+ 1. If Type(value) is BigInt, return value.
+ 2. If Type(value) is Object and value has a [[BigIntData]] internal slot, then
+ ...
+ 3. Throw a TypeError exception.
+features: [BigInt]
+---*/
+
+var valueOf = BigInt.prototype.valueOf;
+assert.sameValue(typeof valueOf, 'function');
+
+assert.throws(TypeError, function() {
+ valueOf.call({});
+}, "{}");
+
+assert.throws(TypeError, function() {
+ valueOf.call(Object(1));
+}, "Object(1)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-primitive-throws.js b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-primitive-throws.js
new file mode 100644
index 0000000000..1956451d5e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-primitive-throws.js
@@ -0,0 +1,67 @@
+// 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: >
+ Throws a TypeError if this is not a BigInt neither an Object.
+info: |
+ BigInt.prototype.valueOf ( )
+
+ 1. Return ? thisBigIntValue(this value).
+
+ The abstract operation thisBigIntValue(value) performs the following steps:
+
+ 1. If Type(value) is BigInt, return value.
+ 2. If Type(value) is Object and value has a [[BigIntData]] internal slot, then
+ ...
+ 3. Throw a TypeError exception.
+features: [BigInt, Symbol]
+---*/
+
+var valueOf = BigInt.prototype.valueOf;
+
+assert.sameValue(typeof valueOf, 'function');
+
+assert.throws(TypeError, function() {
+ valueOf.call(undefined);
+}, "undefined");
+
+assert.throws(TypeError, function() {
+ valueOf.call(null);
+}, "null");
+
+assert.throws(TypeError, function() {
+ valueOf.call(false);
+}, "false");
+
+assert.throws(TypeError, function() {
+ valueOf.call(true);
+}, "true");
+
+assert.throws(TypeError, function() {
+ valueOf.call("");
+}, "the empty string");
+
+assert.throws(TypeError, function() {
+ valueOf.call("1n");
+}, "string");
+
+assert.throws(TypeError, function() {
+ valueOf.call(0);
+}, "number (0)");
+
+assert.throws(TypeError, function() {
+ valueOf.call(1);
+}, "number (1)");
+
+assert.throws(TypeError, function() {
+ valueOf.call(NaN);
+}, "NaN");
+
+var s = Symbol();
+assert.throws(TypeError, function() {
+ valueOf.call(s);
+}, "symbol");
+
+reportCompare(0, 0);