diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/mapfn-is-not-callable.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/mapfn-is-not-callable.js')
-rw-r--r-- | js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/mapfn-is-not-callable.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/mapfn-is-not-callable.js b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/mapfn-is-not-callable.js new file mode 100644 index 0000000000..77921c51a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/TypedArrayConstructors/from/BigInt/mapfn-is-not-callable.js @@ -0,0 +1,61 @@ +// 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: Throw a TypeError exception is mapfn is not callable +info: | + 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 3. If mapfn was supplied and mapfn is not undefined, then + a. If IsCallable(mapfn) is false, throw a TypeError exception. + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol, Symbol.iterator, TypedArray] +---*/ + +var getIterator = 0; +var arrayLike = {}; +Object.defineProperty(arrayLike, Symbol.iterator, { + get: function() { + getIterator++; + } +}); + +testWithBigIntTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + TA.from(arrayLike, null); + }, "mapfn is null"); + + assert.throws(TypeError, function() { + TA.from(arrayLike, 42); + }, "mapfn is a number"); + + assert.throws(TypeError, function() { + TA.from(arrayLike, ""); + }, "mapfn is a string"); + + assert.throws(TypeError, function() { + TA.from(arrayLike, {}); + }, "mapfn is an ordinary object"); + + assert.throws(TypeError, function() { + TA.from(arrayLike, []); + }, "mapfn is an array"); + + assert.throws(TypeError, function() { + TA.from(arrayLike, true); + }, "mapfn is a boolean"); + + var s = Symbol("1"); + assert.throws(TypeError, function() { + TA.from(arrayLike, s); + }, "mapfn is a symbol"); + + assert.sameValue( + getIterator, 0, + "IsCallable(mapfn) check occurs before getting source[@@iterator]" + ); +}); + +reportCompare(0, 0); |