From 7cc98501d37d4b133433825672e4d1e10f7f6926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=C2=A0S=2E=C2=A0Choi?= Date: Mon, 14 Apr 2025 09:47:05 -0600 Subject: [PATCH] Add and rename Array.fromAsync thenable rejection test cases --- ...iterable-with-rejecting-thenable-closes.js | 34 +++++++++++++++++++ ...erable-with-rejecting-thenable-rejects.js} | 0 2 files changed, 34 insertions(+) create mode 100644 test/built-ins/Array/fromAsync/sync-iterable-with-rejecting-thenable-closes.js rename test/built-ins/Array/fromAsync/{sync-iterable-with-thenable-element-rejects.js => sync-iterable-with-rejecting-thenable-rejects.js} (100%) diff --git a/test/built-ins/Array/fromAsync/sync-iterable-with-rejecting-thenable-closes.js b/test/built-ins/Array/fromAsync/sync-iterable-with-rejecting-thenable-closes.js new file mode 100644 index 0000000000..6c6bad315f --- /dev/null +++ b/test/built-ins/Array/fromAsync/sync-iterable-with-rejecting-thenable-closes.js @@ -0,0 +1,34 @@ +// Copyright (C) 2025 J. S. Choi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Array.fromAsync closes any sync-iterable input with a rejecting thenable. +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let finallyCounter = 0; + const inputThenable = { + then(resolve, reject) { + reject(); + }, + }; + function* createInput() { + try { + yield inputThenable; + } finally { + finallyCounter++; + } + } + const input = createInput(); + try { + await Array.fromAsync(input); + } finally { + assert.sameValue(finallyCounter, 1); + } +}); diff --git a/test/built-ins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js b/test/built-ins/Array/fromAsync/sync-iterable-with-rejecting-thenable-rejects.js similarity index 100% rename from test/built-ins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js rename to test/built-ins/Array/fromAsync/sync-iterable-with-rejecting-thenable-rejects.js