From 93a2ba8c28d2f8d1b59bfd596864e79c6dae37fb Mon Sep 17 00:00:00 2001 From: Yusuke Suzuki Date: Mon, 1 Feb 2021 16:26:28 -0800 Subject: [PATCH] Fix BigInt TypedArrays tests 1. test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js It is not updated when a60a67ea880bb4b5de849ee8f7676a475f60c85f is landed. This patch fixes it. 2. test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js After detaching, BigInt64Array/BigUint64Array will produce undefined for indexed access. And if `filter`'s callback says `true` for these results, we need to store `ToBigInt(undefined)` to a newly resulted BigInt64Array/BigUint64Array and this will throw an error. But this test assumed it does not throw. This patch fixed flag so that we do not throw that error while keeping detached typed arrays tested. --- .../filter/BigInt/callbackfn-detachbuffer.js | 6 +++++- .../BigInt/predicate-may-detach-buffer.js | 17 +++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js index cfb3f92f31..346830325b 100644 --- a/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js +++ b/test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js @@ -1,4 +1,5 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. +// Copyright (C) 2021 Apple Inc. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-%typedarray%.prototype.filter @@ -22,11 +23,14 @@ testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.filter(function() { + var flag = true; if (loops === 0) { $DETACHBUFFER(sample.buffer); + } else { + flag = false; } loops++; - return true; + return flag; }); assert.sameValue(loops, 2); diff --git a/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js b/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js index 80078b3fe7..bfb837d23f 100644 --- a/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js +++ b/test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js @@ -1,4 +1,5 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. +// Copyright (C) 2021 Apple Inc. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-%typedarray%.prototype.findindex @@ -36,16 +37,12 @@ features: [BigInt, TypedArray] testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var loops = 0; - var completion = false; - assert.throws(TypeError, function() { - sample.findIndex(function() { - loops++; + sample.findIndex(function() { + if (loops === 0) { $DETACHBUFFER(sample.buffer); - completion = true; - }); - }, "throws a TypeError getting a value from the detached buffer"); - - assert.sameValue(loops, 1, "predicated is called once"); - assert(completion, "abrupt completion does not come from DETACHBUFFER"); + } + loops++; + }); + assert.sameValue(loops, 2, "predicate is called once"); });