Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes LAFuture.collect/collectAll behaviour for empty list parameter
For empty list parameter, were returned future which never been satisfied. Now is returned future that is immediately satisfied by empty list.
- Loading branch information
Showing
2 changed files
with
82 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
core/actor/src/test/scala/net/liftweb/actor/LAFutureSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.liftweb.actor | ||
|
||
import org.specs2.mutable.Specification | ||
|
||
class LAFutureSpec extends Specification { | ||
val timeout = 1000L | ||
|
||
"LAFuture" should { | ||
|
||
"collect one future result" in { | ||
val givenOneResult = 123 | ||
val one = LAFuture(() => givenOneResult) | ||
LAFuture.collect(one).get(timeout) shouldEqual List(givenOneResult) | ||
} | ||
|
||
"collect more future results in correct order" in { | ||
val givenOneResult = 123 | ||
val givenTwoResult = 234 | ||
val one = LAFuture(() => givenOneResult) | ||
val two = LAFuture(() => givenTwoResult) | ||
LAFuture.collect(one, two).get shouldEqual List(givenOneResult, givenTwoResult) | ||
} | ||
|
||
"collect empty list immediately" in { | ||
val collectResult = LAFuture.collect(Nil: _*) | ||
collectResult.isSatisfied shouldEqual true | ||
collectResult.get shouldEqual Nil | ||
} | ||
|
||
"collectAll empty list immediately" in { | ||
val collectResult = LAFuture.collectAll(Nil : _*) | ||
collectResult.isSatisfied shouldEqual true | ||
collectResult.get shouldEqual Nil | ||
} | ||
} | ||
|
||
} |