1
1
package dispatch .spec
2
2
3
3
import org .scalacheck ._
4
+ import scala .collection .immutable .ArraySeq
4
5
5
6
object IterableFutureSpecification
6
7
extends Properties (" Iterable Future" )
7
8
with DispatchCleanup {
8
- import Prop .{forAll ,AnyOperators }
9
- import Gen ._
9
+ import Prop .{forAll }
10
10
11
11
private val port = unfiltered.util.Port .any
12
12
val server = {
@@ -31,7 +31,7 @@ with DispatchCleanup {
31
31
32
32
def split (str : String ): Future [Seq [String ]] =
33
33
for (csv <- Http .default(localhost / " split" << Seq (" str" -> str) > as.String ))
34
- yield csv.split(" ," )
34
+ yield ArraySeq .unsafeWrapArray( csv.split(" ," ) )
35
35
36
36
def value (str : String ): Future [Int ] =
37
37
for (v <- Http .default(localhost / " value" << Seq (" chr" -> str) > as.String ))
@@ -42,7 +42,8 @@ with DispatchCleanup {
42
42
val values = split(sample).values.flatMap { chr =>
43
43
value(chr)
44
44
}
45
- values() ?= sample.map { _.toInt }
45
+
46
+ Prop .?= (values(), sample.map(_.toInt))
46
47
}
47
48
48
49
property(" iterable future values" ) = forAll(Gen .alphaStr) {
@@ -55,10 +56,12 @@ with DispatchCleanup {
55
56
c2 <- value(chr2)
56
57
} yield (c1, c2)
57
58
58
- values() ?= ( for {
59
+ val expected : Iterable [( Int , Int )] = for {
59
60
c1 <- sample
60
61
c2 <- sample.reverse
61
- } yield (c1.toInt, c2.toInt))
62
+ } yield (c1.toInt, c2.toInt)
63
+
64
+ Prop .?= (values(), expected)
62
65
}
63
66
64
67
property(" iterable future values on either" ) = forAll(Gen .alphaStr) {
@@ -68,9 +71,12 @@ with DispatchCleanup {
68
71
chr1 <- split(sample).either.right.values
69
72
c1 <- value(chr1)
70
73
} yield Right (c1)
71
- values().toOption.get ?= (for {
74
+
75
+ val expected = (for {
72
76
c1 <- sample
73
77
} yield c1.toInt)
78
+
79
+ Prop .?= (values(), Right (expected))
74
80
}
75
81
76
82
}
0 commit comments