summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-smaller-instance-throws.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-smaller-instance-throws.js')
-rw-r--r--js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-smaller-instance-throws.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-smaller-instance-throws.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-smaller-instance-throws.js
new file mode 100644
index 0000000000..2982a4cd38
--- /dev/null
+++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-smaller-instance-throws.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-%typedarray%.from
+description: >
+ Throws a TypeError if a custom `this` returns a smaller instance
+info: |
+ %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
+
+ ...
+ 7. If usingIterator is not undefined, then
+ a. Let values be ? IterableToList(source, usingIterator).
+ b. Let len be the number of elements in values.
+ c. Let targetObj be ? TypedArrayCreate(C, «len»).
+ ...
+ 10. Let len be ? ToLength(? Get(arrayLike, "length")).
+ 11. Let targetObj be ? TypedArrayCreate(C, « len »).
+ ...
+includes: [testBigIntTypedArray.js]
+features: [BigInt, Symbol.iterator, TypedArray]
+---*/
+
+var sourceItor = [1n, 2n];
+var sourceObj = {
+ length: 2
+};
+
+testWithBigIntTypedArrayConstructors(function(TA) {
+ var ctor = function() {
+ return new TA(1);
+ };
+ assert.throws(TypeError, function() {
+ TA.from.call(ctor, sourceItor);
+ }, "source is using iterator");
+
+ assert.throws(TypeError, function() {
+ TA.from.call(ctor, sourceObj);
+ }, "source is not using iterator");
+});
+
+reportCompare(0, 0);