File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ CHANGELOG for 3.x
1212 ` some() ` , ` map() ` , ` reduce() ` ) now require an array of promises or values
1313 as input. Before, arrays and promises which resolve to an array were
1414 supported, other input types resolved to empty arrays or ` null ` (#35 ).
15+ * BC break: ` race() ` now returns a forever pending promise when called with
16+ an empty array (#83 ).
17+ The behavior is now also in line with the ES6 specification.
1518 * BC break: The interfaces ` PromiseInterface ` , ` ExtendedPromiseInterface `
1619 and ` CancellablePromiseInterface ` have been merged into a single
1720 ` PromiseInterface ` (#75 ).
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ function all(array $promisesOrValues)
4444function race (array $ promisesOrValues )
4545{
4646 if (!$ promisesOrValues ) {
47- return resolve ( );
47+ return new Promise ( function () {} );
4848 }
4949
5050 $ cancellationQueue = new Internal \CancellationQueue ();
Original file line number Diff line number Diff line change 55class FunctionRaceTest extends TestCase
66{
77 /** @test */
8- public function shouldResolveEmptyInput ()
8+ public function shouldReturnForeverPendingPromiseForEmptyInput ()
99 {
10- $ mock = $ this ->createCallableMock ();
11- $ mock
12- ->expects ($ this ->once ())
13- ->method ('__invoke ' )
14- ->with ($ this ->identicalTo (null ));
15-
1610 race (
1711 []
18- )->then ($ mock );
12+ )->then ($ this -> expectCallableNever (), $ this -> expectCallableNever () );
1913 }
2014
2115 /** @test */
You can’t perform that action at this time.
0 commit comments