mirror of https://github.com/sbt/sbt.git
Convert logic system test cases into unit tests.
Still TODO for auto-plugins/logic: * property-based tests for logic system * user documentation * (optional) 'about plugins' or similar to show more information about the auto-plugins for a project * (deferred) allow AutoPlugin to inject Commands directly? * (deferred) provide AutoPlugin functionality to arbitrary scopes instead of just at the Project level?
This commit is contained in:
parent
9264099594
commit
162d8094ba
|
|
@ -74,7 +74,7 @@ object Sbt extends Build
|
||||||
// cross versioning
|
// cross versioning
|
||||||
lazy val crossSub = baseProject(utilPath / "cross", "Cross") settings(inConfig(Compile)(Transform.crossGenSettings): _*)
|
lazy val crossSub = baseProject(utilPath / "cross", "Cross") settings(inConfig(Compile)(Transform.crossGenSettings): _*)
|
||||||
// A logic with restricted negation as failure for a unique, stable model
|
// A logic with restricted negation as failure for a unique, stable model
|
||||||
lazy val logicSub = baseProject(utilPath / "logic", "Logic").dependsOn(collectionSub, relationSub)
|
lazy val logicSub = testedBaseProject(utilPath / "logic", "Logic").dependsOn(collectionSub, relationSub)
|
||||||
|
|
||||||
/* **** Intermediate-level Modules **** */
|
/* **** Intermediate-level Modules **** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,40 @@
|
||||||
package sbt
|
package sbt
|
||||||
package logic
|
package logic
|
||||||
|
|
||||||
object Test {
|
import org.scalacheck._
|
||||||
|
import Prop.secure
|
||||||
|
import Logic.{LogicException, Matched}
|
||||||
|
|
||||||
|
object LogicTest extends Properties("Logic")
|
||||||
|
{
|
||||||
|
import TestClauses._
|
||||||
|
|
||||||
|
property("Handles trivial resolution.") = secure( expect(trivial, Set(A) ) )
|
||||||
|
property("Handles less trivial resolution.") = secure( expect(lessTrivial, Set(B,A,D)) )
|
||||||
|
property("Handles cycles without negation") = secure( expect(cycles, Set(F,A,B)) )
|
||||||
|
property("Handles basic exclusion.") = secure( expect(excludedPos, Set()) )
|
||||||
|
property("Handles exclusion of head proved by negation.") = secure( expect(excludedNeg, Set()) )
|
||||||
|
// TODO: actually check ordering, probably as part of a check that dependencies are satisifed
|
||||||
|
property("Properly orders results.") = secure( expect(ordering, Set(B,A,C,E,F)))
|
||||||
|
property("Detects cyclic negation") = secure(
|
||||||
|
Logic.reduceAll(badClauses, Set()) match {
|
||||||
|
case Right(res) => false
|
||||||
|
case Left(err: Logic.CyclicNegation) => true
|
||||||
|
case Left(err) => error(s"Expected cyclic error, got: $err")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def expect(result: Either[LogicException, Matched], expected: Set[Atom]) = result match {
|
||||||
|
case Left(err) => false
|
||||||
|
case Right(res) =>
|
||||||
|
val actual = res.provenSet
|
||||||
|
(actual == expected) || error(s"Expected to prove $expected, but actually proved $actual")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object TestClauses
|
||||||
|
{
|
||||||
|
|
||||||
val A = Atom("A")
|
val A = Atom("A")
|
||||||
val B = Atom("B")
|
val B = Atom("B")
|
||||||
val C = Atom("C")
|
val C = Atom("C")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue