diff options
Diffstat (limited to 'test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js')
-rw-r--r-- | test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js new file mode 100644 index 000000000..e99e1b715 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js @@ -0,0 +1,39 @@ +// 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%.prototype.filter +description: callbackfn is called for each item before TypedArraySpeciesCreate +info: | + 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... + 10. Let A be ? TypedArraySpeciesCreate(O, « captured »). + ... +includes: [testBigIntTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntTypedArrayConstructors(function(TA) { + var length = 42; + var sample = new TA(length); + var calls = 0; + var before = false; + + sample.constructor = {}; + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + before = calls === length; + } + }); + + sample.filter(function() { + calls++; + }); + + assert.sameValue(calls, 42, "callbackfn called for each item"); + assert.sameValue(before, true, "all callbackfn called before"); +}); |