mirror of https://github.com/sbt/sbt.git
Merge pull request #13 from sbt/wip/packagenames2
package name change and test migration
This commit is contained in:
commit
ac8c3aefdd
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import Classes.Applicative
|
||||
import Types._
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
import scala.reflect.Manifest
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
object Classes {
|
||||
trait Applicative[M[_]] {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009, 2010 David MacIver, Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
trait Dag[Node <: Dag[Node]] {
|
||||
self: Node =>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
/** A mutable set interface that uses object identity to test for set membership.*/
|
||||
trait IDSet[T] {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import java.lang.Runnable
|
||||
import java.util.concurrent.{ atomic, Executor, LinkedBlockingQueue }
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
import Classes.Applicative
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import collection.mutable
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
sealed trait SourcePosition
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
trait Show[T] {
|
||||
def apply(t: T): String
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
trait ShowLines[A] {
|
||||
def showLines(a: A): Seq[String]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
object Signals {
|
||||
val CONT = "CONT"
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
trait TypeFunctions {
|
||||
type Id[X] = X
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
object Types extends Types
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import java.util.Locale
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008 Mark Harrah */
|
||||
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import org.scalacheck._
|
||||
import Prop._
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import org.scalacheck._
|
||||
import Prop._
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import Types._
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
/** Define our settings system */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import org.scalacheck._
|
||||
import Prop._
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
|
||||
import jline.console.ConsoleReader
|
||||
import jline.console.history.{ FileHistory, MemoryHistory }
|
||||
|
|
@ -128,7 +128,7 @@ final class FullReader(historyPath: Option[File], complete: Parser[_], val handl
|
|||
protected[this] val reader =
|
||||
{
|
||||
val cr = JLine.createReader(historyPath)
|
||||
sbt.util.internal.complete.JLineCompletion.installCustomCompletor(cr, complete)
|
||||
sbt.internal.util.complete.JLineCompletion.installCustomCompletor(cr, complete)
|
||||
cr
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
/**
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import java.lang.Character.{ toLowerCase => lower }
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import java.io.File
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import History.number
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import java.io.File
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import jline.console.ConsoleReader
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2010, 2011 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import Parser._
|
||||
import sbt.util.internal.Types.{ left, right, some }
|
||||
import sbt.util.internal.Util.{ makeList, separate }
|
||||
import sbt.internal.util.Types.{ left, right, some }
|
||||
import sbt.internal.util.Util.{ makeList, separate }
|
||||
|
||||
/**
|
||||
* A String parser that provides semi-automatic tab completion.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2011 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import Parser._
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
object ProcessError {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import Completion.{ token => ctoken, tokenDisplay }
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import DefaultParsers._
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008,2010 Mark Harrah
|
||||
*/
|
||||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
sealed trait UpperBound {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
object JLineTest {
|
||||
|
|
|
|||
|
|
@ -1,54 +1,60 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import org.specs2.mutable.Specification
|
||||
import org.specs2.specification.Scope
|
||||
import java.io.File
|
||||
import sbt.io.IO._
|
||||
|
||||
class FileExamplesTest extends Specification {
|
||||
class FileExamplesTest extends UnitSpec {
|
||||
|
||||
"listing all files in an absolute base directory" should {
|
||||
"produce the entire base directory's contents" in new directoryStructure {
|
||||
fileExamples().toList should containTheSameElementsAs(allRelativizedPaths)
|
||||
"listing all files in an absolute base directory" should
|
||||
"produce the entire base directory's contents" in {
|
||||
val _ = new DirectoryStructure {
|
||||
fileExamples().toList should contain theSameElementsAs (allRelativizedPaths)
|
||||
}
|
||||
}
|
||||
|
||||
"listing files with a prefix that matches none" should
|
||||
"produce an empty list" in {
|
||||
val _ = new DirectoryStructure(withCompletionPrefix = "z") {
|
||||
fileExamples().toList shouldBe empty
|
||||
}
|
||||
}
|
||||
|
||||
"listing single-character prefixed files" should
|
||||
"produce matching paths only" in {
|
||||
val _ = new DirectoryStructure(withCompletionPrefix = "f") {
|
||||
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
|
||||
}
|
||||
}
|
||||
|
||||
"listing directory-prefixed files" should
|
||||
"produce matching paths only" in {
|
||||
val _ = new DirectoryStructure(withCompletionPrefix = "far") {
|
||||
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
|
||||
}
|
||||
}
|
||||
|
||||
it should "produce sub-dir contents only when appending a file separator to the directory" in {
|
||||
val _ = new DirectoryStructure(withCompletionPrefix = "far" + File.separator) {
|
||||
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
|
||||
}
|
||||
}
|
||||
|
||||
"listing files with a prefix that matches none" should {
|
||||
"produce an empty list" in new directoryStructure(withCompletionPrefix = "z") {
|
||||
fileExamples().toList should beEmpty
|
||||
}
|
||||
}
|
||||
|
||||
"listing single-character prefixed files" should {
|
||||
"produce matching paths only" in new directoryStructure(withCompletionPrefix = "f") {
|
||||
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
|
||||
}
|
||||
}
|
||||
|
||||
"listing directory-prefixed files" should {
|
||||
"produce matching paths only" in new directoryStructure(withCompletionPrefix = "far") {
|
||||
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
|
||||
"listing files with a sub-path prefix" should
|
||||
"produce matching paths only" in {
|
||||
val _ = new DirectoryStructure(withCompletionPrefix = "far" + File.separator + "ba") {
|
||||
fileExamples().toList should contain theSameElementsAs (prefixedPathsOnly)
|
||||
}
|
||||
}
|
||||
|
||||
"produce sub-dir contents only when appending a file separator to the directory" in new directoryStructure(withCompletionPrefix = "far" + File.separator) {
|
||||
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
|
||||
"completing a full path" should
|
||||
"produce a list with an empty string" in {
|
||||
val _ = new DirectoryStructure(withCompletionPrefix = "bazaar") {
|
||||
fileExamples().toList shouldEqual List("")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"listing files with a sub-path prefix" should {
|
||||
"produce matching paths only" in new directoryStructure(withCompletionPrefix = "far" + File.separator + "ba") {
|
||||
fileExamples().toList should containTheSameElementsAs(prefixedPathsOnly)
|
||||
}
|
||||
}
|
||||
|
||||
"completing a full path" should {
|
||||
"produce a list with an empty string" in new directoryStructure(withCompletionPrefix = "bazaar") {
|
||||
fileExamples().toList shouldEqual List("")
|
||||
}
|
||||
}
|
||||
|
||||
class directoryStructure(withCompletionPrefix: String = "") extends Scope with DelayedInit {
|
||||
class DirectoryStructure(withCompletionPrefix: String = "") extends DelayedInit {
|
||||
var fileExamples: FileExamples = _
|
||||
var baseDir: File = _
|
||||
var childFiles: List[File] = _
|
||||
|
|
|
|||
|
|
@ -1,26 +1,23 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import org.specs2.mutable.Specification
|
||||
import org.specs2.specification.Scope
|
||||
class FixedSetExamplesTest extends UnitSpec {
|
||||
|
||||
class FixedSetExamplesTest extends Specification {
|
||||
|
||||
"adding a prefix" should {
|
||||
"produce a smaller set of examples with the prefix removed" in new examples {
|
||||
fixedSetExamples.withAddedPrefix("f")() must containTheSameElementsAs(List("oo", "ool", "u"))
|
||||
fixedSetExamples.withAddedPrefix("fo")() must containTheSameElementsAs(List("o", "ol"))
|
||||
fixedSetExamples.withAddedPrefix("b")() must containTheSameElementsAs(List("ar"))
|
||||
"adding a prefix" should "produce a smaller set of examples with the prefix removed" in {
|
||||
val _ = new Examples {
|
||||
fixedSetExamples.withAddedPrefix("f")() should contain theSameElementsAs (List("oo", "ool", "u"))
|
||||
fixedSetExamples.withAddedPrefix("fo")() should contain theSameElementsAs (List("o", "ol"))
|
||||
fixedSetExamples.withAddedPrefix("b")() should contain theSameElementsAs (List("ar"))
|
||||
}
|
||||
}
|
||||
|
||||
"without a prefix" should {
|
||||
"produce the original set" in new examples {
|
||||
fixedSetExamples() mustEqual exampleSet
|
||||
"without a prefix" should "produce the original set" in {
|
||||
val _ = new Examples {
|
||||
fixedSetExamples() shouldBe exampleSet
|
||||
}
|
||||
}
|
||||
|
||||
trait examples extends Scope {
|
||||
trait Examples {
|
||||
val exampleSet = List("foo", "bar", "fool", "fu")
|
||||
val fixedSetExamples = FixedSetExamples(exampleSet)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,61 +1,64 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package complete
|
||||
|
||||
import org.specs2.mutable.Specification
|
||||
import org.specs2.specification.Scope
|
||||
import Completion._
|
||||
|
||||
class ParserWithExamplesTest extends Specification {
|
||||
class ParserWithExamplesTest extends UnitSpec {
|
||||
|
||||
"listing a limited number of completions" should {
|
||||
"grab only the needed number of elements from the iterable source of examples" in new parserWithLazyExamples {
|
||||
parserWithExamples.completions(0)
|
||||
examples.size shouldEqual maxNumberOfExamples
|
||||
"listing a limited number of completions" should
|
||||
"grab only the needed number of elements from the iterable source of examples" in {
|
||||
val _ = new ParserWithLazyExamples {
|
||||
parserWithExamples.completions(0)
|
||||
examples.size shouldEqual maxNumberOfExamples
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"listing only valid completions" should {
|
||||
"use the delegate parser to remove invalid examples" in new parserWithValidExamples {
|
||||
val validCompletions = Completions(Set(
|
||||
suggestion("blue"),
|
||||
suggestion("red")))
|
||||
parserWithExamples.completions(0) shouldEqual validCompletions
|
||||
"listing only valid completions" should
|
||||
"use the delegate parser to remove invalid examples" in {
|
||||
val _ = new ParserWithValidExamples {
|
||||
val validCompletions = Completions(Set(
|
||||
suggestion("blue"),
|
||||
suggestion("red")))
|
||||
parserWithExamples.completions(0) shouldEqual validCompletions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"listing valid completions in a derived parser" should {
|
||||
"produce only valid examples that start with the character of the derivation" in new parserWithValidExamples {
|
||||
val derivedCompletions = Completions(Set(
|
||||
suggestion("lue")))
|
||||
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
|
||||
"listing valid completions in a derived parser" should
|
||||
"produce only valid examples that start with the character of the derivation" in {
|
||||
val _ = new ParserWithValidExamples {
|
||||
val derivedCompletions = Completions(Set(
|
||||
suggestion("lue")))
|
||||
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"listing valid and invalid completions" should {
|
||||
"produce the entire source of examples" in new parserWithAllExamples {
|
||||
val completions = Completions(examples.map(suggestion(_)).toSet)
|
||||
parserWithExamples.completions(0) shouldEqual completions
|
||||
"listing valid and invalid completions" should
|
||||
"produce the entire source of examples" in {
|
||||
val _ = new parserWithAllExamples {
|
||||
val completions = Completions(examples.map(suggestion(_)).toSet)
|
||||
parserWithExamples.completions(0) shouldEqual completions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"listing valid and invalid completions in a derived parser" should {
|
||||
"produce only examples that start with the character of the derivation" in new parserWithAllExamples {
|
||||
val derivedCompletions = Completions(Set(
|
||||
suggestion("lue"),
|
||||
suggestion("lock")))
|
||||
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
|
||||
"listing valid and invalid completions in a derived parser" should
|
||||
"produce only examples that start with the character of the derivation" in {
|
||||
val _ = new parserWithAllExamples {
|
||||
val derivedCompletions = Completions(Set(
|
||||
suggestion("lue"),
|
||||
suggestion("lock")))
|
||||
parserWithExamples.derive('b').completions(0) shouldEqual derivedCompletions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class parserWithLazyExamples extends parser(GrowableSourceOfExamples(), maxNumberOfExamples = 5, removeInvalidExamples = false)
|
||||
class ParserWithLazyExamples extends ParserExample(GrowableSourceOfExamples(), maxNumberOfExamples = 5, removeInvalidExamples = false)
|
||||
|
||||
class parserWithValidExamples extends parser(removeInvalidExamples = true)
|
||||
class ParserWithValidExamples extends ParserExample(removeInvalidExamples = true)
|
||||
|
||||
class parserWithAllExamples extends parser(removeInvalidExamples = false)
|
||||
class parserWithAllExamples extends ParserExample(removeInvalidExamples = false)
|
||||
|
||||
case class parser(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) extends Scope {
|
||||
removeInvalidExamples: Boolean) {
|
||||
|
||||
import DefaultParsers._
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package logic
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sbt.util.internal
|
||||
package sbt.internal.util
|
||||
package logic
|
||||
|
||||
import org.scalacheck._
|
||||
|
|
|
|||
Loading…
Reference in New Issue