Merge pull request #18 from sbt/wip/fileinfo

Adds picklers to FileInfo, also new house rules
This commit is contained in:
eugene yokota 2015-09-25 17:34:19 -04:00 committed by Dale Wijnand
commit 25cbae2b2e
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
9 changed files with 35 additions and 24 deletions

View File

@ -56,9 +56,8 @@ object Dag {
finished;
}
final class Cyclic(val value: Any, val all: List[Any], val complete: Boolean)
extends Exception("Cyclic reference involving " +
(if (complete) all.mkString("\n ", "\n ", "") else value)
) {
extends Exception("Cyclic reference involving " +
(if (complete) all.mkString("\n ", "\n ", "") else value)) {
def this(value: Any) = this(value, value :: Nil, false)
override def toString = getMessage
def ::(a: Any): Cyclic =

View File

@ -49,7 +49,8 @@ object SettingsUsage {
val mySettings: Seq[Setting[_]] = Seq(
setting(a3, value(3)),
setting(b4, map(a4)(_ * 3)),
update(a5)(_ + 1))
update(a5)(_ + 1)
)
// "compiles" and applies the settings.
// This can be split into multiple steps to access intermediate results if desired.

View File

@ -55,7 +55,8 @@ object SettingsTest extends Properties("settings") {
List(scoped0, scoped1) <- chk :: scopedKeys sliding 2
nextInit = if (scoped0 == chk) chk
else (scoped0 zipWith chk) { (p, _) => p + 1 }
} yield derive(setting(scoped1, nextInit))).toSeq
} yield derive(setting(scoped1, nextInit))
).toSeq
{
// Note: This causes a cycle refernec error, quite frequently.
@ -95,7 +96,8 @@ object SettingsTest extends Properties("settings") {
setting(b, value(6)),
derive(setting(b, a)),
setting(a, value(5)),
setting(b, value(8)))
setting(b, value(8))
)
val ev = evaluate(settings)
checkKey(a, Some(5), ev) && checkKey(b, Some(8), ev)
}
@ -104,7 +106,8 @@ object SettingsTest extends Properties("settings") {
setting(a, value(3)),
setting(b, value(6)),
derive(setting(b, a)),
setting(a, value(5)))
setting(a, value(5))
)
val ev = evaluate(settings)
checkKey(a, Some(5), ev) && checkKey(b, Some(5), ev)
}

View File

@ -34,7 +34,8 @@ object HistoryCommands {
Nth -> ("Execute the command with index n, as shown by the " + ListFull + " command"),
Previous -> "Execute the nth command before this one",
StartsWithString -> "Execute the most recent command starting with 'string'",
ContainsString -> "Execute the most recent command containing 'string'")
ContainsString -> "Execute the most recent command containing 'string'"
)
def helpString = "History commands:\n " + (descriptions.map { case (c, d) => c + " " + d }).mkString("\n ")
def printHelp(): Unit =
println(helpString)
@ -46,8 +47,7 @@ object HistoryCommands {
val MaxLines = 500
lazy val num = token(NatBasic, "<integer>")
lazy val last = Last ^^^ { execute(_.!!) }
lazy val list = ListCommands ~> (num ?? Int.MaxValue) map { show =>
(h: History) => { printHistory(h, MaxLines, show); Some(Nil) }
lazy val list = ListCommands ~> (num ?? Int.MaxValue) map { show => (h: History) => { printHistory(h, MaxLines, show); Some(Nil) }
}
lazy val execStr = flag('?') ~ token(any.+.string, "<string>") map {
case (contains, str) =>

View File

@ -426,11 +426,10 @@ trait ParserMain {
case _ =>
val ci = i + 1
if (ci >= s.length)
a.resultEmpty.toEither.left.map { msgs0 =>
() =>
val msgs = msgs0()
val nonEmpty = if (msgs.isEmpty) "Unexpected end of input" :: Nil else msgs
(nonEmpty, ci)
a.resultEmpty.toEither.left.map { msgs0 => () =>
val msgs = msgs0()
val nonEmpty = if (msgs.isEmpty) "Unexpected end of input" :: Nil else msgs
(nonEmpty, ci)
}
else
loop(ci, a derive s(ci))

View File

@ -62,7 +62,8 @@ private[sbt] object TypeString {
val TypeMap = Map(
"java.io.File" -> "File",
"java.net.URL" -> "URL",
"java.net.URI" -> "URI")
"java.net.URI" -> "URI"
)
/**
* A Parser that extracts basic structure from the string representation of a type from Manifest.toString.

View File

@ -18,7 +18,8 @@ class ParserWithExamplesTest extends UnitSpec {
val _ = new ParserWithValidExamples {
val validCompletions = Completions(Set(
suggestion("blue"),
suggestion("red")))
suggestion("red")
))
parserWithExamples.completions(0) shouldEqual validCompletions
}
}
@ -27,7 +28,8 @@ class ParserWithExamplesTest extends UnitSpec {
"produce only valid examples that start with the character of the derivation" in {
val _ = new ParserWithValidExamples {
val derivedCompletions = Completions(Set(
suggestion("lue")))
suggestion("lue")
))
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
}
}
@ -45,7 +47,8 @@ class ParserWithExamplesTest extends UnitSpec {
val _ = new parserWithAllExamples {
val derivedCompletions = Completions(Set(
suggestion("lue"),
suggestion("lock")))
suggestion("lock")
))
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
}
}
@ -56,9 +59,11 @@ class ParserWithExamplesTest extends UnitSpec {
class parserWithAllExamples extends ParserExample(removeInvalidExamples = false)
case class ParserExample(examples: Iterable[String] = Set("blue", "yellow", "greeen", "block", "red"),
case class ParserExample(
examples: Iterable[String] = Set("blue", "yellow", "greeen", "block", "red"),
maxNumberOfExamples: Int = 25,
removeInvalidExamples: Boolean) {
removeInvalidExamples: Boolean
) {
import DefaultParsers._
@ -67,7 +72,8 @@ class ParserWithExamplesTest extends UnitSpec {
colorParser,
FixedSetExamples(examples),
maxNumberOfExamples,
removeInvalidExamples)
removeInvalidExamples
)
}
case class GrowableSourceOfExamples() extends Iterable[String] {

View File

@ -103,7 +103,8 @@ object Logic {
checkAcyclic(clauses)
problem.toLeft(
reduce0(clauses, initialFacts, Matched.empty))
reduce0(clauses, initialFacts, Matched.empty)
)
}
/**

View File

@ -20,7 +20,8 @@ object LogicTest extends Properties("Logic") {
case Right(res) => false
case Left(err: Logic.CyclicNegation) => true
case Left(err) => sys.error(s"Expected cyclic error, got: $err")
})
}
)
def expect(result: Either[LogicException, Matched], expected: Set[Atom]) = result match {
case Left(err) => false