11package dispatch .spec
22
33import org .scalacheck ._
4+ import scala .collection .immutable .ArraySeq
45
56object IterableFutureSpecification
67extends Properties (" Iterable Future" )
78with DispatchCleanup {
8- import Prop .{forAll ,AnyOperators }
9- import Gen ._
9+ import Prop .{forAll }
1010
1111 private val port = unfiltered.util.Port .any
1212 val server = {
@@ -31,7 +31,7 @@ with DispatchCleanup {
3131
3232 def split (str : String ): Future [Seq [String ]] =
3333 for (csv <- Http .default(localhost / " split" << Seq (" str" -> str) > as.String ))
34- yield csv.split(" ," )
34+ yield ArraySeq .unsafeWrapArray( csv.split(" ," ) )
3535
3636 def value (str : String ): Future [Int ] =
3737 for (v <- Http .default(localhost / " value" << Seq (" chr" -> str) > as.String ))
@@ -42,7 +42,8 @@ with DispatchCleanup {
4242 val values = split(sample).values.flatMap { chr =>
4343 value(chr)
4444 }
45- values() ?= sample.map { _.toInt }
45+
46+ Prop .?= (values(), sample.map(_.toInt))
4647 }
4748
4849 property(" iterable future values" ) = forAll(Gen .alphaStr) {
@@ -55,10 +56,12 @@ with DispatchCleanup {
5556 c2 <- value(chr2)
5657 } yield (c1, c2)
5758
58- values() ?= ( for {
59+ val expected : Iterable [( Int , Int )] = for {
5960 c1 <- sample
6061 c2 <- sample.reverse
61- } yield (c1.toInt, c2.toInt))
62+ } yield (c1.toInt, c2.toInt)
63+
64+ Prop .?= (values(), expected)
6265 }
6366
6467 property(" iterable future values on either" ) = forAll(Gen .alphaStr) {
@@ -68,9 +71,12 @@ with DispatchCleanup {
6871 chr1 <- split(sample).either.right.values
6972 c1 <- value(chr1)
7073 } yield Right (c1)
71- values().toOption.get ?= (for {
74+
75+ val expected = (for {
7276 c1 <- sample
7377 } yield c1.toInt)
78+
79+ Prop .?= (values(), Right (expected))
7480 }
7581
7682}
0 commit comments