From b21b0c1820cee545547c18834290564899d4a714 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Wed, 25 Mar 2020 09:55:34 -0400 Subject: [PATCH] Promise.any: additional "resolve from rejection" tests --- .../Promise/any/resolve-from-reject-catch.js | 22 +++++++++++++++++++ ...s => resolve-from-resolve-reject-catch.js} | 0 .../resolve-from-resolve-reject-finally.js | 22 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 test/built-ins/Promise/any/resolve-from-reject-catch.js rename test/built-ins/Promise/any/{resolve-one-mixed.js => resolve-from-resolve-reject-catch.js} (100%) create mode 100644 test/built-ins/Promise/any/resolve-from-resolve-reject-finally.js diff --git a/test/built-ins/Promise/any/resolve-from-reject-catch.js b/test/built-ins/Promise/any/resolve-from-reject-catch.js new file mode 100644 index 0000000000..bbefced968 --- /dev/null +++ b/test/built-ins/Promise/any/resolve-from-reject-catch.js @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.any +description: > + Promise.any resolves with the first item that does not reject. +flags: [async] +features: [Promise.any, arrow-function] +---*/ + +let fulfillables = [ + Promise.reject('a'), + new Promise((resolve, reject) => reject('b')), + Promise.all([Promise.reject('c')]), + Promise.reject('d').catch(v => v), +]; + +Promise.any(fulfillables) + .then((resolution) => { + assert.sameValue(resolution, 'd'); + }).then($DONE, $DONE); diff --git a/test/built-ins/Promise/any/resolve-one-mixed.js b/test/built-ins/Promise/any/resolve-from-resolve-reject-catch.js similarity index 100% rename from test/built-ins/Promise/any/resolve-one-mixed.js rename to test/built-ins/Promise/any/resolve-from-resolve-reject-catch.js diff --git a/test/built-ins/Promise/any/resolve-from-resolve-reject-finally.js b/test/built-ins/Promise/any/resolve-from-resolve-reject-finally.js new file mode 100644 index 0000000000..de1c6a8930 --- /dev/null +++ b/test/built-ins/Promise/any/resolve-from-resolve-reject-finally.js @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-promise.any +description: > + Promise.any resolves with the first item that does not reject. +flags: [async] +features: [Promise.any, arrow-function] +---*/ + +let fulfillables = [ + Promise.reject('a'), + new Promise((resolve, reject) => reject('b')), + Promise.all([Promise.reject('c')]), + Promise.resolve(Promise.reject('d').finally(v => v)), +]; + +Promise.any(fulfillables) + .then((resolution) => { + assert.sameValue(resolution, 'd'); + }).then($DONE, $DONE);