summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-12-28 16:52:47 -0800
committerPaul Phillips <paulp@improving.org>2012-12-28 16:57:33 -0800
commit13643815fe41b17e931be9d0a8906200b0147a23 (patch)
treea9646c5c5b945049e248629ffb61099009b2d6ef /test
parent24a033b2aa4174fe8e9c3c02372b6508ef404601 (diff)
downloadscala-13643815fe41b17e931be9d0a8906200b0147a23.tar.gz
scala-13643815fe41b17e931be9d0a8906200b0147a23.tar.bz2
scala-13643815fe41b17e931be9d0a8906200b0147a23.zip
LinearSeq lengthCompare without an iterator.
Had to fix up an iffy test: not only was it testing undefined behavior, it demanded just the right numbers be printed in a context where all negative or positive numbers are equivalent. It's the ol' "get them coming and going" trick.
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t2544.check4
-rw-r--r--test/files/run/t2544.scala22
2 files changed, 16 insertions, 10 deletions
diff --git a/test/files/run/t2544.check b/test/files/run/t2544.check
index 716b146ac4..d19538dca3 100644
--- a/test/files/run/t2544.check
+++ b/test/files/run/t2544.check
@@ -2,8 +2,8 @@
2
3
3
--2
--2
+-1
+-1
1
1
0
diff --git a/test/files/run/t2544.scala b/test/files/run/t2544.scala
index 7e7cfeb357..6bee2f1082 100644
--- a/test/files/run/t2544.scala
+++ b/test/files/run/t2544.scala
@@ -1,19 +1,25 @@
object Test {
object Foo extends Seq[Int] {
def apply(i: Int) = i
- def length = 4
+ def length = 5
def iterator = Iterator(0,1,2,3,4)
}
+ def lengthEquiv(result: Int) = println(
+ if (result < 0) -1
+ else if (result == 0) 0
+ else 1
+ )
+
def main(args: Array[String]) = {
println(Foo indexWhere(_ >= 2,1))
println(Foo.toList indexWhere(_ >= 2,1))
println(Foo segmentLength(_ <= 3,1))
println(Foo.toList segmentLength(_ <= 3,1))
- println(Foo lengthCompare 7)
- println(Foo.toList lengthCompare 7)
- println(Foo lengthCompare 2)
- println(Foo.toList lengthCompare 2)
- println(Foo lengthCompare 5)
- println(Foo.toList lengthCompare 5)
+ lengthEquiv(Foo lengthCompare 7)
+ lengthEquiv(Foo.toList lengthCompare 7)
+ lengthEquiv(Foo lengthCompare 2)
+ lengthEquiv(Foo.toList lengthCompare 2)
+ lengthEquiv(Foo lengthCompare 5)
+ lengthEquiv(Foo.toList lengthCompare 5)
}
-} \ No newline at end of file
+}