summaryrefslogtreecommitdiff
path: root/test/files/run/sequenceComparisons.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-09-18 00:09:46 -0700
committerPaul Phillips <paulp@improving.org>2013-09-18 07:13:38 -0700
commitf4267ccd96a9143c910c66a5b0436aaa64b7c9dc (patch)
tree174861715807c23ba332f78769a9f7e1377b7f02 /test/files/run/sequenceComparisons.scala
parentd45a3c8cc8e9f1d95d797d548a85abd8597f5bc7 (diff)
downloadscala-f4267ccd96a9143c910c66a5b0436aaa64b7c9dc.tar.gz
scala-f4267ccd96a9143c910c66a5b0436aaa64b7c9dc.tar.bz2
scala-f4267ccd96a9143c910c66a5b0436aaa64b7c9dc.zip
Cull extraneous whitespace.
One last flurry with the broom before I leave you slobs to code in your own filth. Eliminated all the trailing whitespace I could manage, with special prejudice reserved for the test cases which depended on the preservation of trailing whitespace. Was reminded I cannot figure out how to eliminate the trailing space on the "scala> " prompt in repl transcripts. At least reduced the number of such empty prompts by trimming transcript code on the way in. Routed ConsoleReporter's "printMessage" through a trailing whitespace stripping method which might help futureproof against the future of whitespace diseases. Deleted the up-to-40 lines of trailing whitespace found in various library files. It seems like only yesterday we performed whitespace surgery on the whole repo. Clearly it doesn't stick very well. I suggest it would work better to enforce a few requirements on the way in.
Diffstat (limited to 'test/files/run/sequenceComparisons.scala')
-rw-r--r--test/files/run/sequenceComparisons.scala40
1 files changed, 20 insertions, 20 deletions
diff --git a/test/files/run/sequenceComparisons.scala b/test/files/run/sequenceComparisons.scala
index f8ef17d77d..613b37f45a 100644
--- a/test/files/run/sequenceComparisons.scala
+++ b/test/files/run/sequenceComparisons.scala
@@ -2,12 +2,12 @@ import scala.collection.{ mutable, immutable }
import collection.{ Seq, Traversable }
object Test {
- // TODO:
+ // TODO:
//
// SeqProxy
// SeqForwarder
// the commented out ones in seqMakers
-
+
val seqMakers = List[List[Int] => Seq[Int]](
// scala.Array(_: _*),
mutable.ArrayBuffer(_: _*),
@@ -23,13 +23,13 @@ object Test {
immutable.Seq(_: _*),
mutable.Seq(_: _*),
immutable.Stack(_: _*),
- // mutable.Stack(_: _*),
+ // mutable.Stack(_: _*),
immutable.IndexedSeq(_: _*), // was Vector
//mutable.Vector(_: _*),
immutable.List(_: _*),
immutable.Stream(_: _*)
)
-
+
abstract class Data[T] {
val seq: Seq[T]
private def seqList = seq.toList
@@ -45,50 +45,50 @@ object Test {
}
lazy val eqeq = Method(_ == _, (List(seqList), List(Nil, seqList drop 1, seqList ::: seqList)), "%s == %s")
-
+
val startsWithInputs: Inputs
lazy val startsWith = Method(_ startsWith _, startsWithInputs, "%s startsWith %s")
-
+
val endsWithInputs: Inputs
lazy val endsWith = Method(_ endsWith _, endsWithInputs, "%s endsWith %s")
val indexOfSliceInputs: Inputs
private def subseqTest(s1: Seq[T], s2: Seq[T]) = (s1 indexOfSlice s2) != -1
lazy val indexOfSlice = Method(subseqTest _, indexOfSliceInputs, "(%s indexOfSlice %s) != -1")
-
+
val sameElementsInputs: Inputs
lazy val sameElements = Method(_ sameElements _, sameElementsInputs, "%s sameElements %s")
-
+
def methodList = List(eqeq, startsWith, endsWith, indexOfSlice, sameElements)
}
-
+
object test1 extends Data[Int] {
val seq = List(1,2,3,4,5)
-
+
val startsWithInputs = (
List(Nil, List(1), List(1,2), seq),
List(List(1,2,3,4,6), seq ::: List(5), List(0))
)
-
+
val endsWithInputs = (
List(Nil, List(5), List(4,5), seq),
List(0 :: seq, List(5,2,3,4,5), List(3,4), List(5,6))
)
-
+
val indexOfSliceInputs = (
List(Nil, List(1), List(3), List(5), List(1,2), List(2,3,4), List(4,5), seq),
List(List(1,2,3,5), List(6), List(5,4,3,2,1), List(2,1))
)
-
+
val sameElementsInputs = (
List(List(1,2,3,4,5)),
List(Nil, List(1), List(1,2), List(2,3,4), List(2,3,4,5), List(2,3,4,5,1), List(1,2,3,5,4), seq.reverse)
)
}
-
+
val failures = new mutable.ListBuffer[String]
var testCount = 0
-
+
def assertOne(op1: Any, op2: Any, res: Boolean, str: String) {
testCount += 1
val resStr = str.format(op1, op2)
@@ -97,25 +97,25 @@ object Test {
failures += ("FAIL: " + resStr)
// assert(res, resStr)
}
-
+
def runSeqs() = {
for (s1f <- seqMakers ; s2f <- seqMakers ; testData <- List(test1)) {
import testData._
val scrut = s1f(seq)
-
+
for (Method(f, (trueList, falseList), descr) <- methodList) {
for (s <- trueList; rhs = s2f(s))
assertOne(scrut, rhs, f(scrut, rhs), descr)
-
+
for (s <- falseList; rhs = s2f(s))
assertOne(scrut, rhs, !f(scrut, rhs), "!(" + descr + ")")
}
}
}
-
+
def main(args: Array[String]) {
runSeqs()
-
+
assert(failures.isEmpty, failures mkString "\n")
}
}