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)) )
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ object EvalTest extends Properties("eval")
|
|||
private[this] val reporter = new StoreReporter
|
||||
import reporter.{ERROR,Info,Severity}
|
||||
private[this] val eval = new Eval(_ => reporter, None)
|
||||
|
||||
|
||||
property("inferred integer") = forAll{ (i: Int) =>
|
||||
val result = eval.eval(i.toString)
|
||||
(label("Value", value(result)) |: (value(result) == i)) &&
|
||||
|
|
@ -25,11 +25,11 @@ object EvalTest extends Properties("eval")
|
|||
(label("Type", result.tpe) |: (result.tpe == IntType)) &&
|
||||
(label("Files", result.generated) |: (result.generated.isEmpty))
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ object TestBuild
|
|||
val MaxIDSize = 8
|
||||
val MaxDeps = 8
|
||||
val KeysPerEnv = 10
|
||||
|
||||
|
||||
val MaxTasksGen = chooseShrinkable(1, MaxTasks)
|
||||
val MaxProjectsGen = chooseShrinkable(1, MaxProjects)
|
||||
val MaxConfigsGen = chooseShrinkable(1, MaxConfigs)
|
||||
|
|
@ -53,7 +53,7 @@ object TestBuild
|
|||
(Scope.display(scope, "<key>"), showKeys(map))
|
||||
scopeStrings.toSeq.sorted.map(t => t._1 + t._2).mkString("\n\t")
|
||||
}
|
||||
val extra: BuildUtil[Proj] =
|
||||
val extra: BuildUtil[Proj] =
|
||||
{
|
||||
val getp = (build: URI, project: String) => env.buildMap(build).projectMap(project)
|
||||
new BuildUtil(keyIndex, data, env.root.uri, env.rootProject, getp, _.configurations.map(c => ConfigKey(c.name)), Relation.empty)
|
||||
|
|
@ -148,7 +148,7 @@ object TestBuild
|
|||
}
|
||||
final class Taskk(val key: AttributeKey[String], val delegates: Seq[Taskk])
|
||||
{
|
||||
override def toString = key.label + " (delegates: " + delegates.map(_.key.label).mkString(", ") + ")"
|
||||
override def toString = key.label + " (delegates: " + delegates.map(_.key.label).mkString(", ") + ")"
|
||||
}
|
||||
|
||||
def mapBy[K, T](s: Seq[T])(f: T => K): Map[K, T] = s map { t => (f(t), t) } toMap;
|
||||
|
|
@ -214,7 +214,7 @@ object TestBuild
|
|||
implicit def envGen(implicit bGen: Gen[Build], tasks: Gen[Seq[Taskk]]): Gen[Env] =
|
||||
for(i <- MaxBuildsGen; bs <- listOfN(i, bGen); ts <- tasks) yield new Env(bs, ts)
|
||||
implicit def buildGen(implicit uGen: Gen[URI], pGen: URI => Gen[Seq[Proj]]): Gen[Build] = for(u <- uGen; ps <- pGen(u)) yield new Build(u, ps)
|
||||
|
||||
|
||||
def nGen[T](igen: Gen[Int])(implicit g: Gen[T]): Gen[List[T]] = igen flatMap { ig => listOfN(ig, g) }
|
||||
|
||||
implicit def genProjects(build: URI)(implicit genID: Gen[String], maxDeps: Gen[Int], count: Gen[Int], confs: Gen[Seq[Config]]): Gen[Seq[Proj]] =
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ object Util
|
|||
def minProject(path: File, nameString: String) = Project(normalize(nameString), path) settings( commonSettings(nameString) ++ publishPomSettings : _* )
|
||||
def baseProject(path: File, nameString: String) = minProject(path, nameString) settings( base : _*)
|
||||
def testedBaseProject(path: File, nameString: String) = baseProject(path, nameString) settings(testDependencies)
|
||||
|
||||
|
||||
lazy val javaOnly = Seq[Setting[_]](/*crossPaths := false, */compileOrder := CompileOrder.JavaThenScala, unmanagedSourceDirectories in Compile <<= Seq(javaSource in Compile).join)
|
||||
lazy val base: Seq[Setting[_]] = Seq(projectComponent) ++ baseScalacOptions ++ Licensed.settings
|
||||
lazy val baseScalacOptions = Seq(
|
||||
|
|
@ -47,10 +47,10 @@ object Util
|
|||
case _ => Seq("-feature", "-language:implicitConversions", "-language:postfixOps", "-language:higherKinds", "-language:existentials")
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
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"
|
||||
)
|
||||
|
|
@ -59,7 +59,7 @@ object Util
|
|||
|
||||
lazy val minimalSettings: Seq[Setting[_]] = Defaults.paths ++ Seq[Setting[_]](crossTarget := target.value, name <<= thisProject(_.id))
|
||||
|
||||
def projectComponent = projectID <<= (projectID, componentID) { (pid, cid) =>
|
||||
def projectComponent = projectID <<= (projectID, componentID) { (pid, cid) =>
|
||||
cid match { case Some(id) => pid extra("e:component" -> id); case None => pid }
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ object Util
|
|||
val init = keywords.map(tn => '"' + tn + '"').mkString("Set(", ", ", ")")
|
||||
val ObjectName = "ScalaKeywords"
|
||||
val PackageName = "sbt"
|
||||
val keywordsSrc =
|
||||
val keywordsSrc =
|
||||
"""package %s
|
||||
object %s {
|
||||
val values = %s
|
||||
|
|
@ -188,7 +188,7 @@ object Licensed
|
|||
lazy val seeRegex = """\(see (.*?)\)""".r
|
||||
def licensePath(base: File, str: String): File = { val path = base / str; if(path.exists) path else error("Referenced license '" + str + "' not found at " + path) }
|
||||
def seePaths(base: File, noticeString: String): Seq[File] = seeRegex.findAllIn(noticeString).matchData.map(d => licensePath(base, d.group(1))).toList
|
||||
|
||||
|
||||
def settings: Seq[Setting[_]] = Seq(
|
||||
notice <<= baseDirectory(_ / "NOTICE"),
|
||||
unmanagedResources in Compile <++= (notice, extractLicenses) map { _ +: _ },
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -27,7 +27,7 @@ object DagSpecification extends Properties("Dag")
|
|||
}
|
||||
Gen.parameterized(nonterminalGen)
|
||||
}
|
||||
|
||||
|
||||
private def isSet[T](c: Seq[T]) = Set(c: _*).size == c.size
|
||||
private def dependenciesPrecedeNodes(sort: List[TestDag]) =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)(_ #&& _)(_ && _))
|
||||
|
|
@ -99,7 +104,7 @@ object ProcessSpecification extends Properties("Process I/O")
|
|||
val process = f(a, b)
|
||||
( process ! ) == 0 && sameFiles(a, b)
|
||||
}
|
||||
private def sameFiles(a: File, b: File) =
|
||||
private def sameFiles(a: File, b: File) =
|
||||
IO.readBytes(a) sameElements IO.readBytes(b)
|
||||
|
||||
private def withTempFiles[T](f: (File, File) => T): T =
|
||||
|
|
@ -112,7 +117,7 @@ object ProcessSpecification extends Properties("Process I/O")
|
|||
temporaryFile1.delete()
|
||||
temporaryFile2.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
private def unsigned(b: Int): Int = ((b: Int) +256) % 256
|
||||
private def unsigned(b: Byte): Int = unsigned(b: Int)
|
||||
private def process(command: String) =
|
||||
|
|
|
|||
Loading…
Reference in New Issue