mirror of https://github.com/sbt/sbt.git
update to ScalaCheck 1.11.0
This commit is contained in:
parent
191737d35b
commit
a92b883e23
|
|
@ -29,7 +29,7 @@ object EnumerationTest extends Properties("Enumeration")
|
|||
{
|
||||
def invalid(s: String) =
|
||||
("valueOf(" + s + ")") |:
|
||||
Prop.throws(enum.toValue(s), classOf[Exception])
|
||||
Prop.throws(classOf[Exception])(enum.toValue(s))
|
||||
def valid(s: String, expected: Enumeration#Value) =
|
||||
("valueOf(" + s + ")") |:
|
||||
("Expected " + expected) |:
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ object ListMapProperties extends Properties("ListMap")
|
|||
{ (map + (key, value) ).get(key) == Some(value) }
|
||||
}
|
||||
property("remove") = Prop.forAll { (map: ListMap[Int,Int], key: Int) =>
|
||||
{ Prop.throws((map - key)(key), classOf[Exception]) } &&
|
||||
{ Prop.throws(classOf[Exception])((map - key)(key)) } &&
|
||||
{ !(map - key).contains(key) } &&
|
||||
{ (map - key).get(key).isEmpty }
|
||||
}
|
||||
property("empty") = Prop.forAll { (key: Int) =>
|
||||
{ Prop.throws(ListMap.empty(key), classOf[Exception]) }
|
||||
{ Prop.throws(classOf[Exception])(ListMap.empty(key)) }
|
||||
{ !ListMap.empty.contains(key) } &&
|
||||
{ ListMap.empty.get(key).isEmpty }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ object PreTest extends Properties("Pre")
|
|||
property("isEmpty") = Prop.forAll( (s: String) => (s.isEmpty == isEmpty(s)) )
|
||||
property("isNonEmpty") = Prop.forAll( (s: String) => (isEmpty(s) != isNonEmpty(s)) )
|
||||
property("assert true") = { assert(true); true }
|
||||
property("assert false") = Prop.throws(assert(false), classOf[AssertionError])
|
||||
property("assert false") = Prop.throws(classOf[AssertionError])(assert(false))
|
||||
property("assert true with message") = Prop.forAll { (s: String) => assert(true, s); true }
|
||||
property("assert false with message") = Prop.forAll( (s: String) => Prop.throws(assert(false, s), classOf[AssertionError] ) )
|
||||
property("require false") = Prop.forAll( (s: String) => Prop.throws(require(false, s), classOf[IllegalArgumentException]) )
|
||||
property("assert false with message") = Prop.forAll( (s: String) => Prop.throws(classOf[AssertionError] )(assert(false, s)) )
|
||||
property("require false") = Prop.forAll( (s: String) => Prop.throws(classOf[IllegalArgumentException])(require(false, s)) )
|
||||
property("require true") = Prop.forAll { (s: String) => require(true, s); true }
|
||||
property("error") = Prop.forAll( (s: String) => Prop.throws(error(s), classOf[BootException]) )
|
||||
property("error") = Prop.forAll( (s: String) => Prop.throws(classOf[BootException])(error(s)) )
|
||||
property("toBoolean") = Prop.forAll( (s: String) => trap(toBoolean(s)) == trap(java.lang.Boolean.parseBoolean(s)) )
|
||||
property("toArray") = Prop.forAll( (list: List[Int]) => arrEquals(list.toArray, toArray(list)) )
|
||||
property("toArray") = Prop.forAll( (list: List[String]) => objArrEquals(list.toArray, toArray(list)) )
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ object EvalTest extends Properties("eval")
|
|||
property("type mismatch") = forAll{ (i: Int, l: Int) =>
|
||||
val line = math.abs(l)
|
||||
val src = "mismatch"
|
||||
throws(eval.eval(i.toString, tpeName =Some(BooleanType), line = line, srcName = src), classOf[RuntimeException]) &&
|
||||
throws(classOf[RuntimeException])(eval.eval(i.toString, tpeName =Some(BooleanType), line = line, srcName = src)) &&
|
||||
hasErrors(line+1, src)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -262,8 +262,8 @@ object TestBuild
|
|||
val next = for(depCount <- maxDeps; d <- pick(depCount min xs.size, xs) ) yield (x, d.toList)
|
||||
genAcyclic(maxDeps, xs, next :: acc)
|
||||
}
|
||||
def sequence[T](gs: Seq[Gen[T]]): Gen[Seq[T]] = Gen { prms =>
|
||||
Some(gs map { g => g(prms) getOrElse error("failed generator") })
|
||||
def sequence[T](gs: Seq[Gen[T]]): Gen[Seq[T]] = Gen.parameterized { prms =>
|
||||
wrap( gs map { g => g(prms) getOrElse error("failed generator") } )
|
||||
}
|
||||
type Inputs[A,T] = (T, Seq[T], Seq[A] => A)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ object Util
|
|||
|
||||
def testDependencies = libraryDependencies <++= includeTestDependencies { incl =>
|
||||
if(incl) Seq(
|
||||
"org.scalacheck" %% "scalacheck" % "1.10.0" % "test",
|
||||
"org.scalacheck" %% "scalacheck" % "1.11.0" % "test",
|
||||
"org.specs2" %% "specs2" % "1.12.3" % "test",
|
||||
"junit" % "junit" % "4.11" % "test"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ object DagSpecification extends Properties("Dag")
|
|||
private def dagGen(nodeCount: Int): Gen[TestDag] =
|
||||
{
|
||||
val nodes = new HashSet[TestDag]
|
||||
def nonterminalGen(p: Gen.Params): Gen[TestDag] =
|
||||
def nonterminalGen(p: Gen.Parameters): Gen[TestDag] =
|
||||
{
|
||||
for(i <- 0 until nodeCount; nextDeps <- Gen.someOf(nodes).apply(p))
|
||||
nodes += new TestDag(i, nextDeps)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ import Process._
|
|||
|
||||
object ProcessSpecification extends Properties("Process I/O")
|
||||
{
|
||||
implicit val exitCodeArb: Arbitrary[Array[Byte]] = Arbitrary(Gen.choose(0, 10) flatMap { size => Gen.resize(size, Arbitrary.arbArray[Byte].arbitrary) })
|
||||
implicit val exitCodeArb: Arbitrary[Array[Byte]] = Arbitrary(
|
||||
for(size <- Gen.choose(0, 10);
|
||||
l <- Gen.listOfN[Byte](size, Arbitrary.arbByte.arbitrary))
|
||||
yield
|
||||
l.toArray
|
||||
)
|
||||
|
||||
/*property("Correct exit code") = forAll( (exitCode: Byte) => checkExit(exitCode))
|
||||
property("#&& correct") = forAll( (exitCodes: Array[Byte]) => checkBinary(exitCodes)(_ #&& _)(_ && _))
|
||||
|
|
|
|||
Loading…
Reference in New Issue