summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-object-throws.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-object-throws.js')
-rw-r--r--js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-object-throws.js33
1 files changed, 33 insertions, 0 deletions
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);