2 // Misc scalacheck lift tests
4 // [1] http://code.google.com/p/scalacheck/wiki/UserGuide
6 package org
.botnode
.botlist
.tests
8 import org
.scalacheck
._
9 import org
.scalacheck
.Test
._
10 import org
.scalacheck
.Gen
._
11 import org
.scalacheck
.Arbitrary
._
12 import org
.scalacheck
.Prop
._
13 import org
.scalacheck
.ConsoleReporter
.testStatsEx
18 * SmallInteger defines a generator that generates integers
19 * between 0 and 100, inclusively. Generators will be
20 * described closer in a later section. propSmallInteger
21 * simply specifies that each integer generated should be
22 * in the correct range. The forAll method is good
23 * to use when you want to control the data generation
24 * by specifying exactly which generator that should be used,
25 * and not rely on a default generator for the given type.
26 * -- ScalaCheck User Guide.
28 val smallInteger
= Gen
.choose(0, 10)
29 val smallEvenInteger
= Gen
.choose(0,200) suchThat (_
% 2 == 0)
30 val prop_SmallInteger
= Prop
.forAll(smallInteger
)(n
=> {
34 val propReverseList
= property( (l
: List
[String
]) => l
.reverse
.reverse
== l
)
35 val propConcatString
= property( (s1
: String
, s2
: String
) => s1
.concat(s2
).endsWith(s2
) )
37 val prop_commutative
= property((a
: Int
, b
: Int
) => {
40 testStatsEx("Commutativity", check(prop_commutative
))
41 Test
.check(prop_SmallInteger
)
42 Test
.check(propReverseList
)
43 Test
.check(propConcatString
)