From e239d7fa5b9de5edffb06022c4cc5a9c105a51d3 Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Wed, 26 May 2010 14:14:12 +0000 Subject: svnmerge + tags --- test/files/run/bug2958.scala | 16 +++++++++++++ test/files/run/bug3050.scala | 9 ++++++++ test/files/run/bug3395.check | 2 ++ test/files/run/bug3395.scala | 13 +++++++++++ test/files/run/colltest1.scala | 6 +++-- test/files/run/equality.scala | 2 ++ test/files/run/groupby.scala | 18 +++++++++++++++ test/files/run/iterator3444.scala | 23 +++++++++++++++++++ test/files/run/matcharraytail.check | 2 +- test/files/run/nodebuffer-array.check | 3 +++ test/files/run/nodebuffer-array.scala | 15 ++++++++++++ test/files/run/patmat-seqs.check | 13 +++++++++++ test/files/run/patmat-seqs.scala | 42 ++++++++++++++++++++++++++++++++++ test/files/run/spec-ame.check | 2 ++ test/files/run/spec-ame.scala | 17 ++++++++++++++ test/files/run/spec-overrides.check | 0 test/files/run/spec-overrides.scala | 20 ++++++++++++++++ test/files/run/unittest_iterator.scala | 9 +++++--- 18 files changed, 206 insertions(+), 6 deletions(-) create mode 100644 test/files/run/bug2958.scala create mode 100644 test/files/run/bug3050.scala create mode 100644 test/files/run/bug3395.check create mode 100644 test/files/run/bug3395.scala create mode 100644 test/files/run/groupby.scala create mode 100644 test/files/run/iterator3444.scala create mode 100644 test/files/run/nodebuffer-array.check create mode 100644 test/files/run/nodebuffer-array.scala create mode 100644 test/files/run/patmat-seqs.check create mode 100644 test/files/run/patmat-seqs.scala create mode 100644 test/files/run/spec-ame.check create mode 100644 test/files/run/spec-ame.scala create mode 100644 test/files/run/spec-overrides.check create mode 100644 test/files/run/spec-overrides.scala (limited to 'test/files/run') diff --git a/test/files/run/bug2958.scala b/test/files/run/bug2958.scala new file mode 100644 index 0000000000..dcd24ecc36 --- /dev/null +++ b/test/files/run/bug2958.scala @@ -0,0 +1,16 @@ +object Test { + def f(args: Array[String]) = args match { + case Array("-p", prefix, from, to) => + prefix + from + to + + case Array(from, to) => + from + to + + case _ => + "default" + } + + def main(args: Array[String]) { + assert(f(Array("1", "2")) == "12") + } +} \ No newline at end of file diff --git a/test/files/run/bug3050.scala b/test/files/run/bug3050.scala new file mode 100644 index 0000000000..aaec99ec14 --- /dev/null +++ b/test/files/run/bug3050.scala @@ -0,0 +1,9 @@ +object Test { + def main(args: Array[String]): Unit = { + val x = + try { ("": Any) match { case List(_*) => true } } + catch { case _ => false } + + assert(x == false) + } +} diff --git a/test/files/run/bug3395.check b/test/files/run/bug3395.check new file mode 100644 index 0000000000..5f5521fae2 --- /dev/null +++ b/test/files/run/bug3395.check @@ -0,0 +1,2 @@ +abc +def diff --git a/test/files/run/bug3395.scala b/test/files/run/bug3395.scala new file mode 100644 index 0000000000..b4990a1716 --- /dev/null +++ b/test/files/run/bug3395.scala @@ -0,0 +1,13 @@ +object Test { + def main(args: Array[String]): Unit = { + Seq("") match { + case Seq("") => println("abc") + case Seq(_, _, x) => println(x) + } + + Seq(1, 2, "def") match { + case Seq("") => println("abc") + case Seq(_, _, x) => println(x) + } + } +} \ No newline at end of file diff --git a/test/files/run/colltest1.scala b/test/files/run/colltest1.scala index 557282cb8d..943fe4c4e7 100644 --- a/test/files/run/colltest1.scala +++ b/test/files/run/colltest1.scala @@ -2,8 +2,7 @@ import collection._ object Test extends Application { - def orderedTraversableTest(empty: Traversable[Int]) - { + def orderedTraversableTest(empty: Traversable[Int]) { println("new test starting with "+empty) assert(empty.isEmpty) val ten = empty ++ List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) @@ -113,6 +112,9 @@ object Test extends Application { assert(ten.endsWith(List(9, 10))) assert(ten.endsWith(List())) assert(ten.indexOfSlice(List(3, 4, 5)) == 2, ten.indexOfSlice(List(3, 4, 5))) + assert(ten.lastIndexOfSlice(List(8, 9, 10)) == 7) + assert(ten.lastIndexOfSlice(List(1, 2, 3)) == 0) + assert(ten.lastIndexOfSlice(List(9, 10, 11)) == -1) assert(ten contains 1) assert(ten contains 10) assert(!(ten contains 0)) diff --git a/test/files/run/equality.scala b/test/files/run/equality.scala index 6498b232e1..ff59898821 100644 --- a/test/files/run/equality.scala +++ b/test/files/run/equality.scala @@ -34,5 +34,7 @@ object Test // negatives val bigLong = new java.util.concurrent.atomic.AtomicLong(Long.MaxValue) assert(-1 != bigLong && bigLong != -1) // bigLong.intValue() == -1 + assert(BigDecimal(1.1) != 1L) + assert(1L != BigDecimal(1.1)) } } diff --git a/test/files/run/groupby.scala b/test/files/run/groupby.scala new file mode 100644 index 0000000000..a751e65e80 --- /dev/null +++ b/test/files/run/groupby.scala @@ -0,0 +1,18 @@ + + + +// Fixes #3422 +object Test { + + def main(args: Array[String]) { + val arr = Array.range(0,10) + val map = arr groupBy (_%2) + val v1 = map(0) + val v2 = map(0) + // this should hold, of course, assuming also that group by returns a regular + // map implementation, and does nothing fancy - and it should return just a + // hash map by default. + assert(v1 eq v2) + } + +} diff --git a/test/files/run/iterator3444.scala b/test/files/run/iterator3444.scala new file mode 100644 index 0000000000..1d0713addc --- /dev/null +++ b/test/files/run/iterator3444.scala @@ -0,0 +1,23 @@ + + +// ticked #3444 +object Test { + + def main(args: Array[String]) { + val it = (1 to 12).toSeq.iterator + + assert(it.next == 1) + assert(it.take(2).toList == List(2, 3)) + + val jt = (4 to 12).toSeq.iterator + assert(jt.next == 4) + assert(jt.drop(5).toList == List(10, 11, 12)) + + val kt = (1 until 10).toSeq.iterator + assert(kt.drop(50).toList == Nil) + + val mt = (1 until 5).toSeq.iterator + assert(mt.take(50).toList == List(1, 2, 3, 4)) + } + +} diff --git a/test/files/run/matcharraytail.check b/test/files/run/matcharraytail.check index 15381501a9..f2844d41a9 100644 --- a/test/files/run/matcharraytail.check +++ b/test/files/run/matcharraytail.check @@ -1,2 +1,2 @@ Array(foo, bar, baz) -ArrayBuffer(bar, baz) +Vector(bar, baz) diff --git a/test/files/run/nodebuffer-array.check b/test/files/run/nodebuffer-array.check new file mode 100644 index 0000000000..49f8bfaf8d --- /dev/null +++ b/test/files/run/nodebuffer-array.check @@ -0,0 +1,3 @@ + + abc + diff --git a/test/files/run/nodebuffer-array.scala b/test/files/run/nodebuffer-array.scala new file mode 100644 index 0000000000..f9cfbc50df --- /dev/null +++ b/test/files/run/nodebuffer-array.scala @@ -0,0 +1,15 @@ +object Test { + + def f(s: String) = { + + { + for (item <- s split ',') yield + { item } + } + + } + + def main(args: Array[String]): Unit = { + println(f("a,b,c")) + } +} diff --git a/test/files/run/patmat-seqs.check b/test/files/run/patmat-seqs.check new file mode 100644 index 0000000000..bb2a5ee44a --- /dev/null +++ b/test/files/run/patmat-seqs.check @@ -0,0 +1,13 @@ +s3 +s2 +s1 +s0 +ss6 +d +s3 +s3 +d +s1 +s3 +d +d diff --git a/test/files/run/patmat-seqs.scala b/test/files/run/patmat-seqs.scala new file mode 100644 index 0000000000..b5c47b4b4b --- /dev/null +++ b/test/files/run/patmat-seqs.scala @@ -0,0 +1,42 @@ +object Test { + def f1(x: Any) = x match { + case Seq(1, 2, 3) => "s3" + case Seq(4, 5) => "s2" + case Seq(7) => "s1" + case Nil => "s0" + case Seq(_, _, _, _, _, x: String) => "ss6" + case _ => "d" + } + + def f2(x: Any) = x match { + case Seq("a", "b", _*) => "s2" + case Seq(1, _*) => "s1" + case Seq(5, 6, 7, _*) => "s3" + case _ => "d" + } + + def main(args: Array[String]): Unit = { + val xs1 = List( + List(1,2,3), + List(4,5), + Vector(7), + Seq(), + Seq(1, 2, 3, 4, 5, "abcd"), + "abc" + ) map f1 + + xs1 foreach println + + val xs2 = List( + Seq(5, 6, 7), + Seq(5, 6, 7, 8, 9), + Seq("a"), + Seq(1, 6, 7), + List(5, 6, 7), + Nil, + 5 + ) map f2 + + xs2 foreach println + } +} diff --git a/test/files/run/spec-ame.check b/test/files/run/spec-ame.check new file mode 100644 index 0000000000..afa12db4df --- /dev/null +++ b/test/files/run/spec-ame.check @@ -0,0 +1,2 @@ +abc +10 diff --git a/test/files/run/spec-ame.scala b/test/files/run/spec-ame.scala new file mode 100644 index 0000000000..86c47077f0 --- /dev/null +++ b/test/files/run/spec-ame.scala @@ -0,0 +1,17 @@ +// ticket #3432 +object Test { + trait B[@specialized(Int) T] { + def value: T + } + + class A[@specialized(Int) T](x: T) { + def foo: B[T] = new B[T] { + def value = x + } + } + + def main(args: Array[String]) { + println((new A("abc")).foo.value) + println((new A(10)).foo.value) + } +} diff --git a/test/files/run/spec-overrides.check b/test/files/run/spec-overrides.check new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/files/run/spec-overrides.scala b/test/files/run/spec-overrides.scala new file mode 100644 index 0000000000..f5d2e2f9c7 --- /dev/null +++ b/test/files/run/spec-overrides.scala @@ -0,0 +1,20 @@ + trait Base[@specialized(Double) B] { + def default: B; + } + + trait D1 extends Base[Double] { + override def default = 0.0; + } + + class D2 extends D1 { + override def default: Double = 1.0; + } + + +object Test extends Application { + val d2 = new D2 + + assert(d2.default == 1.0, d2.default) + assert((d2: Base[_]).default == 1.0, (d2: Base[_]).default) + assert((d2: D1).default == 1.0, (d2: D1).default) +} diff --git a/test/files/run/unittest_iterator.scala b/test/files/run/unittest_iterator.scala index 28a548160f..21dc64c3c5 100644 --- a/test/files/run/unittest_iterator.scala +++ b/test/files/run/unittest_iterator.scala @@ -1,6 +1,5 @@ // Some iterator grouped/sliding unit tests -object Test -{ +object Test { def it = (1 to 10).iterator def assertThat[T](expectedLength: Int, expectedLast: Seq[T])(it: Iterator[Seq[T]]) { val xs = it.toList @@ -34,7 +33,11 @@ object Test assertThat(2, List(9, 10, -1, -1, -1)) { it.sliding(5, 8) withPadding -1 } assertThat(1, (1 to 5).toList) { it.sliding(5, 8) withPartial false } - // make sure it throws past th end + // larger step than window + assertThat(5, List(9)) { it.sliding(1, 2) } + assertThat(3, List(9, 10)) { it.sliding(2, 4) } + + // make sure it throws past the end val thrown = try { val it = List(1,2,3).sliding(2) it.next -- cgit v1.2.3