From 9c0e58c48da4cdbae7c96ef45fc15cd7aff4301f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 28 Sep 2010 00:51:25 +0000 Subject: Cleaning up the contents of test. including "CheckEither", written against scalacheck 1.2 in the year 471 AD. Removed all the duplicates I could find, mostly between pending and files. Renamed a bunch of tests so they wouldn't look like likely duplicates next time around. Nominated somebody else to do this once in a while. No review. --- test/files/jvm/unittest_io.scala | 24 --- test/files/jvm/unittest_io_Jvm.scala | 24 +++ test/files/pos/bug0325.scala | 4 - test/files/pos/bug1210.scala | 28 --- test/files/pos/bug1241.scala | 8 - test/files/pos/bug1909b-pos.scala | 6 + test/files/pos/bug1909b.scala | 6 - test/files/pos/bug284-pos.scala | 5 + test/files/pos/bug284.scala | 5 - test/files/pos/bug3175-pos.scala | 7 + test/files/pos/bug3175.scala | 7 - test/files/pos/bug3636.scala | 49 +++++ test/files/pos/cyclics-pos.scala | 26 +++ test/files/pos/cyclics.scala | 26 --- test/files/pos/depmet_1.flags | 1 - test/files/pos/depmet_1.scala | 6 - test/files/pos/depmet_1_pos.flags | 1 + test/files/pos/depmet_1_pos.scala | 6 + test/files/pos/exceptions.scala | 20 -- test/files/pos/imp2-pos.scala | 5 + test/files/pos/imp2.scala | 5 - test/files/pos/imports-pos.scala | 16 ++ test/files/pos/imports.scala | 16 -- test/files/pos/infer2-pos.scala | 8 + test/files/pos/infer2.scala | 8 - test/files/pos/misc-unapply_pos.scala | 27 +++ test/files/pos/pos-bug1210.scala | 28 +++ test/files/pos/pos-bug1241.scala | 8 + test/files/pos/simple-exceptions.scala | 20 ++ test/files/pos/t1422.scala | 2 - test/files/pos/t1422_pos.scala | 2 + test/files/pos/t1591.scala | 7 - test/files/pos/t1591_pos.scala | 7 + test/files/pos/t2208.scala | 8 - test/files/pos/t2208_pos.scala | 8 + test/files/pos/t2421b.scala | 19 -- test/files/pos/t2421b_pos.scala | 19 ++ test/files/pos/t2726/bug2726_2.scala | 3 + test/files/pos/t2726/test_2.scala | 3 - test/files/pos/t2868/t2868_src_2.scala | 6 + test/files/pos/t2868/test_2.scala | 6 - test/files/pos/tcpoly_variance.scala | 7 - test/files/pos/tcpoly_variance_pos.scala | 7 + test/files/pos/test2.scala | 5 - test/files/pos/typerep.scala | 21 -- test/files/pos/typerep_pos.scala | 21 ++ test/files/pos/unapply.scala | 27 --- test/files/pos/variances.scala | 8 - test/files/pos/variances_pos.scala | 8 + test/files/run/bug3150.scala | 10 + test/files/run/lazy-override-run.check | 3 + test/files/run/lazy-override-run.scala | 26 +++ test/files/run/lazy-override.check | 3 - test/files/run/lazy-override.scala | 26 --- test/files/run/lists-run.scala | 210 +++++++++++++++++++ test/files/run/lists.scala | 210 ------------------- test/files/run/t2316.scala | 32 --- test/files/run/t2316_run.scala | 32 +++ test/files/scalacheck/CheckEither.scala | 194 +++++++++++++++++ test/files/scalacheck/array.scala | 37 ++++ test/files/scalacheck/list.scala | 21 ++ test/files/scalacheck/primitive-eqeq.scala | 37 ++++ test/files/scalacheck/range.scala | 206 ++++++++++++++++++ test/files/scalacheck/scan.scala | 17 ++ test/files/scalacheck/substringTests.scala | 21 ++ test/files/scalacheck/test2.scala | 21 -- test/partest-tests/jvm/actor-receivewithin.check | 16 -- test/partest-tests/jvm/actor-receivewithin.scala | 69 ------- test/partest-tests/run/crash.scala | 6 - test/partest-tests/run/streamWithFilter.check | 5 - test/partest-tests/run/streamWithFilter.scala | 11 - test/partest-tests/run/timeout.scala | 5 - test/pending/neg/t1477.scala | 25 --- test/pending/pos/bug2018.scala | 15 -- test/pending/pos/bug3420.flags | 1 - test/pending/pos/bug3420.scala | 5 - test/pending/pos/bug563.scala | 7 - test/pending/pos/foo.scala | 3 - test/pending/pos/t0716.scala | 24 --- test/pending/pos/t2162.scala | 20 -- test/pending/pos/t2179.scala | 6 - test/pending/pos/t2635.scala | 16 -- test/pending/pos/t2641.scala | 16 -- test/pending/pos/t3636.scala | 49 ----- test/pending/run/bug1006.scala | 13 -- test/pending/run/bug2087.scala | 8 - test/pending/run/bug2365/Test.scala | 35 ---- test/pending/run/bug2365/bug2365.javaopts | 1 - test/pending/run/bug2365/run | 13 -- test/pending/run/bug3150.scala | 10 - test/pending/run/castsingleton.scala | 10 - test/pending/run/t0807.scala | 5 - test/pending/run/t1939.scala | 41 ---- test/pending/scalacheck/CheckEither.scala | 253 ----------------------- test/pending/scalacheck/array.scala | 37 ---- test/pending/scalacheck/eqeq.scala | 37 ---- test/pending/scalacheck/list.scala | 21 -- test/pending/scalacheck/range.scala | 205 ------------------ test/pending/scalacheck/scan.scala | 17 -- test/pending/script/bug2365.sh | 13 ++ test/pending/script/error-messages.check | 7 + test/pending/script/error-messages.scala | 9 + test/pending/script/errors.check | 7 - test/pending/script/errors.scala | 9 - 104 files changed, 1160 insertions(+), 1590 deletions(-) delete mode 100644 test/files/jvm/unittest_io.scala create mode 100644 test/files/jvm/unittest_io_Jvm.scala delete mode 100644 test/files/pos/bug0325.scala delete mode 100644 test/files/pos/bug1210.scala delete mode 100644 test/files/pos/bug1241.scala create mode 100644 test/files/pos/bug1909b-pos.scala delete mode 100644 test/files/pos/bug1909b.scala create mode 100644 test/files/pos/bug284-pos.scala delete mode 100644 test/files/pos/bug284.scala create mode 100644 test/files/pos/bug3175-pos.scala delete mode 100644 test/files/pos/bug3175.scala create mode 100644 test/files/pos/bug3636.scala create mode 100644 test/files/pos/cyclics-pos.scala delete mode 100644 test/files/pos/cyclics.scala delete mode 100644 test/files/pos/depmet_1.flags delete mode 100644 test/files/pos/depmet_1.scala create mode 100644 test/files/pos/depmet_1_pos.flags create mode 100644 test/files/pos/depmet_1_pos.scala delete mode 100644 test/files/pos/exceptions.scala create mode 100644 test/files/pos/imp2-pos.scala delete mode 100644 test/files/pos/imp2.scala create mode 100644 test/files/pos/imports-pos.scala delete mode 100644 test/files/pos/imports.scala create mode 100644 test/files/pos/infer2-pos.scala delete mode 100644 test/files/pos/infer2.scala create mode 100644 test/files/pos/misc-unapply_pos.scala create mode 100644 test/files/pos/pos-bug1210.scala create mode 100644 test/files/pos/pos-bug1241.scala create mode 100644 test/files/pos/simple-exceptions.scala delete mode 100644 test/files/pos/t1422.scala create mode 100644 test/files/pos/t1422_pos.scala delete mode 100644 test/files/pos/t1591.scala create mode 100644 test/files/pos/t1591_pos.scala delete mode 100644 test/files/pos/t2208.scala create mode 100644 test/files/pos/t2208_pos.scala delete mode 100644 test/files/pos/t2421b.scala create mode 100644 test/files/pos/t2421b_pos.scala create mode 100644 test/files/pos/t2726/bug2726_2.scala delete mode 100644 test/files/pos/t2726/test_2.scala create mode 100644 test/files/pos/t2868/t2868_src_2.scala delete mode 100644 test/files/pos/t2868/test_2.scala delete mode 100644 test/files/pos/tcpoly_variance.scala create mode 100644 test/files/pos/tcpoly_variance_pos.scala delete mode 100644 test/files/pos/test2.scala delete mode 100644 test/files/pos/typerep.scala create mode 100644 test/files/pos/typerep_pos.scala delete mode 100644 test/files/pos/unapply.scala delete mode 100644 test/files/pos/variances.scala create mode 100644 test/files/pos/variances_pos.scala create mode 100644 test/files/run/bug3150.scala create mode 100644 test/files/run/lazy-override-run.check create mode 100644 test/files/run/lazy-override-run.scala delete mode 100644 test/files/run/lazy-override.check delete mode 100644 test/files/run/lazy-override.scala create mode 100644 test/files/run/lists-run.scala delete mode 100644 test/files/run/lists.scala delete mode 100644 test/files/run/t2316.scala create mode 100644 test/files/run/t2316_run.scala create mode 100644 test/files/scalacheck/CheckEither.scala create mode 100644 test/files/scalacheck/array.scala create mode 100644 test/files/scalacheck/list.scala create mode 100644 test/files/scalacheck/primitive-eqeq.scala create mode 100644 test/files/scalacheck/range.scala create mode 100644 test/files/scalacheck/scan.scala create mode 100644 test/files/scalacheck/substringTests.scala delete mode 100644 test/files/scalacheck/test2.scala delete mode 100644 test/partest-tests/jvm/actor-receivewithin.check delete mode 100644 test/partest-tests/jvm/actor-receivewithin.scala delete mode 100644 test/partest-tests/run/crash.scala delete mode 100644 test/partest-tests/run/streamWithFilter.check delete mode 100644 test/partest-tests/run/streamWithFilter.scala delete mode 100644 test/partest-tests/run/timeout.scala delete mode 100644 test/pending/neg/t1477.scala delete mode 100644 test/pending/pos/bug2018.scala delete mode 100644 test/pending/pos/bug3420.flags delete mode 100644 test/pending/pos/bug3420.scala delete mode 100644 test/pending/pos/bug563.scala delete mode 100644 test/pending/pos/foo.scala delete mode 100644 test/pending/pos/t0716.scala delete mode 100644 test/pending/pos/t2162.scala delete mode 100644 test/pending/pos/t2179.scala delete mode 100644 test/pending/pos/t2635.scala delete mode 100644 test/pending/pos/t2641.scala delete mode 100644 test/pending/pos/t3636.scala delete mode 100644 test/pending/run/bug1006.scala delete mode 100644 test/pending/run/bug2087.scala delete mode 100644 test/pending/run/bug2365/Test.scala delete mode 100644 test/pending/run/bug2365/bug2365.javaopts delete mode 100755 test/pending/run/bug2365/run delete mode 100644 test/pending/run/bug3150.scala delete mode 100644 test/pending/run/castsingleton.scala delete mode 100644 test/pending/run/t0807.scala delete mode 100644 test/pending/run/t1939.scala delete mode 100644 test/pending/scalacheck/CheckEither.scala delete mode 100644 test/pending/scalacheck/array.scala delete mode 100644 test/pending/scalacheck/eqeq.scala delete mode 100644 test/pending/scalacheck/list.scala delete mode 100644 test/pending/scalacheck/range.scala delete mode 100644 test/pending/scalacheck/scan.scala create mode 100755 test/pending/script/bug2365.sh create mode 100644 test/pending/script/error-messages.check create mode 100644 test/pending/script/error-messages.scala delete mode 100644 test/pending/script/errors.check delete mode 100644 test/pending/script/errors.scala (limited to 'test') diff --git a/test/files/jvm/unittest_io.scala b/test/files/jvm/unittest_io.scala deleted file mode 100644 index fd5889cb86..0000000000 --- a/test/files/jvm/unittest_io.scala +++ /dev/null @@ -1,24 +0,0 @@ -import scala.testing.SUnit._ -import scala.io.Source - -object Test extends TestConsoleMain { - - def suite = new TestSuite( - new ReadlinesTest - ) - - class ReadlinesTest extends TestCase("scala.io.Source method getLines()") { - - val src = Source.fromString(""" -This is a file -it is split on several lines. - -isn't it? -""") - def runTest() = assertEquals("wrong number of lines",src.getLines.toList.length,5) // five new lines in there - //for (line <- src.getLines) { - // Console.print(line) - //} - } - -} diff --git a/test/files/jvm/unittest_io_Jvm.scala b/test/files/jvm/unittest_io_Jvm.scala new file mode 100644 index 0000000000..fd5889cb86 --- /dev/null +++ b/test/files/jvm/unittest_io_Jvm.scala @@ -0,0 +1,24 @@ +import scala.testing.SUnit._ +import scala.io.Source + +object Test extends TestConsoleMain { + + def suite = new TestSuite( + new ReadlinesTest + ) + + class ReadlinesTest extends TestCase("scala.io.Source method getLines()") { + + val src = Source.fromString(""" +This is a file +it is split on several lines. + +isn't it? +""") + def runTest() = assertEquals("wrong number of lines",src.getLines.toList.length,5) // five new lines in there + //for (line <- src.getLines) { + // Console.print(line) + //} + } + +} diff --git a/test/files/pos/bug0325.scala b/test/files/pos/bug0325.scala deleted file mode 100644 index 4b13c431b7..0000000000 --- a/test/files/pos/bug0325.scala +++ /dev/null @@ -1,4 +0,0 @@ -class Foobar { - val foo = "foo"; - def foo(bar: String): String = foo + bar; // crashes the compiler -} diff --git a/test/files/pos/bug1210.scala b/test/files/pos/bug1210.scala deleted file mode 100644 index eb163a956e..0000000000 --- a/test/files/pos/bug1210.scala +++ /dev/null @@ -1,28 +0,0 @@ -object Test -{ - def f[T](recurse: T => List[T]): List[T] = - { - Nil - } - - abstract class M - { self => - type Settings - type selfType = M {type Settings = self.Settings} - - val v: List[selfType] = f[selfType]((x: selfType) => x.v) - } - - abstract class M2 - { self => - type Settings - type selfType = M2 {type Settings = self.Settings} - - def g: List[selfType] = Nil - - { - f[selfType](_.g) - } - } -} - diff --git a/test/files/pos/bug1241.scala b/test/files/pos/bug1241.scala deleted file mode 100644 index 333e6c5490..0000000000 --- a/test/files/pos/bug1241.scala +++ /dev/null @@ -1,8 +0,0 @@ -object test extends Application { - // more.. - type T = { def hello() } - //val x4 = new AnyRef { def hello() { println("4") } } // ok! - val x4: T = new { def hello() { println("4") } } // error! - x4.hello() - // more.. -} diff --git a/test/files/pos/bug1909b-pos.scala b/test/files/pos/bug1909b-pos.scala new file mode 100644 index 0000000000..b914bee366 --- /dev/null +++ b/test/files/pos/bug1909b-pos.scala @@ -0,0 +1,6 @@ +class Ticket1909 (x: Int) { + def this() = this({ + def bar() = 5 + bar + }) +} \ No newline at end of file diff --git a/test/files/pos/bug1909b.scala b/test/files/pos/bug1909b.scala deleted file mode 100644 index b914bee366..0000000000 --- a/test/files/pos/bug1909b.scala +++ /dev/null @@ -1,6 +0,0 @@ -class Ticket1909 (x: Int) { - def this() = this({ - def bar() = 5 - bar - }) -} \ No newline at end of file diff --git a/test/files/pos/bug284-pos.scala b/test/files/pos/bug284-pos.scala new file mode 100644 index 0000000000..19673b7e4c --- /dev/null +++ b/test/files/pos/bug284-pos.scala @@ -0,0 +1,5 @@ +trait B[T] { + def f1(a: T): Unit { } + def f2(a: T): Unit + def f3(a: T) { } +} diff --git a/test/files/pos/bug284.scala b/test/files/pos/bug284.scala deleted file mode 100644 index 19673b7e4c..0000000000 --- a/test/files/pos/bug284.scala +++ /dev/null @@ -1,5 +0,0 @@ -trait B[T] { - def f1(a: T): Unit { } - def f2(a: T): Unit - def f3(a: T) { } -} diff --git a/test/files/pos/bug3175-pos.scala b/test/files/pos/bug3175-pos.scala new file mode 100644 index 0000000000..89bbf8b5fc --- /dev/null +++ b/test/files/pos/bug3175-pos.scala @@ -0,0 +1,7 @@ +object Test { + def f(g:{val update:Unit}) = g.update + + def main(args: Array[String]): Unit = { + + } +} diff --git a/test/files/pos/bug3175.scala b/test/files/pos/bug3175.scala deleted file mode 100644 index 89bbf8b5fc..0000000000 --- a/test/files/pos/bug3175.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test { - def f(g:{val update:Unit}) = g.update - - def main(args: Array[String]): Unit = { - - } -} diff --git a/test/files/pos/bug3636.scala b/test/files/pos/bug3636.scala new file mode 100644 index 0000000000..24d18c653d --- /dev/null +++ b/test/files/pos/bug3636.scala @@ -0,0 +1,49 @@ +class CTxnLocal[ T ] { + def set( x: T )( implicit t: Txn ) {} + def get( implicit t: Txn ) : T = null.asInstanceOf[ T ] + def initialValue( t: Txn ) : T = null.asInstanceOf[ T ] +} + +trait Txn + +trait ProcTxn { + def ccstm: Txn +} + +trait TxnLocal[ @specialized T ] { + def apply()( implicit tx: ProcTxn ) : T + def set( v: T )( implicit tx: ProcTxn ) : Unit + def swap( v: T )( implicit tx: ProcTxn ) : T + def transform( f: T => T )( implicit tx: ProcTxn ) : Unit +} + +object TxnLocal { + def apply[ @specialized T ] : TxnLocal[ T ] = new Impl( new CTxnLocal[ T ]) + def apply[ @specialized T ]( initValue: => T ) : TxnLocal[ T ] = new Impl( new CTxnLocal[ T ] { + override def initialValue( tx: Txn ): T = initValue + }) + + private class Impl[ T ]( c: CTxnLocal[ T ]) extends TxnLocal[ T ] { + def apply()( implicit tx: ProcTxn ) : T = c.get( tx.ccstm ) + def set( v: T )( implicit tx: ProcTxn ) : Unit = c.set( v )( tx.ccstm ) + def swap( v: T )( implicit tx: ProcTxn ) : T = { + // currently not implemented in CTxnLocal + val oldV = apply + set( v ) + oldV + } + def transform( f: T => T )( implicit tx: ProcTxn ) { + set( f( apply )) + } + } +} + + +object Transition { + private val currentRef = TxnLocal[ Transition ]( Instant ) + def current( implicit tx: ProcTxn ) : Transition = currentRef() +} + +sealed abstract class Transition +case object Instant extends Transition + diff --git a/test/files/pos/cyclics-pos.scala b/test/files/pos/cyclics-pos.scala new file mode 100644 index 0000000000..395e88815a --- /dev/null +++ b/test/files/pos/cyclics-pos.scala @@ -0,0 +1,26 @@ +trait Param[T] +trait Abs { type T } +trait Cyclic1[A <: Param[A]] // works +trait Cyclic2[A <: Abs { type T <: A }] +trait Cyclic3 { type A <: Abs { type T = A } } +trait Cyclic4 { type A <: Param[A] } // works +trait Cyclic5 { type AA <: Abs; type A <: AA { type T = A } } + + +trait IterableTemplate { + type Elem + type Constr <: IterableTemplate + type ConstrOf[A] = Constr { type Elem = A } + + def iterator: Iterator[Elem] + + def map [B] (f: Elem => B): ConstrOf[B] + + def foreach(f: Elem => Unit) = iterator.foreach(f) +} + + +trait Iterable[A] extends IterableTemplate { self => + type Elem + type Constr <: Iterable[A] { type Constr <: Iterable.this.Constr } +} diff --git a/test/files/pos/cyclics.scala b/test/files/pos/cyclics.scala deleted file mode 100644 index 395e88815a..0000000000 --- a/test/files/pos/cyclics.scala +++ /dev/null @@ -1,26 +0,0 @@ -trait Param[T] -trait Abs { type T } -trait Cyclic1[A <: Param[A]] // works -trait Cyclic2[A <: Abs { type T <: A }] -trait Cyclic3 { type A <: Abs { type T = A } } -trait Cyclic4 { type A <: Param[A] } // works -trait Cyclic5 { type AA <: Abs; type A <: AA { type T = A } } - - -trait IterableTemplate { - type Elem - type Constr <: IterableTemplate - type ConstrOf[A] = Constr { type Elem = A } - - def iterator: Iterator[Elem] - - def map [B] (f: Elem => B): ConstrOf[B] - - def foreach(f: Elem => Unit) = iterator.foreach(f) -} - - -trait Iterable[A] extends IterableTemplate { self => - type Elem - type Constr <: Iterable[A] { type Constr <: Iterable.this.Constr } -} diff --git a/test/files/pos/depmet_1.flags b/test/files/pos/depmet_1.flags deleted file mode 100644 index 1c26b24745..0000000000 --- a/test/files/pos/depmet_1.flags +++ /dev/null @@ -1 +0,0 @@ --Ydependent-method-types \ No newline at end of file diff --git a/test/files/pos/depmet_1.scala b/test/files/pos/depmet_1.scala deleted file mode 100644 index 166e991817..0000000000 --- a/test/files/pos/depmet_1.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test { - def precise(x: String)(y: x.type): x.type = y - val foo = "foo" - val fun : foo.type => foo.type = precise(foo) - val bar : foo.type = precise(foo)(foo) -} \ No newline at end of file diff --git a/test/files/pos/depmet_1_pos.flags b/test/files/pos/depmet_1_pos.flags new file mode 100644 index 0000000000..1c26b24745 --- /dev/null +++ b/test/files/pos/depmet_1_pos.flags @@ -0,0 +1 @@ +-Ydependent-method-types \ No newline at end of file diff --git a/test/files/pos/depmet_1_pos.scala b/test/files/pos/depmet_1_pos.scala new file mode 100644 index 0000000000..166e991817 --- /dev/null +++ b/test/files/pos/depmet_1_pos.scala @@ -0,0 +1,6 @@ +object Test { + def precise(x: String)(y: x.type): x.type = y + val foo = "foo" + val fun : foo.type => foo.type = precise(foo) + val bar : foo.type = precise(foo)(foo) +} \ No newline at end of file diff --git a/test/files/pos/exceptions.scala b/test/files/pos/exceptions.scala deleted file mode 100644 index 52c33fb43a..0000000000 --- a/test/files/pos/exceptions.scala +++ /dev/null @@ -1,20 +0,0 @@ -import java.io.IOException; - -object Test { - - //def error[a](x: String):a = new java.lang.RuntimeException(x) throw; - - def main(args: Array[String]): Unit = { - try { - try { - Console.println("hi!"); - error("xx"); - } finally { - Console.println("ho!") - } - } catch { - case ex: IOException => Console.println("io exception!"); - case ex => Console.println(ex); - } - } -} diff --git a/test/files/pos/imp2-pos.scala b/test/files/pos/imp2-pos.scala new file mode 100644 index 0000000000..5460c60015 --- /dev/null +++ b/test/files/pos/imp2-pos.scala @@ -0,0 +1,5 @@ +object Test { + import collection.mutable._ + import collection.mutable._ + val x = new HashMap +} diff --git a/test/files/pos/imp2.scala b/test/files/pos/imp2.scala deleted file mode 100644 index 5460c60015..0000000000 --- a/test/files/pos/imp2.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test { - import collection.mutable._ - import collection.mutable._ - val x = new HashMap -} diff --git a/test/files/pos/imports-pos.scala b/test/files/pos/imports-pos.scala new file mode 100644 index 0000000000..f6a55e5e07 --- /dev/null +++ b/test/files/pos/imports-pos.scala @@ -0,0 +1,16 @@ +package test; + +import java.lang.{System => S} + +object test { + import S.out.{print => p, println => print} + + val foo = 1; + + p("hello"); print("world"); S.out.println("!"); + S.out.flush(); +} +object test1 { + import test._; + foo +} diff --git a/test/files/pos/imports.scala b/test/files/pos/imports.scala deleted file mode 100644 index f6a55e5e07..0000000000 --- a/test/files/pos/imports.scala +++ /dev/null @@ -1,16 +0,0 @@ -package test; - -import java.lang.{System => S} - -object test { - import S.out.{print => p, println => print} - - val foo = 1; - - p("hello"); print("world"); S.out.println("!"); - S.out.flush(); -} -object test1 { - import test._; - foo -} diff --git a/test/files/pos/infer2-pos.scala b/test/files/pos/infer2-pos.scala new file mode 100644 index 0000000000..e065219a80 --- /dev/null +++ b/test/files/pos/infer2-pos.scala @@ -0,0 +1,8 @@ +package test +class Lst[T] +case class cons[T](x: T, xs: Lst[T]) extends Lst[T] +case class nil[T] extends Lst[T] +object test { + Console.println(cons(1, nil())) +} + diff --git a/test/files/pos/infer2.scala b/test/files/pos/infer2.scala deleted file mode 100644 index e065219a80..0000000000 --- a/test/files/pos/infer2.scala +++ /dev/null @@ -1,8 +0,0 @@ -package test -class Lst[T] -case class cons[T](x: T, xs: Lst[T]) extends Lst[T] -case class nil[T] extends Lst[T] -object test { - Console.println(cons(1, nil())) -} - diff --git a/test/files/pos/misc-unapply_pos.scala b/test/files/pos/misc-unapply_pos.scala new file mode 100644 index 0000000000..6651e64362 --- /dev/null +++ b/test/files/pos/misc-unapply_pos.scala @@ -0,0 +1,27 @@ +object Test { + val xs = List(1) + val f: Int = { + xs match { + case List(x) => x + } + } +} + +// the following comes from ticket #230 +trait Foo { + def name: String + def unapply(x: String): Option[Unit] = { + if (x == name) Some(()) else None + } +} +object Bar extends Foo { def name = "bar" } +object Baz extends Foo { def name = "baz" } + +object Test_ { + def matcher(s: String) = s match { + case Bar(x) => println("bar") + case Baz(x) => println("baz") +// ^ +// error: unreachable code + } + } diff --git a/test/files/pos/pos-bug1210.scala b/test/files/pos/pos-bug1210.scala new file mode 100644 index 0000000000..eb163a956e --- /dev/null +++ b/test/files/pos/pos-bug1210.scala @@ -0,0 +1,28 @@ +object Test +{ + def f[T](recurse: T => List[T]): List[T] = + { + Nil + } + + abstract class M + { self => + type Settings + type selfType = M {type Settings = self.Settings} + + val v: List[selfType] = f[selfType]((x: selfType) => x.v) + } + + abstract class M2 + { self => + type Settings + type selfType = M2 {type Settings = self.Settings} + + def g: List[selfType] = Nil + + { + f[selfType](_.g) + } + } +} + diff --git a/test/files/pos/pos-bug1241.scala b/test/files/pos/pos-bug1241.scala new file mode 100644 index 0000000000..333e6c5490 --- /dev/null +++ b/test/files/pos/pos-bug1241.scala @@ -0,0 +1,8 @@ +object test extends Application { + // more.. + type T = { def hello() } + //val x4 = new AnyRef { def hello() { println("4") } } // ok! + val x4: T = new { def hello() { println("4") } } // error! + x4.hello() + // more.. +} diff --git a/test/files/pos/simple-exceptions.scala b/test/files/pos/simple-exceptions.scala new file mode 100644 index 0000000000..52c33fb43a --- /dev/null +++ b/test/files/pos/simple-exceptions.scala @@ -0,0 +1,20 @@ +import java.io.IOException; + +object Test { + + //def error[a](x: String):a = new java.lang.RuntimeException(x) throw; + + def main(args: Array[String]): Unit = { + try { + try { + Console.println("hi!"); + error("xx"); + } finally { + Console.println("ho!") + } + } catch { + case ex: IOException => Console.println("io exception!"); + case ex => Console.println(ex); + } + } +} diff --git a/test/files/pos/t1422.scala b/test/files/pos/t1422.scala deleted file mode 100644 index 658f5c730d..0000000000 --- a/test/files/pos/t1422.scala +++ /dev/null @@ -1,2 +0,0 @@ -case class A(private val foo:String) -case class B(protected[this] val foo:String) diff --git a/test/files/pos/t1422_pos.scala b/test/files/pos/t1422_pos.scala new file mode 100644 index 0000000000..658f5c730d --- /dev/null +++ b/test/files/pos/t1422_pos.scala @@ -0,0 +1,2 @@ +case class A(private val foo:String) +case class B(protected[this] val foo:String) diff --git a/test/files/pos/t1591.scala b/test/files/pos/t1591.scala deleted file mode 100644 index 4f55d7ce19..0000000000 --- a/test/files/pos/t1591.scala +++ /dev/null @@ -1,7 +0,0 @@ -trait A - -object Test { - lazy val a = new A { - object Zenek - } -} diff --git a/test/files/pos/t1591_pos.scala b/test/files/pos/t1591_pos.scala new file mode 100644 index 0000000000..4f55d7ce19 --- /dev/null +++ b/test/files/pos/t1591_pos.scala @@ -0,0 +1,7 @@ +trait A + +object Test { + lazy val a = new A { + object Zenek + } +} diff --git a/test/files/pos/t2208.scala b/test/files/pos/t2208.scala deleted file mode 100644 index f1a521b14c..0000000000 --- a/test/files/pos/t2208.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - class A - - class B[X] - type Alias[X <: A] = B[X] - - val foo: B[A] = new Alias[A] // check that type aliases can be instantiated -} \ No newline at end of file diff --git a/test/files/pos/t2208_pos.scala b/test/files/pos/t2208_pos.scala new file mode 100644 index 0000000000..f1a521b14c --- /dev/null +++ b/test/files/pos/t2208_pos.scala @@ -0,0 +1,8 @@ +object Test { + class A + + class B[X] + type Alias[X <: A] = B[X] + + val foo: B[A] = new Alias[A] // check that type aliases can be instantiated +} \ No newline at end of file diff --git a/test/files/pos/t2421b.scala b/test/files/pos/t2421b.scala deleted file mode 100644 index 0df3461662..0000000000 --- a/test/files/pos/t2421b.scala +++ /dev/null @@ -1,19 +0,0 @@ -object Test { - class A - class B - class C - class F[X] - - def f(implicit aa: F[A]) = println(aa) - - implicit def a : F[A] = new F[A]() - implicit def b[X <: B] = new F[X]() - - f -} -/* bug: -error: ambiguous implicit values: - both method b in object Test1 of type [X <: Test1.B]Test1.F[X] - and method a in object Test1 of type => Test1.F[Test1.A] - match expected type Test1.F[Test1.A] -*/ diff --git a/test/files/pos/t2421b_pos.scala b/test/files/pos/t2421b_pos.scala new file mode 100644 index 0000000000..0df3461662 --- /dev/null +++ b/test/files/pos/t2421b_pos.scala @@ -0,0 +1,19 @@ +object Test { + class A + class B + class C + class F[X] + + def f(implicit aa: F[A]) = println(aa) + + implicit def a : F[A] = new F[A]() + implicit def b[X <: B] = new F[X]() + + f +} +/* bug: +error: ambiguous implicit values: + both method b in object Test1 of type [X <: Test1.B]Test1.F[X] + and method a in object Test1 of type => Test1.F[Test1.A] + match expected type Test1.F[Test1.A] +*/ diff --git a/test/files/pos/t2726/bug2726_2.scala b/test/files/pos/t2726/bug2726_2.scala new file mode 100644 index 0000000000..e738143aeb --- /dev/null +++ b/test/files/pos/t2726/bug2726_2.scala @@ -0,0 +1,3 @@ +object SQuery2Test { + new SQLBuilder +} diff --git a/test/files/pos/t2726/test_2.scala b/test/files/pos/t2726/test_2.scala deleted file mode 100644 index e738143aeb..0000000000 --- a/test/files/pos/t2726/test_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -object SQuery2Test { - new SQLBuilder -} diff --git a/test/files/pos/t2868/t2868_src_2.scala b/test/files/pos/t2868/t2868_src_2.scala new file mode 100644 index 0000000000..f11ef0fae2 --- /dev/null +++ b/test/files/pos/t2868/t2868_src_2.scala @@ -0,0 +1,6 @@ +class test { + val l = (new pick).s + val u = (new pick).foo + val c = (new pick).bar + val k = (new pick).baz +} diff --git a/test/files/pos/t2868/test_2.scala b/test/files/pos/t2868/test_2.scala deleted file mode 100644 index f11ef0fae2..0000000000 --- a/test/files/pos/t2868/test_2.scala +++ /dev/null @@ -1,6 +0,0 @@ -class test { - val l = (new pick).s - val u = (new pick).foo - val c = (new pick).bar - val k = (new pick).baz -} diff --git a/test/files/pos/tcpoly_variance.scala b/test/files/pos/tcpoly_variance.scala deleted file mode 100644 index b641716d50..0000000000 --- a/test/files/pos/tcpoly_variance.scala +++ /dev/null @@ -1,7 +0,0 @@ -class A[m[+x]] { - def str: m[Object] = error("foo") -} - -class B[m[+x]] extends A[m] { - override def str: m[String] = error("foo") -} diff --git a/test/files/pos/tcpoly_variance_pos.scala b/test/files/pos/tcpoly_variance_pos.scala new file mode 100644 index 0000000000..b641716d50 --- /dev/null +++ b/test/files/pos/tcpoly_variance_pos.scala @@ -0,0 +1,7 @@ +class A[m[+x]] { + def str: m[Object] = error("foo") +} + +class B[m[+x]] extends A[m] { + override def str: m[String] = error("foo") +} diff --git a/test/files/pos/test2.scala b/test/files/pos/test2.scala deleted file mode 100644 index 0dcc16ffab..0000000000 --- a/test/files/pos/test2.scala +++ /dev/null @@ -1,5 +0,0 @@ -import scala._; -object test2 { - def f(x: Int): Int = 'a'; - def g(x: Int) = f(f(x)); -} diff --git a/test/files/pos/typerep.scala b/test/files/pos/typerep.scala deleted file mode 100644 index 7faa8a1928..0000000000 --- a/test/files/pos/typerep.scala +++ /dev/null @@ -1,21 +0,0 @@ -object typerep extends Application { - class TypeRep[T] {} - case object IntRep extends TypeRep[Int] { - override def toString = "Int" - } - case object BooleanRep extends TypeRep[Boolean] { - override def toString = "Boolean" - } - case class ListRep[T](elemrep: TypeRep[T]) extends TypeRep[List[T]] { - override def toString = "List" - } - - implicit def intRep: TypeRep[Int] = IntRep - implicit def booleanRep: TypeRep[Boolean] = BooleanRep - implicit def listRep[T](implicit elemrep: TypeRep[T]): TypeRep[List[T]] = ListRep(elemrep) - - def getType[T](x: T)(implicit rep: TypeRep[T]): TypeRep[T] = rep - - println(getType(1)) - println(getType(List(1))) -} diff --git a/test/files/pos/typerep_pos.scala b/test/files/pos/typerep_pos.scala new file mode 100644 index 0000000000..7faa8a1928 --- /dev/null +++ b/test/files/pos/typerep_pos.scala @@ -0,0 +1,21 @@ +object typerep extends Application { + class TypeRep[T] {} + case object IntRep extends TypeRep[Int] { + override def toString = "Int" + } + case object BooleanRep extends TypeRep[Boolean] { + override def toString = "Boolean" + } + case class ListRep[T](elemrep: TypeRep[T]) extends TypeRep[List[T]] { + override def toString = "List" + } + + implicit def intRep: TypeRep[Int] = IntRep + implicit def booleanRep: TypeRep[Boolean] = BooleanRep + implicit def listRep[T](implicit elemrep: TypeRep[T]): TypeRep[List[T]] = ListRep(elemrep) + + def getType[T](x: T)(implicit rep: TypeRep[T]): TypeRep[T] = rep + + println(getType(1)) + println(getType(List(1))) +} diff --git a/test/files/pos/unapply.scala b/test/files/pos/unapply.scala deleted file mode 100644 index 6651e64362..0000000000 --- a/test/files/pos/unapply.scala +++ /dev/null @@ -1,27 +0,0 @@ -object Test { - val xs = List(1) - val f: Int = { - xs match { - case List(x) => x - } - } -} - -// the following comes from ticket #230 -trait Foo { - def name: String - def unapply(x: String): Option[Unit] = { - if (x == name) Some(()) else None - } -} -object Bar extends Foo { def name = "bar" } -object Baz extends Foo { def name = "baz" } - -object Test_ { - def matcher(s: String) = s match { - case Bar(x) => println("bar") - case Baz(x) => println("baz") -// ^ -// error: unreachable code - } - } diff --git a/test/files/pos/variances.scala b/test/files/pos/variances.scala deleted file mode 100644 index 7dc56b0225..0000000000 --- a/test/files/pos/variances.scala +++ /dev/null @@ -1,8 +0,0 @@ -abstract class P[+a, +b] { // SLS, Example 4.4.2 - def fst: a; - def snd: b -} - -trait Vector[+a] { // SLS, Example 4.4.3 b) - def append[b >: a](x: Vector[b]): Vector[b] -} diff --git a/test/files/pos/variances_pos.scala b/test/files/pos/variances_pos.scala new file mode 100644 index 0000000000..7dc56b0225 --- /dev/null +++ b/test/files/pos/variances_pos.scala @@ -0,0 +1,8 @@ +abstract class P[+a, +b] { // SLS, Example 4.4.2 + def fst: a; + def snd: b +} + +trait Vector[+a] { // SLS, Example 4.4.3 b) + def append[b >: a](x: Vector[b]): Vector[b] +} diff --git a/test/files/run/bug3150.scala b/test/files/run/bug3150.scala new file mode 100644 index 0000000000..034703b5f7 --- /dev/null +++ b/test/files/run/bug3150.scala @@ -0,0 +1,10 @@ +object Test { + case object Bob { override def equals(other: Any) = true } + def f(x: Any) = x match { case Bob => Bob } + + def main(args: Array[String]): Unit = { + assert(f(Bob) eq Bob) + assert(f(0) eq Bob) + assert(f(Nil) eq Bob) + } +} diff --git a/test/files/run/lazy-override-run.check b/test/files/run/lazy-override-run.check new file mode 100644 index 0000000000..a8f658d7b5 --- /dev/null +++ b/test/files/run/lazy-override-run.check @@ -0,0 +1,3 @@ +a.x=/*A.x*/2 +b.x=/*B.x*/3 +b.z=/*B.z/3 diff --git a/test/files/run/lazy-override-run.scala b/test/files/run/lazy-override-run.scala new file mode 100644 index 0000000000..e5884257a8 --- /dev/null +++ b/test/files/run/lazy-override-run.scala @@ -0,0 +1,26 @@ +class A { + lazy val x: Int = { print("/*A.x*/"); 2 } + lazy val y: Int = { print("/*A.y*/"); 2 } + lazy val z: Int = { print("/*A.z*/"); 2 } +} + +class B extends A { + override lazy val x: Int = { print("/*B.x*/"); 3 } + override lazy val y: Int = { print("/*B.y*/"); 3 } + override lazy val z: Int = { print("/*B.z/"); 3 } +} + + + + +object Test extends Application { + val a = new A + print("a.x=") + println(a.x) + + val b = new B + print("b.x=") + println(b.x) + print("b.z=") + println(b.z) +} diff --git a/test/files/run/lazy-override.check b/test/files/run/lazy-override.check deleted file mode 100644 index a8f658d7b5..0000000000 --- a/test/files/run/lazy-override.check +++ /dev/null @@ -1,3 +0,0 @@ -a.x=/*A.x*/2 -b.x=/*B.x*/3 -b.z=/*B.z/3 diff --git a/test/files/run/lazy-override.scala b/test/files/run/lazy-override.scala deleted file mode 100644 index e5884257a8..0000000000 --- a/test/files/run/lazy-override.scala +++ /dev/null @@ -1,26 +0,0 @@ -class A { - lazy val x: Int = { print("/*A.x*/"); 2 } - lazy val y: Int = { print("/*A.y*/"); 2 } - lazy val z: Int = { print("/*A.z*/"); 2 } -} - -class B extends A { - override lazy val x: Int = { print("/*B.x*/"); 3 } - override lazy val y: Int = { print("/*B.y*/"); 3 } - override lazy val z: Int = { print("/*B.z/"); 3 } -} - - - - -object Test extends Application { - val a = new A - print("a.x=") - println(a.x) - - val b = new B - print("b.x=") - println(b.x) - print("b.z=") - println(b.z) -} diff --git a/test/files/run/lists-run.scala b/test/files/run/lists-run.scala new file mode 100644 index 0000000000..6c9b55961e --- /dev/null +++ b/test/files/run/lists-run.scala @@ -0,0 +1,210 @@ +//############################################################################ +// Lists +//############################################################################ + +//############################################################################ + +import testing.SUnit._ + +/** Test the Scala implementation of class scala.List. + * + * @author Stephane Micheloud + */ +object Test extends TestConsoleMain { + def suite = new TestSuite( + Test_multiset, // multiset operations: union, intersect, diff + Test1, //count, exists, filter, .. + Test2, //#468 + Test3, //#1691 + Test4, //#1721 + Test5 + ) +} + +object Test_multiset extends TestCase("multiset") with Assert { + override def enableStackTrace = false + override def runTest { + def isSubListOf[A](thiz: List[A], that: List[A]): Boolean = + thiz forall (that contains _) + val xs = List(1, 1, 2) + val ys = List(1, 2, 2, 3) + assertEquals("xs_union_ys", List(1, 1, 2, 1, 2, 2, 3), xs union ys) + assertEquals("ys_union_xs", List(1, 2, 2, 3, 1, 1, 2), ys union xs) + assertEquals("xs_intersect_ys", List(1, 2), xs intersect ys) + assertEquals("ys_intersect_xs", List(1, 2), ys intersect xs) + assertEquals("xs_diff_ys", List(1), xs diff ys) + assertEquals("ys_diff_xs", List(2, 3), ys diff xs) + assertTrue("xs_subset_ys", isSubListOf(xs -- ys, xs diff ys)) + + val zs = List(0, 1, 1, 2, 2, 2) + assertEquals("zs_union_ys", List(0, 1, 1, 2, 2, 2, 1, 2, 2, 3), zs union ys) + assertEquals("ys_union_zs", List(1, 2, 2, 3, 0, 1, 1, 2, 2, 2), ys union zs) + assertEquals("zs_intersect_ys", List(1, 2, 2), zs intersect ys) + assertEquals("ys_intersect_zs", List(1, 2, 2), ys intersect zs) + assertEquals("zs_diff_ys", List(0, 1, 2), zs diff ys) + assertEquals("ys_diff_zs", List(3), ys diff zs) + assertTrue("xs_subset_ys", isSubListOf(zs -- ys, zs diff ys)) + + val ws = List(2) + assertEquals("ws_union_ys", List(2, 1, 2, 2, 3), ws union ys) + assertEquals("ys_union_ws", List(1, 2, 2, 3, 2), ys union ws) + assertEquals("ws_intersect_ys", List(2), ws intersect ys) + assertEquals("ys_intersect_ws", List(2), ys intersect ws) + assertEquals("ws_diff_ys", List(), ws diff ys) + assertEquals("ys_diff_ws", List(1, 2, 3), ys diff ws) + assertTrue("ws_subset_ys", isSubListOf(ws -- ys, ws diff ys)) + + val vs = List(3, 2, 2, 1) + assertEquals("xs_union_vs", List(1, 1, 2, 3, 2, 2, 1), xs union vs) + assertEquals("vs_union_xs", List(3, 2, 2, 1, 1, 1, 2), vs union xs) + assertEquals("xs_intersect_vs", List(1, 2), xs intersect vs) + assertEquals("vs_intersect_xs", List(2, 1), vs intersect xs) + assertEquals("xs_diff_vs", List(1), xs diff vs) + assertEquals("vs_diff_xs", List(3, 2), vs diff xs) + assertTrue("xs_subset_vs", isSubListOf(xs -- vs, xs diff vs)) + + // tests adapted from Thomas Jung + assertTrue( + "be symmetric after sorting", { + def sort(zs: List[Int]) = zs sort ( _ > _ ) + sort(xs intersect ys) == sort(ys intersect xs) + }) + assertTrue( + "obey min cardinality", { + def cardinality[A](zs: List[A], e: A): Int = zs count (e == _) + val intersection = xs intersect ys + xs forall (e => cardinality(intersection, e) == (cardinality(xs, e) +min cardinality(ys, e))) + }) + assertTrue( + "maintain order", { + val intersection = xs intersect ys + val unconsumed = xs.foldLeft(intersection){(rest, e) => + if (! rest.isEmpty && e == rest.head) rest.tail else rest + } + unconsumed.isEmpty + }) + assertTrue( + "has the list as again intersection", + xs == (xs intersect xs) + ) + } +} + +object Test1 extends TestCase("ctor") with Assert { + override def enableStackTrace = false + override def runTest { + val xs1 = List(1, 2, 3) + val xs2 = List('a', 'b') + val xs3 = List(List(1, 2), List(4, 5)) + val xs4 = List(2, 4, 6, 8) + val xs5 = List(List(3, 4), List(3), List(4, 5)) + + { + val n1 = xs1 count { e => e % 2 != 0 } + val n2 = xs4 count { e => e < 5 } + assertEquals("check_count", 4, n1 + n2) + } + { + val b1 = xs1 exists { e => e % 2 == 0 } + val b2 = xs4 exists { e => e == 5 } + assertEquals("check_exists", false , b1 & b2) + } + { + val ys1 = xs1 filter { e => e % 2 == 0 } + val ys2 = xs4 filter { e => e < 5 } + assertEquals("check_filter", 3, ys1.length + ys2.length) + } + { + val n1 = xs1.foldLeft(0)((e1, e2) => e1 + e2) + val ys1 = xs4.foldLeft(List[Int]())((e1, e2) => e2 :: e1) + assertEquals("check_foldLeft", 10, n1 + ys1.length) + } + { + val b1 = xs1 forall { e => e < 10} + val b2 = xs4 forall { e => e % 2 == 0 } + assertEquals("check_forall", true, b1 & b2) + } + { + val ys1 = xs1 filterNot { e => e % 2 != 0 } + val ys2 = xs4 filterNot { e => e < 5 } + assertEquals("check_remove", 3, ys1.length + ys2.length) + } + { + val ys1 = xs1 zip xs2 + val ys2 = xs1 zip xs3 + assertEquals("check_zip", 4, ys1.length + ys2.length) + } + { + val ys1 = xs1.zipAll(xs2, 0, '_') + val ys2 = xs2.zipAll(xs1, '_', 0) + val ys3 = xs1.zipAll(xs3, 0, List(-1)) + assertEquals("check_zipAll", 9, ys1.length + ys2.length + ys3.length) + } + } +} + +object Test2 extends TestCase("t0468") with Assert { + override def enableStackTrace = false + override def runTest { + val xs1 = List(1, 2, 3) + val xs2 = List(0) + + val ys1 = xs1 ::: List(4) + assertEquals("check_:::", List(1, 2, 3, 4), ys1) + + val ys2 = ys1 - 4 + assertEquals("check_-", xs1, ys2) + + val n2 = (xs1 ++ ys1).length + val n3 = (xs1 ++ Nil).length + val n4 = (xs1 ++ ((new collection.mutable.ArrayBuffer[Int]) + 0)).length + assertEquals("check_++", 14, n2 + n3 + n4) + } +} + +object Test3 extends TestCase("t1691") with Assert { + override def enableStackTrace = false + override def runTest { + try { + List.range(1, 10, 0) + } catch { + case e: IllegalArgumentException => () + case _ => throw new Error("List.range(1, 10, 0)") + } + try { + List.range(1, 10, x => 4) + } catch { + case e: IllegalArgumentException => () + case _ => throw new Error("List.range(1, 10, x => 4)") + } + assertEquals(List.range(10, 0, x => x - 2), + List(10, 8, 6, 4, 2)) + } +} + +object Test4 extends TestCase("t1721") with Assert { + override def enableStackTrace = false + override def runTest { + assertTrue(List(1,2,3).endsWith(List(2,3))) + assertFalse(List(1,2,3).endsWith(List(1,3))) + assertTrue(List(1,2,3).endsWith(List())) + assertFalse(List(1,2,3).endsWith(List(0,1,2,3))) + assertTrue(List(1,2,3).endsWith(List(1,2,3))) + assertFalse(List().endsWith(List(1,2,3))) + assertTrue(List().endsWith(List())) + } +} + +object Test5 extends TestCase("list pattern matching") { + def show(xs: List[String]) = xs match { + case "foo" :: args => args.toString + case List(x) => x.toString + case Nil => "Nil" + } + override def runTest { + assert(show(List()) == "Nil") + assert(show(List("a")) == "a") + assert(show(List("foo", "b")) == "List(b)") + } +} diff --git a/test/files/run/lists.scala b/test/files/run/lists.scala deleted file mode 100644 index 6c9b55961e..0000000000 --- a/test/files/run/lists.scala +++ /dev/null @@ -1,210 +0,0 @@ -//############################################################################ -// Lists -//############################################################################ - -//############################################################################ - -import testing.SUnit._ - -/** Test the Scala implementation of class scala.List. - * - * @author Stephane Micheloud - */ -object Test extends TestConsoleMain { - def suite = new TestSuite( - Test_multiset, // multiset operations: union, intersect, diff - Test1, //count, exists, filter, .. - Test2, //#468 - Test3, //#1691 - Test4, //#1721 - Test5 - ) -} - -object Test_multiset extends TestCase("multiset") with Assert { - override def enableStackTrace = false - override def runTest { - def isSubListOf[A](thiz: List[A], that: List[A]): Boolean = - thiz forall (that contains _) - val xs = List(1, 1, 2) - val ys = List(1, 2, 2, 3) - assertEquals("xs_union_ys", List(1, 1, 2, 1, 2, 2, 3), xs union ys) - assertEquals("ys_union_xs", List(1, 2, 2, 3, 1, 1, 2), ys union xs) - assertEquals("xs_intersect_ys", List(1, 2), xs intersect ys) - assertEquals("ys_intersect_xs", List(1, 2), ys intersect xs) - assertEquals("xs_diff_ys", List(1), xs diff ys) - assertEquals("ys_diff_xs", List(2, 3), ys diff xs) - assertTrue("xs_subset_ys", isSubListOf(xs -- ys, xs diff ys)) - - val zs = List(0, 1, 1, 2, 2, 2) - assertEquals("zs_union_ys", List(0, 1, 1, 2, 2, 2, 1, 2, 2, 3), zs union ys) - assertEquals("ys_union_zs", List(1, 2, 2, 3, 0, 1, 1, 2, 2, 2), ys union zs) - assertEquals("zs_intersect_ys", List(1, 2, 2), zs intersect ys) - assertEquals("ys_intersect_zs", List(1, 2, 2), ys intersect zs) - assertEquals("zs_diff_ys", List(0, 1, 2), zs diff ys) - assertEquals("ys_diff_zs", List(3), ys diff zs) - assertTrue("xs_subset_ys", isSubListOf(zs -- ys, zs diff ys)) - - val ws = List(2) - assertEquals("ws_union_ys", List(2, 1, 2, 2, 3), ws union ys) - assertEquals("ys_union_ws", List(1, 2, 2, 3, 2), ys union ws) - assertEquals("ws_intersect_ys", List(2), ws intersect ys) - assertEquals("ys_intersect_ws", List(2), ys intersect ws) - assertEquals("ws_diff_ys", List(), ws diff ys) - assertEquals("ys_diff_ws", List(1, 2, 3), ys diff ws) - assertTrue("ws_subset_ys", isSubListOf(ws -- ys, ws diff ys)) - - val vs = List(3, 2, 2, 1) - assertEquals("xs_union_vs", List(1, 1, 2, 3, 2, 2, 1), xs union vs) - assertEquals("vs_union_xs", List(3, 2, 2, 1, 1, 1, 2), vs union xs) - assertEquals("xs_intersect_vs", List(1, 2), xs intersect vs) - assertEquals("vs_intersect_xs", List(2, 1), vs intersect xs) - assertEquals("xs_diff_vs", List(1), xs diff vs) - assertEquals("vs_diff_xs", List(3, 2), vs diff xs) - assertTrue("xs_subset_vs", isSubListOf(xs -- vs, xs diff vs)) - - // tests adapted from Thomas Jung - assertTrue( - "be symmetric after sorting", { - def sort(zs: List[Int]) = zs sort ( _ > _ ) - sort(xs intersect ys) == sort(ys intersect xs) - }) - assertTrue( - "obey min cardinality", { - def cardinality[A](zs: List[A], e: A): Int = zs count (e == _) - val intersection = xs intersect ys - xs forall (e => cardinality(intersection, e) == (cardinality(xs, e) -min cardinality(ys, e))) - }) - assertTrue( - "maintain order", { - val intersection = xs intersect ys - val unconsumed = xs.foldLeft(intersection){(rest, e) => - if (! rest.isEmpty && e == rest.head) rest.tail else rest - } - unconsumed.isEmpty - }) - assertTrue( - "has the list as again intersection", - xs == (xs intersect xs) - ) - } -} - -object Test1 extends TestCase("ctor") with Assert { - override def enableStackTrace = false - override def runTest { - val xs1 = List(1, 2, 3) - val xs2 = List('a', 'b') - val xs3 = List(List(1, 2), List(4, 5)) - val xs4 = List(2, 4, 6, 8) - val xs5 = List(List(3, 4), List(3), List(4, 5)) - - { - val n1 = xs1 count { e => e % 2 != 0 } - val n2 = xs4 count { e => e < 5 } - assertEquals("check_count", 4, n1 + n2) - } - { - val b1 = xs1 exists { e => e % 2 == 0 } - val b2 = xs4 exists { e => e == 5 } - assertEquals("check_exists", false , b1 & b2) - } - { - val ys1 = xs1 filter { e => e % 2 == 0 } - val ys2 = xs4 filter { e => e < 5 } - assertEquals("check_filter", 3, ys1.length + ys2.length) - } - { - val n1 = xs1.foldLeft(0)((e1, e2) => e1 + e2) - val ys1 = xs4.foldLeft(List[Int]())((e1, e2) => e2 :: e1) - assertEquals("check_foldLeft", 10, n1 + ys1.length) - } - { - val b1 = xs1 forall { e => e < 10} - val b2 = xs4 forall { e => e % 2 == 0 } - assertEquals("check_forall", true, b1 & b2) - } - { - val ys1 = xs1 filterNot { e => e % 2 != 0 } - val ys2 = xs4 filterNot { e => e < 5 } - assertEquals("check_remove", 3, ys1.length + ys2.length) - } - { - val ys1 = xs1 zip xs2 - val ys2 = xs1 zip xs3 - assertEquals("check_zip", 4, ys1.length + ys2.length) - } - { - val ys1 = xs1.zipAll(xs2, 0, '_') - val ys2 = xs2.zipAll(xs1, '_', 0) - val ys3 = xs1.zipAll(xs3, 0, List(-1)) - assertEquals("check_zipAll", 9, ys1.length + ys2.length + ys3.length) - } - } -} - -object Test2 extends TestCase("t0468") with Assert { - override def enableStackTrace = false - override def runTest { - val xs1 = List(1, 2, 3) - val xs2 = List(0) - - val ys1 = xs1 ::: List(4) - assertEquals("check_:::", List(1, 2, 3, 4), ys1) - - val ys2 = ys1 - 4 - assertEquals("check_-", xs1, ys2) - - val n2 = (xs1 ++ ys1).length - val n3 = (xs1 ++ Nil).length - val n4 = (xs1 ++ ((new collection.mutable.ArrayBuffer[Int]) + 0)).length - assertEquals("check_++", 14, n2 + n3 + n4) - } -} - -object Test3 extends TestCase("t1691") with Assert { - override def enableStackTrace = false - override def runTest { - try { - List.range(1, 10, 0) - } catch { - case e: IllegalArgumentException => () - case _ => throw new Error("List.range(1, 10, 0)") - } - try { - List.range(1, 10, x => 4) - } catch { - case e: IllegalArgumentException => () - case _ => throw new Error("List.range(1, 10, x => 4)") - } - assertEquals(List.range(10, 0, x => x - 2), - List(10, 8, 6, 4, 2)) - } -} - -object Test4 extends TestCase("t1721") with Assert { - override def enableStackTrace = false - override def runTest { - assertTrue(List(1,2,3).endsWith(List(2,3))) - assertFalse(List(1,2,3).endsWith(List(1,3))) - assertTrue(List(1,2,3).endsWith(List())) - assertFalse(List(1,2,3).endsWith(List(0,1,2,3))) - assertTrue(List(1,2,3).endsWith(List(1,2,3))) - assertFalse(List().endsWith(List(1,2,3))) - assertTrue(List().endsWith(List())) - } -} - -object Test5 extends TestCase("list pattern matching") { - def show(xs: List[String]) = xs match { - case "foo" :: args => args.toString - case List(x) => x.toString - case Nil => "Nil" - } - override def runTest { - assert(show(List()) == "Nil") - assert(show(List("a")) == "a") - assert(show(List("foo", "b")) == "List(b)") - } -} diff --git a/test/files/run/t2316.scala b/test/files/run/t2316.scala deleted file mode 100644 index a3d5bf890b..0000000000 --- a/test/files/run/t2316.scala +++ /dev/null @@ -1,32 +0,0 @@ -case class T1(source: String) - -object T1 { - implicit def T1FromT2(implicit t2: T2) = new T1(t2.source) -} - -case class T2(source: String) - -object A { - def requireT1(implicit t1: T1) = t1 - - object B1 { - implicit val t2_b1 = new T2("from B1") - requireT1 - } - - object B2 { - def t1 = { - implicit val t2_b2 = new T2("from B2") - // Implicits.cacheResult returns T1.T1FromT2(t2_b1) here, which is bogus. Even though T1.T1FromT2 was found - // outside of the scope of A.B1, this implicit expression should _not_ be cached, as it includes the bound - // variable t2_b1 from this scope. - requireT1 - } - } -} - -object Test { - def main(args: Array[String]) { - assert(A.B2.t1.source == "from B2") - } -} \ No newline at end of file diff --git a/test/files/run/t2316_run.scala b/test/files/run/t2316_run.scala new file mode 100644 index 0000000000..a3d5bf890b --- /dev/null +++ b/test/files/run/t2316_run.scala @@ -0,0 +1,32 @@ +case class T1(source: String) + +object T1 { + implicit def T1FromT2(implicit t2: T2) = new T1(t2.source) +} + +case class T2(source: String) + +object A { + def requireT1(implicit t1: T1) = t1 + + object B1 { + implicit val t2_b1 = new T2("from B1") + requireT1 + } + + object B2 { + def t1 = { + implicit val t2_b2 = new T2("from B2") + // Implicits.cacheResult returns T1.T1FromT2(t2_b1) here, which is bogus. Even though T1.T1FromT2 was found + // outside of the scope of A.B1, this implicit expression should _not_ be cached, as it includes the bound + // variable t2_b1 from this scope. + requireT1 + } + } +} + +object Test { + def main(args: Array[String]) { + assert(A.B2.t1.source == "from B2") + } +} \ No newline at end of file diff --git a/test/files/scalacheck/CheckEither.scala b/test/files/scalacheck/CheckEither.scala new file mode 100644 index 0000000000..0651b90b2e --- /dev/null +++ b/test/files/scalacheck/CheckEither.scala @@ -0,0 +1,194 @@ +import org.scalacheck.{ Arbitrary, ConsoleReporter, Prop, Properties } +import org.scalacheck.Arbitrary.{arbitrary, arbThrowable} +import org.scalacheck.Gen.oneOf +import org.scalacheck.util.StdRand +import org.scalacheck.Prop._ +import org.scalacheck.ConsoleReporter.{testReport, propReport} +import org.scalacheck.Test.{Params, check} +import org.scalacheck.ConsoleReporter.testStatsEx +import Function.tupled + +object CheckEither extends Properties("Either") { + implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = + Arbitrary[Either[X, Y]](oneOf(arbitrary[X].map(Left(_)), arbitrary[Y].map(Right(_)))) + + val prop_either1 = forAll((n: Int) => Left(n).fold(x => x, b => error("fail")) == n) + + val prop_either2 = forAll((n: Int) => Right(n).fold(a => error("fail"), x => x) == n) + + val prop_swap = forAll((e: Either[Int, Int]) => e match { + case Left(a) => e.swap.right.get == a + case Right(b) => e.swap.left.get == b + }) + + val prop_isLeftRight = forAll((e: Either[Int, Int]) => e.isLeft != e.isRight) + + object CheckLeftProjection { + val prop_value = forAll((n: Int) => Left(n).left.get == n) + + val prop_getOrElse = forAll((e: Either[Int, Int], or: Int) => e.left.getOrElse(or) == (e match { + case Left(a) => a + case Right(_) => or + })) + + val prop_forall = forAll((e: Either[Int, Int]) => + e.left.forall(_ % 2 == 0) == (e.isRight || e.left.get % 2 == 0)) + + val prop_exists = forAll((e: Either[Int, Int]) => + e.left.exists(_ % 2 == 0) == (e.isLeft && e.left.get % 2 == 0)) + + val prop_flatMapLeftIdentity = forAll((e: Either[Int, Int], n: Int, s: String) => { + def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s) + Left(n).left.flatMap(f(_)) == f(n)}) + + val prop_flatMapRightIdentity = forAll((e: Either[Int, Int]) => e.left.flatMap(Left(_)) == e) + + val prop_flatMapComposition = forAll((e: Either[Int, Int]) => { + def f(x: Int) = if(x % 2 == 0) Left(x) else Right(x) + def g(x: Int) = if(x % 7 == 0) Right(x) else Left(x) + e.left.flatMap(f(_)).left.flatMap(g(_)) == e.left.flatMap(f(_).left.flatMap(g(_)))}) + + val prop_mapIdentity = forAll((e: Either[Int, Int]) => e.left.map(x => x) == e) + + val prop_mapComposition = forAll((e: Either[String, Int]) => { + def f(s: String) = s.toLowerCase + def g(s: String) = s.reverse + e.left.map(x => f(g(x))) == e.left.map(x => g(x)).left.map(f(_))}) + + val prop_filter = forAll((e: Either[Int, Int], x: Int) => e.left.filter(_ % 2 == 0) == + (if(e.isRight || e.left.get % 2 != 0) None else Some(e))) + + val prop_seq = forAll((e: Either[Int, Int]) => e.left.toSeq == (e match { + case Left(a) => Seq(a) + case Right(_) => Seq.empty + })) + + val prop_option = forAll((e: Either[Int, Int]) => e.left.toOption == (e match { + case Left(a) => Some(a) + case Right(_) => None + })) + } + + object CheckRightProjection { + val prop_value = forAll((n: Int) => Right(n).right.get == n) + + val prop_getOrElse = forAll((e: Either[Int, Int], or: Int) => e.right.getOrElse(or) == (e match { + case Left(_) => or + case Right(b) => b + })) + + val prop_forall = forAll((e: Either[Int, Int]) => + e.right.forall(_ % 2 == 0) == (e.isLeft || e.right.get % 2 == 0)) + + val prop_exists = forAll((e: Either[Int, Int]) => + e.right.exists(_ % 2 == 0) == (e.isRight && e.right.get % 2 == 0)) + + val prop_flatMapLeftIdentity = forAll((e: Either[Int, Int], n: Int, s: String) => { + def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s) + Right(n).right.flatMap(f(_)) == f(n)}) + + val prop_flatMapRightIdentity = forAll((e: Either[Int, Int]) => e.right.flatMap(Right(_)) == e) + + val prop_flatMapComposition = forAll((e: Either[Int, Int]) => { + def f(x: Int) = if(x % 2 == 0) Left(x) else Right(x) + def g(x: Int) = if(x % 7 == 0) Right(x) else Left(x) + e.right.flatMap(f(_)).right.flatMap(g(_)) == e.right.flatMap(f(_).right.flatMap(g(_)))}) + + val prop_mapIdentity = forAll((e: Either[Int, Int]) => e.right.map(x => x) == e) + + val prop_mapComposition = forAll((e: Either[Int, String]) => { + def f(s: String) = s.toLowerCase + def g(s: String) = s.reverse + e.right.map(x => f(g(x))) == e.right.map(x => g(x)).right.map(f(_))}) + + val prop_filter = forAll((e: Either[Int, Int], x: Int) => e.right.filter(_ % 2 == 0) == + (if(e.isLeft || e.right.get % 2 != 0) None else Some(e))) + + val prop_seq = forAll((e: Either[Int, Int]) => e.right.toSeq == (e match { + case Left(_) => Seq.empty + case Right(b) => Seq(b) + })) + + val prop_option = forAll((e: Either[Int, Int]) => e.right.toOption == (e match { + case Left(_) => None + case Right(b) => Some(b) + })) + } + + val prop_Either_left = forAll((n: Int) => Left(n).left.get == n) + + val prop_Either_right = forAll((n: Int) => Right(n).right.get == n) + + val prop_Either_joinLeft = forAll((e: Either[Either[Int, Int], Int]) => e match { + case Left(ee) => e.joinLeft == ee + case Right(n) => e.joinLeft == Right(n) + }) + + val prop_Either_joinRight = forAll((e: Either[Int, Either[Int, Int]]) => e match { + case Left(n) => e.joinRight == Left(n) + case Right(ee) => e.joinRight == ee + }) + + val prop_Either_reduce = forAll((e: Either[Int, Int]) => + e.merge == (e match { + case Left(a) => a + case Right(a) => a + })) + + /** Hard to believe I'm "fixing" a test to reflect B before A ... */ + val prop_Either_cond = forAll((c: Boolean, a: Int, b: Int) => + Either.cond(c, a, b) == (if(c) Right(a) else Left(b))) + + val tests = List( + ("prop_either1", prop_either1), + ("prop_either2", prop_either2), + ("prop_swap", prop_swap), + ("prop_isLeftRight", prop_isLeftRight), + ("Left.prop_value", CheckLeftProjection.prop_value), + ("Left.prop_getOrElse", CheckLeftProjection.prop_getOrElse), + ("Left.prop_forall", CheckLeftProjection.prop_forall), + ("Left.prop_exists", CheckLeftProjection.prop_exists), + ("Left.prop_flatMapLeftIdentity", CheckLeftProjection.prop_flatMapLeftIdentity), + ("Left.prop_flatMapRightIdentity", CheckLeftProjection.prop_flatMapRightIdentity), + ("Left.prop_flatMapComposition", CheckLeftProjection.prop_flatMapComposition), + ("Left.prop_mapIdentity", CheckLeftProjection.prop_mapIdentity), + ("Left.prop_mapComposition", CheckLeftProjection.prop_mapComposition), + ("Left.prop_filter", CheckLeftProjection.prop_filter), + ("Left.prop_seq", CheckLeftProjection.prop_seq), + ("Left.prop_option", CheckLeftProjection.prop_option), + ("Right.prop_value", CheckRightProjection.prop_value), + ("Right.prop_getOrElse", CheckRightProjection.prop_getOrElse), + ("Right.prop_forall", CheckRightProjection.prop_forall), + ("Right.prop_exists", CheckRightProjection.prop_exists), + ("Right.prop_flatMapLeftIdentity", CheckRightProjection.prop_flatMapLeftIdentity), + ("Right.prop_flatMapRightIdentity", CheckRightProjection.prop_flatMapRightIdentity), + ("Right.prop_flatMapComposition", CheckRightProjection.prop_flatMapComposition), + ("Right.prop_mapIdentity", CheckRightProjection.prop_mapIdentity), + ("Right.prop_mapComposition", CheckRightProjection.prop_mapComposition), + ("Right.prop_filter", CheckRightProjection.prop_filter), + ("Right.prop_seq", CheckRightProjection.prop_seq), + ("Right.prop_option", CheckRightProjection.prop_option), + ("prop_Either_left", prop_Either_left), + ("prop_Either_right", prop_Either_right), + ("prop_Either_joinLeft", prop_Either_joinLeft), + ("prop_Either_joinRight", prop_Either_joinRight), + ("prop_Either_reduce", prop_Either_reduce), + ("prop_Either_cond", prop_Either_cond) + ) + + for ((label, prop) <- tests) { + property(label) = prop + } + + import org.scalacheck.{ Test => STest } + + def runTests() = { + STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), this) + } +} + +object Test { + def main(args: Array[String]): Unit = { + CheckEither.runTests() + } +} diff --git a/test/files/scalacheck/array.scala b/test/files/scalacheck/array.scala new file mode 100644 index 0000000000..03c0217180 --- /dev/null +++ b/test/files/scalacheck/array.scala @@ -0,0 +1,37 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ +import util._ +import Buildable._ +import scala.collection.mutable.ArraySeq + +object Test extends Properties("Array") { + /** At this moment the authentic scalacheck Array Builder/Arb bits are commented out. + */ + implicit def arbArray[T](implicit a: Arbitrary[T], m: Manifest[T]): Arbitrary[Array[T]] = + Arbitrary(containerOf[List,T](arbitrary[T]) map (_.toArray)) + + val arrGen: Gen[Array[_]] = oneOf( + arbitrary[Array[Int]], + arbitrary[Array[Array[Int]]], + arbitrary[Array[List[String]]], + arbitrary[Array[String]], + arbitrary[Array[Boolean]], + arbitrary[Array[AnyVal]] + ) + + // inspired by #1857 and #2352 + property("eq/ne") = forAll(arrGen, arrGen) { (c1, c2) => + (c1 eq c2) || (c1 ne c2) + } + + // inspired by #2299 + def smallInt = choose(1, 10) + property("ofDim") = forAll(smallInt, smallInt, smallInt) { (i1, i2, i3) => + val arr = Array.ofDim[String](i1, i2, i3) + val flattened = arr flatMap (x => x) flatMap (x => x) + flattened.length == i1 * i2 * i3 + } +} + diff --git a/test/files/scalacheck/list.scala b/test/files/scalacheck/list.scala new file mode 100644 index 0000000000..1caf35e872 --- /dev/null +++ b/test/files/scalacheck/list.scala @@ -0,0 +1,21 @@ +import org.scalacheck._ +import Prop._ +import Gen._ + +object Test extends Properties("List") { + def sorted(xs: List[Int]) = xs sortWith (_ < _) + + property("concat size") = forAll { (l1: List[Int], l2: List[Int]) => (l1.size + l2.size) == (l1 ::: l2).size } + property("reverse") = forAll { (l1: List[Int]) => l1.reverse.reverse == l1 } + property("toSet") = forAll { (l1: List[Int]) => sorted(l1.toSet.toList) sameElements sorted(l1).distinct } + property("flatten") = forAll { (xxs: List[List[Int]]) => xxs.flatten.length == (xxs map (_.length) sum) } + property("startsWith/take") = forAll { (xs: List[Int], count: Int) => xs startsWith (xs take count) } + property("endsWith/takeRight") = forAll { (xs: List[Int], count: Int) => xs endsWith (xs takeRight count) } + property("fill") = forAll(choose(1, 100)) { count => + forAll { (x: Int) => + val xs = List.fill(count)(x) + (xs.length == count) && (xs.distinct == List(x)) + } + } +} + diff --git a/test/files/scalacheck/primitive-eqeq.scala b/test/files/scalacheck/primitive-eqeq.scala new file mode 100644 index 0000000000..60fe63c207 --- /dev/null +++ b/test/files/scalacheck/primitive-eqeq.scala @@ -0,0 +1,37 @@ +import org.scalacheck._ +import Prop._ +import Gen._ + +object Test extends Properties("==") { + def equalObjectsEqualHashcodes(x: Any, y: Any) = (x != y) || (x == y && x.## == y.##) + + // ticket #2087 + property("short/char") = forAll { (x: Short) => { + val ch: Char = x.toChar + (x == ch) == (ch == x) + } + } + + property("symmetry") = forAll { (x: AnyVal, y: AnyVal) => (x == y) == (y == x) } + property("transitivity") = forAll { (x: AnyVal, y: AnyVal, z: AnyVal) => x != y || y != z || x == z } + + property("##") = forAll { + (x: Short) => { + val anyvals = List(x.toByte, x.toChar, x, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x)) + val shortAndLarger = anyvals drop 2 + + val result = ( + ((anyvals, anyvals).zipped forall equalObjectsEqualHashcodes) && + ((shortAndLarger, shortAndLarger).zipped forall (_ == _)) && + ((shortAndLarger, shortAndLarger).zipped forall ((x, y) => (x: Any) == (y: Any))) + ) + result + } + } + property("## 2") = forAll { + (dv: Double) => { + val fv = dv.toFloat + (fv != dv) || (fv.## == dv.##) + } + } +} diff --git a/test/files/scalacheck/range.scala b/test/files/scalacheck/range.scala new file mode 100644 index 0000000000..b14177e38b --- /dev/null +++ b/test/files/scalacheck/range.scala @@ -0,0 +1,206 @@ +import org.scalacheck._ +import Prop._ +import Gen._ +import Arbitrary._ + +class Counter(r: Range) { + var cnt = 0L + var last: Option[Int] = None + val str = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")") + def apply(x: Int) = { + cnt += 1L + if (cnt % 500000000L == 0L) { + println("Working: %s %d %d" format (str, cnt, x)) + } + if (cnt > (Int.MaxValue.toLong + 1) * 2) + error("Count exceeds maximum possible for an Int Range") + if ((r.step > 0 && last.exists(_ > x)) || (r.step < 0 && last.exists(_ < x))) + error("Range wrapped: %d %s" format (x, last.toString)) + last = Some(x) + } +} + +abstract class RangeTest(kind: String) extends Properties("Range "+kind) { + def myGen: Gen[Range] + + val genRange = for { + start <- arbitrary[Int] + end <- arbitrary[Int] + step <- Gen.choose(1, (start - end).abs + 1) + } yield if (start < end) Range(start, end, step) else Range(start, end, -step) + + val genReasonableSizeRange = for { + start <- choose(-Int.MinValue, Int.MaxValue) + end <- choose(-Int.MinValue, Int.MaxValue) + step <- choose(-Int.MaxValue, Int.MaxValue) + } yield Range(start, end, if (step == 0) 100 else step) + + val genSmallRange = for { + start <- choose(-100, 100) + end <- choose(-100, 100) + step <- choose(1, 1) + } yield if (start < end) Range(start, end, step) else Range(start, end, -step) + + val genRangeByOne = for { + start <- arbitrary[Int] + end <- arbitrary[Int] + if (end.toLong - start.toLong).abs <= 10000000L + } yield if (start < end) Range(start, end) else Range(end, start) + + def str(r: Range) = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")") + + def expectedSize(r: Range): Long = if (r.isInclusive) { + (r.end.toLong - r.start.toLong < 0, r.step < 0) match { + case (true, true) | (false, false) => (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong + 1L + case _ => if (r.start == r.end) 1L else 0L + } + } else { + (r.end.toLong - r.start.toLong < 0, r.step < 0) match { + case (true, true) | (false, false) => ( + (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong + + (if ((r.end.toLong - r.start.toLong).abs % r.step.abs.toLong > 0L) 1L else 0L) + ) + case _ => 0L + } + } + + def within(r: Range, x: Int) = if (r.step > 0) + r.start <= x && (if (r.isInclusive) x <= r.end else x < r.end) + else + r.start >= x && (if (r.isInclusive) x >= r.end else x > r.end) + + def multiple(r: Range, x: Int) = (x.toLong - r.start) % r.step == 0 + + property("foreach.step") = forAll(myGen) { r => + var allValid = true + val cnt = new Counter(r) +// println("--------------------") +// println(r) + r foreach { x => cnt(x) +// println(x + ", " + (x - r.start) + ", " + (x.toLong - r.start) + ", " + ((x.toLong - r.start) % r.step)) + allValid &&= multiple(r, x) + } + allValid :| str(r) + } + + property("foreach.inside.range") = forAll(myGen) { r => + var allValid = true + var last: Option[Int] = None + val cnt = new Counter(r) + r foreach { x => cnt(x) + allValid &&= within(r, x) + } + allValid :| str(r) + } + + property("foreach.visited.size") = forAll(myGen) { r => + var visited = 0L + val cnt = new Counter(r) + r foreach { x => cnt(x) + visited += 1L + } +// println("----------") +// println(str(r)) +// println("size: " + r.size) +// println("expected: " + expectedSize(r)) +// println("visited: " + visited) + (visited == expectedSize(r)) :| str(r) + } + + property("length") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => + (r.length == expectedSize(r)) :| str(r) + } + + property("isEmpty") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => + (r.isEmpty == (expectedSize(r) == 0L)) :| str(r) + } + + property("contains") = forAll(myGen, arbInt.arbitrary) { (r, x) => +// println("----------------") +// println(str(r)) +// println(x) +// println("within: " + within(r, x)) +// println("multiple: " + multiple(r, x)) +// println("contains: " + r.contains(x)) + ((within(r, x) && multiple(r, x)) == r.contains(x)) :| str(r)+": "+x + } + + property("take") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => + val t = r take x + (t.size == (0 max x min r.size) && t.start == r.start && t.step == r.step) :| str(r)+" / "+str(t)+": "+x + } + + property("takeWhile") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => + val t = (if (r.step > 0) r takeWhile (_ <= x) else r takeWhile(_ >= x)) + if (r.size == 0) { + (t.size == 0) :| str(r)+" / "+str(t)+": "+x + } else { + val t2 = (if (r.step > 0) Range(r.start, x min r.last, r.step).inclusive else Range(r.start, x max r.last, r.step).inclusive) + (t.start == r.start && t.size == t2.size && t.step == r.step) :| str(r)+" / "+str(t)+" / "+str(t2)+": "+x + } + } + + property("reverse.toSet.equal") = forAll(myGen) { r => + val reversed = r.reverse + val aresame = r.toSet == reversed.toSet + if (!aresame) { + println(str(r)) + println(r) + println(reversed) + println(r.toSet) + println(reversed.toSet) + } + aresame + } +} + +object NormalRangeTest extends RangeTest("normal") { + override def myGen = genReasonableSizeRange + def genOne = for { + start <- arbitrary[Int] + end <- arbitrary[Int] + if (start.toLong - end.toLong).abs < Int.MaxValue.toLong + } yield Range(start, end, if (start < end) 1 else - 1) + property("by 1.size + 1 == inclusive.size") = forAll(genOne) { r => + (r.size + 1 == r.inclusive.size) :| str(r) + } +} + +object InclusiveRangeTest extends RangeTest("inclusive") { + override def myGen = for (r <- genReasonableSizeRange) yield r.inclusive +} + +object ByOneRangeTest extends RangeTest("byOne") { + override def myGen = genSmallRange +} + +object InclusiveByOneRangeTest extends RangeTest("inclusiveByOne") { + override def myGen = for (r <- genSmallRange) yield r.inclusive +} + +object SmallValuesRange extends RangeTest("smallValues") { + override def myGen = genSmallRange +} + +object Test extends Properties("Range") { + import org.scalacheck.{ Test => STest } + + List(NormalRangeTest, InclusiveRangeTest, ByOneRangeTest, InclusiveByOneRangeTest) foreach { ps => + STest.checkProperties(STest.Params(testCallback = ConsoleReporter(0)), ps) + } +} + +/* Mini-benchmark +def testRange(i: Int, j: Int, k: Int) = { + var count = 0 + for { + vi <- 0 to i + vj <- 0 to j + vk <- 0 to k + } { count += 1 } +} + +testRange(10, 1000, 10000) +testRange(10000, 1000, 10) +*/ + diff --git a/test/files/scalacheck/scan.scala b/test/files/scalacheck/scan.scala new file mode 100644 index 0000000000..e9b25ce3df --- /dev/null +++ b/test/files/scalacheck/scan.scala @@ -0,0 +1,17 @@ +import org.scalacheck._ +import Prop._ +import Gen._ + + +object Test extends Properties("TraversableLike.scanLeft") { + property("scanLeft") = forAll { (xs: List[Int], z: Int) => { + val sums = xs.scanLeft(z)(_ + _) + (xs.size == 0) || sums.zip(sums.tail).map(x => x._2 - x._1) == xs + }} +} + + + + + + diff --git a/test/files/scalacheck/substringTests.scala b/test/files/scalacheck/substringTests.scala new file mode 100644 index 0000000000..2cb5fc0498 --- /dev/null +++ b/test/files/scalacheck/substringTests.scala @@ -0,0 +1,21 @@ +import org.scalacheck._ + + +object Test extends Properties("String") { + property("startsWith") = Prop.forAll((a: String, b: String) => (a+b).startsWith(a)) + + property("endsWith") = Prop.forAll((a: String, b: String) => (a+b).endsWith(b)) + + // Is this really always true? + property("concat") = Prop.forAll((a: String, b: String) => + (a+b).length > a.length && (a+b).length > b.length + ) + + property("substring") = Prop.forAll((a: String, b: String) => + (a+b).substring(a.length) == b + ) + + property("substring") = Prop.forAll((a: String, b: String, c: String) => + (a+b+c).substring(a.length, a.length+b.length) == b + ) +} diff --git a/test/files/scalacheck/test2.scala b/test/files/scalacheck/test2.scala deleted file mode 100644 index 2cb5fc0498..0000000000 --- a/test/files/scalacheck/test2.scala +++ /dev/null @@ -1,21 +0,0 @@ -import org.scalacheck._ - - -object Test extends Properties("String") { - property("startsWith") = Prop.forAll((a: String, b: String) => (a+b).startsWith(a)) - - property("endsWith") = Prop.forAll((a: String, b: String) => (a+b).endsWith(b)) - - // Is this really always true? - property("concat") = Prop.forAll((a: String, b: String) => - (a+b).length > a.length && (a+b).length > b.length - ) - - property("substring") = Prop.forAll((a: String, b: String) => - (a+b).substring(a.length) == b - ) - - property("substring") = Prop.forAll((a: String, b: String, c: String) => - (a+b+c).substring(a.length, a.length+b.length) == b - ) -} diff --git a/test/partest-tests/jvm/actor-receivewithin.check b/test/partest-tests/jvm/actor-receivewithin.check deleted file mode 100644 index a6a3e88c61..0000000000 --- a/test/partest-tests/jvm/actor-receivewithin.check +++ /dev/null @@ -1,16 +0,0 @@ -'msg -'msg -'msg -'msg -'msg -TIMEOUT -TIMEOUT -TIMEOUT -TIMEOUT -TIMEOUT -'msg2 -'msg2 -'msg2 -'msg2 -'msg2 -TIMEOUT diff --git a/test/partest-tests/jvm/actor-receivewithin.scala b/test/partest-tests/jvm/actor-receivewithin.scala deleted file mode 100644 index a5c87c2722..0000000000 --- a/test/partest-tests/jvm/actor-receivewithin.scala +++ /dev/null @@ -1,69 +0,0 @@ -import scala.actors.{Actor, TIMEOUT} - -object A extends Actor { - def act() { - receive { - case 'done => - var cnt = 0 - while (cnt < 500) { - cnt += 1 - receiveWithin (0) { - case 'msg => - if (cnt % 100 == 0) - println("'msg") - case TIMEOUT => - // should not happen - println("FAIL1") - } - } - cnt = 0 - while (cnt < 500) { - cnt += 1 - receiveWithin (0) { - case 'msg => - // should not happen - println("FAIL2") - case TIMEOUT => - if (cnt % 100 == 0) - println("TIMEOUT") - } - } - B ! 'next - receive { case 'done => } - cnt = 0 - while (cnt < 501) { - cnt += 1 - receiveWithin (500) { - case 'msg2 => - if (cnt % 100 == 0) - println("'msg2") - case TIMEOUT => - println("TIMEOUT") - } - } - } - } -} - -object B extends Actor { - def act() { - A.start() - for (_ <- 1 to 500) { - A ! 'msg - } - A ! 'done - receive { - case 'next => - for (_ <- 1 to 500) { - A ! 'msg2 - } - A ! 'done - } - } -} - -object Test { - def main(args:Array[String]) { - B.start() - } -} diff --git a/test/partest-tests/run/crash.scala b/test/partest-tests/run/crash.scala deleted file mode 100644 index 1735cc444e..0000000000 --- a/test/partest-tests/run/crash.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - val t = new Throwable("DOOM") - throw t - } -} diff --git a/test/partest-tests/run/streamWithFilter.check b/test/partest-tests/run/streamWithFilter.check deleted file mode 100644 index 6b0e91a147..0000000000 --- a/test/partest-tests/run/streamWithFilter.check +++ /dev/null @@ -1,5 +0,0 @@ -15 -30 -45 -60 -75 diff --git a/test/partest-tests/run/streamWithFilter.scala b/test/partest-tests/run/streamWithFilter.scala deleted file mode 100644 index cb919d4f55..0000000000 --- a/test/partest-tests/run/streamWithFilter.scala +++ /dev/null @@ -1,11 +0,0 @@ -object Test { - val nums = Stream.from(1) - def isFizz(x: Int) = x % 3 == 0 - def isBuzz(x: Int) = x % 5 == 0 - // next line will run forever if withFilter isn't doing its thing. - val fizzbuzzes = for (n <- nums ; if isFizz(n) ; if isBuzz(n)) yield n - - def main(args: Array[String]): Unit = { - fizzbuzzes take 5 foreach println - } -} diff --git a/test/partest-tests/run/timeout.scala b/test/partest-tests/run/timeout.scala deleted file mode 100644 index 91417b39ab..0000000000 --- a/test/partest-tests/run/timeout.scala +++ /dev/null @@ -1,5 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - Thread.sleep(10000000) - } -} diff --git a/test/pending/neg/t1477.scala b/test/pending/neg/t1477.scala deleted file mode 100644 index 0cc0cd5f7a..0000000000 --- a/test/pending/neg/t1477.scala +++ /dev/null @@ -1,25 +0,0 @@ -object Test extends Application { - trait A - trait B extends A - - trait C { - type U - trait D { type T >: B <: A } - type V <: D - val y: V#T = new B { } - } - - trait Middle extends C { - type V <: (D with U) - } - - class D extends Middle { - trait E - trait F { type T = E } - type U = F - def frob(arg : E) : E = arg - frob(y) - } - - new D -} diff --git a/test/pending/pos/bug2018.scala b/test/pending/pos/bug2018.scala deleted file mode 100644 index f1753f4d7a..0000000000 --- a/test/pending/pos/bug2018.scala +++ /dev/null @@ -1,15 +0,0 @@ -class A { - val b = new B - - def getChildren = List(new A).elements - - class B { - private def check = true - - private def getAncestor(p: A): A = { - val c = (p.getChildren.find(_.b.check)) match {case Some(d) => d case None => p} - - if (c == p) p else c.b.getAncestor(c) - } - } -} diff --git a/test/pending/pos/bug3420.flags b/test/pending/pos/bug3420.flags deleted file mode 100644 index ea03113c66..0000000000 --- a/test/pending/pos/bug3420.flags +++ /dev/null @@ -1 +0,0 @@ --optimise -Xfatal-warnings \ No newline at end of file diff --git a/test/pending/pos/bug3420.scala b/test/pending/pos/bug3420.scala deleted file mode 100644 index 0fc56ed67b..0000000000 --- a/test/pending/pos/bug3420.scala +++ /dev/null @@ -1,5 +0,0 @@ -class C { - val cv = Map[Int, Int](1 -> 2) - lazy val cl = Map[Int, Int](1 -> 2) - def cd = Map[Int, Int](1 -> 2) -} diff --git a/test/pending/pos/bug563.scala b/test/pending/pos/bug563.scala deleted file mode 100644 index d559226bdb..0000000000 --- a/test/pending/pos/bug563.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test { - def map[A,R](a : List[A], f : A => R) : List[R] = a.map(f); - - def split(sn : Iterable[List[Cell[int]]]) : unit = - for (val n <- sn) - map(n,ptr => new Cell(ptr.elem)); -} diff --git a/test/pending/pos/foo.scala b/test/pending/pos/foo.scala deleted file mode 100644 index 8b45addbd5..0000000000 --- a/test/pending/pos/foo.scala +++ /dev/null @@ -1,3 +0,0 @@ -object foo { - var x: String -} diff --git a/test/pending/pos/t0716.scala b/test/pending/pos/t0716.scala deleted file mode 100644 index 98ba9bb2aa..0000000000 --- a/test/pending/pos/t0716.scala +++ /dev/null @@ -1,24 +0,0 @@ -trait Functor[F[_]] { - def fmap[A,B](fun: A=>B, arg:F[A]): F[B] -} -object Functor{ - implicit val ListFunctor = new Functor[List] { - def fmap[A, B](f: A => B, arg: List[A]):List[B] = arg map f - } - - final class OOFunctor[F[_],A](arg:F[A])(implicit ftr: Functor[F]) { - def fmap[B](fun: A=>B):F[B] = ftr.fmap(fun,arg) - } - - //breaks if uncommented - implicit def lifttoOO[F[_],A](arg:F[A])(implicit ftr: Functor[F]) = new OOFunctor[F,A](arg)(ftr) - - //works if uncommented - //implicit def liftListtoOO[A](arg:List[A]):OOFunctor[List,A] = new OOFunctor[List,A](arg) -} - -object GeneralLiftingDemo extends Application { - import Functor._ - val l = List(1,2,3) - println("OO : " + l.fmap( 1+) ) -} diff --git a/test/pending/pos/t2162.scala b/test/pending/pos/t2162.scala deleted file mode 100644 index b21404726b..0000000000 --- a/test/pending/pos/t2162.scala +++ /dev/null @@ -1,20 +0,0 @@ -// crash verified; no solution yet -class Foo(x: Int) -class Bar extends Foo(1) - -trait A { - def foo[T <: Foo] -} -class B extends A { - def foo[Bar] { println("B.foo[Bar]") } -} -object test { - val x = new B - val y = new A { - def foo[Bar] { println("A.foo[Bar]") } - } - def main(args: Array[String]) { - x.foo // ok - y.foo // java.lang.AssertionError: assertion failed (Erasure.scala:441 in r18338)) - } -} diff --git a/test/pending/pos/t2179.scala b/test/pending/pos/t2179.scala deleted file mode 100644 index fd37d8f760..0000000000 --- a/test/pending/pos/t2179.scala +++ /dev/null @@ -1,6 +0,0 @@ -on trunk r18368, this delightful little poison pill: - -(Nil:List[List[Double]]).reduceLeft((_: Any, _: Any) => Nil.indices.map(_ => 0d)) - -sends the compiler into an apparently infinite loop. a sample thread dump shows: - diff --git a/test/pending/pos/t2635.scala b/test/pending/pos/t2635.scala deleted file mode 100644 index 378631b23d..0000000000 --- a/test/pending/pos/t2635.scala +++ /dev/null @@ -1,16 +0,0 @@ -abstract class Base - -object Test -{ - def run(c: Class[_ <: Base]): Unit = { - } - - def main(args: Array[String]): Unit = - { - val sc: Option[Class[_ <: Base]] = Some(classOf[Base]) - sc match { - case Some((c: Class[_ <: Base])) => run(c) - case None => - } - } -} \ No newline at end of file diff --git a/test/pending/pos/t2641.scala b/test/pending/pos/t2641.scala deleted file mode 100644 index fec825c4f9..0000000000 --- a/test/pending/pos/t2641.scala +++ /dev/null @@ -1,16 +0,0 @@ -import scala.collection._ -import scala.collection.generic._ - -abstract class ManagedSeqStrict[+A] - extends Traversable[A] - with GenericTraversableTemplate[A, ManagedSeqStrict] - -trait ManagedSeq[+A, +Coll] - extends ManagedSeqStrict[A] - with TraversableView[A, ManagedSeqStrict[A]] - with TraversableViewLike[A, ManagedSeqStrict[A], ManagedSeq[A/*ERROR: too few type args*/]] -{ self => - trait Transformed[+B] extends ManagedSeq[B, Coll] with super.Transformed[B] - - trait Sliced extends Transformed[A] with super.Sliced -} \ No newline at end of file diff --git a/test/pending/pos/t3636.scala b/test/pending/pos/t3636.scala deleted file mode 100644 index 24d18c653d..0000000000 --- a/test/pending/pos/t3636.scala +++ /dev/null @@ -1,49 +0,0 @@ -class CTxnLocal[ T ] { - def set( x: T )( implicit t: Txn ) {} - def get( implicit t: Txn ) : T = null.asInstanceOf[ T ] - def initialValue( t: Txn ) : T = null.asInstanceOf[ T ] -} - -trait Txn - -trait ProcTxn { - def ccstm: Txn -} - -trait TxnLocal[ @specialized T ] { - def apply()( implicit tx: ProcTxn ) : T - def set( v: T )( implicit tx: ProcTxn ) : Unit - def swap( v: T )( implicit tx: ProcTxn ) : T - def transform( f: T => T )( implicit tx: ProcTxn ) : Unit -} - -object TxnLocal { - def apply[ @specialized T ] : TxnLocal[ T ] = new Impl( new CTxnLocal[ T ]) - def apply[ @specialized T ]( initValue: => T ) : TxnLocal[ T ] = new Impl( new CTxnLocal[ T ] { - override def initialValue( tx: Txn ): T = initValue - }) - - private class Impl[ T ]( c: CTxnLocal[ T ]) extends TxnLocal[ T ] { - def apply()( implicit tx: ProcTxn ) : T = c.get( tx.ccstm ) - def set( v: T )( implicit tx: ProcTxn ) : Unit = c.set( v )( tx.ccstm ) - def swap( v: T )( implicit tx: ProcTxn ) : T = { - // currently not implemented in CTxnLocal - val oldV = apply - set( v ) - oldV - } - def transform( f: T => T )( implicit tx: ProcTxn ) { - set( f( apply )) - } - } -} - - -object Transition { - private val currentRef = TxnLocal[ Transition ]( Instant ) - def current( implicit tx: ProcTxn ) : Transition = currentRef() -} - -sealed abstract class Transition -case object Instant extends Transition - diff --git a/test/pending/run/bug1006.scala b/test/pending/run/bug1006.scala deleted file mode 100644 index 0a82373fb6..0000000000 --- a/test/pending/run/bug1006.scala +++ /dev/null @@ -1,13 +0,0 @@ -object foo { - def main(args: Array[String]) { - abstract class A[T] { - def myVal: T - } - - class B[T](value: T) extends A[T] { - def myVal = value - } - - Console.println(new B[int](23).myVal) - } -} diff --git a/test/pending/run/bug2087.scala b/test/pending/run/bug2087.scala deleted file mode 100644 index b3f96fa415..0000000000 --- a/test/pending/run/bug2087.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test { - def main(args: Array[String]): Unit = { - val s: Short = 0xFA99.toShort - val c: Char = 0xFA99.toChar - - assert((s == c) == (c == s)) - } -} \ No newline at end of file diff --git a/test/pending/run/bug2365/Test.scala b/test/pending/run/bug2365/Test.scala deleted file mode 100644 index 92b58f4a25..0000000000 --- a/test/pending/run/bug2365/Test.scala +++ /dev/null @@ -1,35 +0,0 @@ -import scala.tools.nsc.io._ -import java.net.URL - -object A { def apply(d: { def apply(): Int}) = d.apply() } -object A2 { def apply(d: { def apply(): Int}) = d.apply() } -object A3 { def apply(d: { def apply(): Int}) = d.apply() } -object A4 { def apply(d: { def apply(): Int}) = d.apply() } - -class B extends Function0[Int] { - def apply() = 3 -} - -object Test -{ - type StructF0 = { def apply(): Int } - def main(args: Array[String]) { - for(i <- 0 until 150) - println(i + " " + test(A.apply) + " " + test(A2.apply) + " " + test(A3.apply) + " " + test(A3.apply)) - } - - def test(withF0: StructF0 => Int): Int = { - // Some large jar - val ivyJar = File("/local/lib/java/ivy.jar").toURL - // load a class in a separate loader that will be passed to A - val loader = new java.net.URLClassLoader(Array(File(".").toURL, ivyJar)) - // load a real class to fill perm gen space - Class.forName("org.apache.ivy.Ivy", true, loader).newInstance - // create a class from another class loader with an apply: Int method - val b = Class.forName("B", true, loader).newInstance - - // pass instance to a, which will call apply using structural type reflection. - // This should hold on to the class for B, which means bLoader will not get collected - withF0(b.asInstanceOf[StructF0]) - } -} diff --git a/test/pending/run/bug2365/bug2365.javaopts b/test/pending/run/bug2365/bug2365.javaopts deleted file mode 100644 index 357e033c1c..0000000000 --- a/test/pending/run/bug2365/bug2365.javaopts +++ /dev/null @@ -1 +0,0 @@ --XX:MaxPermSize=25M diff --git a/test/pending/run/bug2365/run b/test/pending/run/bug2365/run deleted file mode 100755 index f3c44ad086..0000000000 --- a/test/pending/run/bug2365/run +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# This script should fail with any build of scala where #2365 -# is not fixed, and otherwise succeed. Failure means running out -# of PermGen space. - -CP=.:/local/lib/java/ivy.jar -# SCALAC=/scala/inst/28/bin/scalac -SCALAC=scalac -RUN_OPTS="-XX:MaxPermSize=25M -verbose:gc" - -$SCALAC -cp $CP *.scala -JAVA_OPTS="${RUN_OPTS}" scala -cp $CP Test diff --git a/test/pending/run/bug3150.scala b/test/pending/run/bug3150.scala deleted file mode 100644 index 034703b5f7..0000000000 --- a/test/pending/run/bug3150.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test { - case object Bob { override def equals(other: Any) = true } - def f(x: Any) = x match { case Bob => Bob } - - def main(args: Array[String]): Unit = { - assert(f(Bob) eq Bob) - assert(f(0) eq Bob) - assert(f(Nil) eq Bob) - } -} diff --git a/test/pending/run/castsingleton.scala b/test/pending/run/castsingleton.scala deleted file mode 100644 index 171b380dc9..0000000000 --- a/test/pending/run/castsingleton.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test extends Application { - case class L(); - object N extends L(); - - def empty(xs : L) : Unit = xs match { - case x@N => println(x); println(x); - } - - empty(L()) -} diff --git a/test/pending/run/t0807.scala b/test/pending/run/t0807.scala deleted file mode 100644 index e69aa1c71c..0000000000 --- a/test/pending/run/t0807.scala +++ /dev/null @@ -1,5 +0,0 @@ -trait A -trait B extends A { val x = println("early") } -object Test extends Application { - new B {} -} diff --git a/test/pending/run/t1939.scala b/test/pending/run/t1939.scala deleted file mode 100644 index 44ab1769d2..0000000000 --- a/test/pending/run/t1939.scala +++ /dev/null @@ -1,41 +0,0 @@ -// works in trunk -class Module {} - -abstract class T { - type moduleType <: Module - def module: moduleType -} - -final class T1(val module: Module) extends T { - type moduleType = Module -} - -final class T2(_module: Module) extends T { - type moduleType = Module - - def module = _module -} - -object Main extends Application { - - type mType = Module - - type tType = T { type moduleType <: mType } - // type tType = T { type moduleType <: Module } // runs successfully - // type tType = T // runs successfully - - def f(ts: List[tType]): Unit = { - - for (t <- ts; m = t.module) {} - ts.map(_.module).foreach { _ => () } - // ts.map(t => (t : T).module).foreach { _ => () } // runs successfully - } - - f(new T1(new Module) :: new T2(new Module) :: Nil) -} - -/* - * java.lang.AbstractMethodError - at scala.List.foreach(List.scala:849) - at Main$.f -*/ diff --git a/test/pending/scalacheck/CheckEither.scala b/test/pending/scalacheck/CheckEither.scala deleted file mode 100644 index a6c728451b..0000000000 --- a/test/pending/scalacheck/CheckEither.scala +++ /dev/null @@ -1,253 +0,0 @@ - -// To run these tests: -// 1) wget http://scalacheck.googlecode.com/files/ScalaCheck-1.2.jar -// 2) scalac -classpath ScalaCheck-1.2.jar Either.scala -// 3) scala -classpath .:ScalaCheck-1.2.jar scala.CheckEither -// 4) observe passing tests - -import org.scalacheck.Arbitrary -import org.scalacheck.Arbitrary.{arbitrary, arbThrowable} -import org.scalacheck.Gen.oneOf -import org.scalacheck.{Prop, StdRand} -import org.scalacheck.Prop._ -import org.scalacheck.ConsoleReporter.{testReport, propReport} -import org.scalacheck.Test.{Params, check} -import org.scalacheck.ConsoleReporter.testStatsEx -import Function.tupled - -object CheckEither { - implicit def arbitraryEither[X, Y](implicit xa: Arbitrary[X], ya: Arbitrary[Y]): Arbitrary[Either[X, Y]] = - Arbitrary[Either[X, Y]](oneOf(arbitrary[X].map(Left(_)), arbitrary[Y].map(Right(_)))) - - val prop_either1 = property((n: Int) => Left(n).either(x => x, b => error("fail")) == n) - - val prop_either2 = property((n: Int) => Right(n).either(a => error("fail"), x => x) == n) - - val prop_swap = property((e: Either[Int, Int]) => e match { - case Left(a) => e.swap.right.value == a - case Right(b) => e.swap.left.value == b - }) - - val prop_isLeftRight = property((e: Either[Int, Int]) => e.isLeft != e.isRight) - - object CheckLeftProjection { - val prop_valueE = property((n: Int, s: String) => Left(n).left.valueE(s) == n) - - val prop_value = property((n: Int) => Left(n).left.value == n) - - val prop_on = property((e: Either[Int, Int]) => e.left.on((_: Int) + 1) == (e match { - case Left(a) => a - case Right(b) => b + 1 - })) - - val prop_getOrElse = property((e: Either[Int, Int], or: Int) => e.left.getOrElse(or) == (e match { - case Left(a) => a - case Right(_) => or - })) - - val prop_forall = property((e: Either[Int, Int]) => - e.left.forall(_ % 2 == 0) == (e.isRight || e.left.value % 2 == 0)) - - val prop_exists = property((e: Either[Int, Int]) => - e.left.exists(_ % 2 == 0) == (e.isLeft && e.left.value % 2 == 0)) - - val prop_flatMapLeftIdentity = property((e: Either[Int, Int], n: Int, s: String) => { - def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s) - Left(n).left.flatMap(f(_)) == f(n)}) - - val prop_flatMapRightIdentity = property((e: Either[Int, Int]) => e.left.flatMap(Left(_)) == e) - - val prop_flatMapComposition = property((e: Either[Int, Int]) => { - def f(x: Int) = if(x % 2 == 0) Left(x) else Right(x) - def g(x: Int) = if(x % 7 == 0) Right(x) else Left(x) - e.left.flatMap(f(_)).left.flatMap(g(_)) == e.left.flatMap(f(_).left.flatMap(g(_)))}) - - val prop_mapIdentity = property((e: Either[Int, Int]) => e.left.map(x => x) == e) - - val prop_mapComposition = property((e: Either[String, Int]) => { - def f(s: String) = s.toLowerCase - def g(s: String) = s.reverse - e.left.map(x => f(g(x))) == e.left.map(x => g(x)).left.map(f(_))}) - - val prop_filter = property((e: Either[Int, Int], x: Int) => e.left.filter(_ % 2 == 0) == - (if(e.isRight || e.left.value % 2 != 0) None else Some(e))) - - val prop_ap = property((e1: Either[Int, Int], e2: Either[Int, Int]) => { - val ee2 = e2.left map (n => (x: Int) => x + n) - e1.left.ap(ee2) == (ee2 match { - case Left(f) => e1 match { - case Left(a) => Left(f(a)) - case Right(b) => Right(b) - } - case Right(b) => Right(b) - }) - }) - - val prop_seq = property((e: Either[Int, Int]) => e.left.seq == (e match { - case Left(a) => Seq.singleton(a) - case Right(_) => Seq.empty - })) - - val prop_option = property((e: Either[Int, Int]) => e.left.option == (e match { - case Left(a) => Some(a) - case Right(_) => None - })) - } - - object CheckRightProjection { - val prop_valueE = property((n: Int, s: String) => Right(n).right.valueE(s) == n) - - val prop_value = property((n: Int) => Right(n).right.value == n) - - val prop_on = property((e: Either[Int, Int]) => e.right.on((_: Int) + 1) == (e match { - case Left(a) => a + 1 - case Right(b) => b - })) - - val prop_getOrElse = property((e: Either[Int, Int], or: Int) => e.right.getOrElse(or) == (e match { - case Left(_) => or - case Right(b) => b - })) - - val prop_forall = property((e: Either[Int, Int]) => - e.right.forall(_ % 2 == 0) == (e.isLeft || e.right.value % 2 == 0)) - - val prop_exists = property((e: Either[Int, Int]) => - e.right.exists(_ % 2 == 0) == (e.isRight && e.right.value % 2 == 0)) - - val prop_flatMapLeftIdentity = property((e: Either[Int, Int], n: Int, s: String) => { - def f(x: Int) = if(x % 2 == 0) Left(s) else Right(s) - Right(n).right.flatMap(f(_)) == f(n)}) - - val prop_flatMapRightIdentity = property((e: Either[Int, Int]) => e.right.flatMap(Right(_)) == e) - - val prop_flatMapComposition = property((e: Either[Int, Int]) => { - def f(x: Int) = if(x % 2 == 0) Left(x) else Right(x) - def g(x: Int) = if(x % 7 == 0) Right(x) else Left(x) - e.right.flatMap(f(_)).right.flatMap(g(_)) == e.right.flatMap(f(_).right.flatMap(g(_)))}) - - val prop_mapIdentity = property((e: Either[Int, Int]) => e.right.map(x => x) == e) - - val prop_mapComposition = property((e: Either[Int, String]) => { - def f(s: String) = s.toLowerCase - def g(s: String) = s.reverse - e.right.map(x => f(g(x))) == e.right.map(x => g(x)).right.map(f(_))}) - - val prop_filter = property((e: Either[Int, Int], x: Int) => e.right.filter(_ % 2 == 0) == - (if(e.isLeft || e.right.value % 2 != 0) None else Some(e))) - - val prop_ap = property((e1: Either[Int, Int], e2: Either[Int, Int]) => { - val ee2 = e2.right map (n => (x: Int) => x + n) - e1.right.ap(ee2) == (ee2 match { - case Left(a) => Left(a) - case Right(f) => e1 match { - case Left(a) => Left(a) - case Right(b) => Right(f(b)) - } - }) - }) - - val prop_seq = property((e: Either[Int, Int]) => e.right.seq == (e match { - case Left(_) => Seq.empty - case Right(b) => Seq.singleton(b) - })) - - val prop_option = property((e: Either[Int, Int]) => e.right.option == (e match { - case Left(_) => None - case Right(b) => Some(b) - })) - } - - val prop_Either_left = property((n: Int) => Either.left(n).left.value == n) - - val prop_Either_right = property((n: Int) => Either.right(n).right.value == n) - - val prop_Either_joinLeft = property((e: Either[Either[Int, Int], Int]) => e match { - case Left(ee) => Either.joinLeft(e) == ee - case Right(n) => Either.joinLeft(e) == Right(n) - }) - - val prop_Either_joinRight = property((e: Either[Int, Either[Int, Int]]) => e match { - case Left(n) => Either.joinRight(e) == Left(n) - case Right(ee) => Either.joinRight(e) == ee - }) - - val prop_Either_lefts = property((es: List[Either[Int, Int]]) => - Either.lefts(es) == es.filter(_.isLeft).map(_.left.value)) - - val prop_Either_rights = property((es: List[Either[Int, Int]]) => - Either.rights(es) == es.filter(_.isRight).map(_.right.value)) - - val prop_Either_leftRights = property((es: List[Either[Int, Int]]) => - Either.rights(es) == es.filter(_.isRight).map(_.right.value)) - - val prop_Either_throws = property((n: Int) => - Either.throws(n) == Right(n) && Either.throws(error("error")).isLeft) - - val prop_Either_throwIt = property((e: Either[Throwable, Int]) => - try { - Either.throwIt(e) == e.right.value - } catch { - case (t) => e.isLeft && e.left.value == t - }) - - val prop_Either_reduce = property((e: Either[Int, Int]) => - Either.reduce(e) == (e match { - case Left(a) => a - case Right(a) => a - })) - - val prop_Either_iif = property((c: Boolean, a: Int, b: Int) => - Either.iif(c, a, b) == (if(c) Right(b) else Left(a))) - - val tests = List( - ("prop_either1", prop_either1), - ("prop_either2", prop_either2), - ("prop_swap", prop_swap), - ("prop_isLeftRight", prop_isLeftRight), - ("Left.prop_valueE", CheckLeftProjection.prop_valueE), - ("Left.prop_value", CheckLeftProjection.prop_value), - ("Left.prop_getOrElse", CheckLeftProjection.prop_getOrElse), - ("Left.prop_forall", CheckLeftProjection.prop_forall), - ("Left.prop_exists", CheckLeftProjection.prop_exists), - ("Left.prop_flatMapLeftIdentity", CheckLeftProjection.prop_flatMapLeftIdentity), - ("Left.prop_flatMapRightIdentity", CheckLeftProjection.prop_flatMapRightIdentity), - ("Left.prop_flatMapComposition", CheckLeftProjection.prop_flatMapComposition), - ("Left.prop_mapIdentity", CheckLeftProjection.prop_mapIdentity), - ("Left.prop_mapComposition", CheckLeftProjection.prop_mapComposition), - ("Left.prop_filter", CheckLeftProjection.prop_filter), - ("Left.prop_ap", CheckLeftProjection.prop_ap), - ("Left.prop_seq", CheckLeftProjection.prop_seq), - ("Left.prop_option", CheckLeftProjection.prop_option), - ("Right.prop_valueE", CheckRightProjection.prop_valueE), - ("Right.prop_value", CheckRightProjection.prop_value), - ("Right.prop_getOrElse", CheckRightProjection.prop_getOrElse), - ("Right.prop_forall", CheckRightProjection.prop_forall), - ("Right.prop_exists", CheckRightProjection.prop_exists), - ("Right.prop_flatMapLeftIdentity", CheckRightProjection.prop_flatMapLeftIdentity), - ("Right.prop_flatMapRightIdentity", CheckRightProjection.prop_flatMapRightIdentity), - ("Right.prop_flatMapComposition", CheckRightProjection.prop_flatMapComposition), - ("Right.prop_mapIdentity", CheckRightProjection.prop_mapIdentity), - ("Right.prop_mapComposition", CheckRightProjection.prop_mapComposition), - ("Right.prop_filter", CheckRightProjection.prop_filter), - ("Right.prop_ap", CheckRightProjection.prop_ap), - ("Right.prop_seq", CheckRightProjection.prop_seq), - ("Right.prop_option", CheckRightProjection.prop_option), - ("prop_Either_left", prop_Either_left), - ("prop_Either_right", prop_Either_right), - ("prop_Either_joinLeft", prop_Either_joinLeft), - ("prop_Either_joinRight", prop_Either_joinRight), - ("prop_Either_lefts", prop_Either_lefts), - ("prop_Either_rights", prop_Either_rights), - ("prop_Either_leftRights", prop_Either_leftRights), - ("prop_Either_throws", prop_Either_throws), - ("prop_Either_throwIt", prop_Either_throwIt), - ("prop_Either_reduce", prop_Either_reduce), - ("prop_Either_iif", prop_Either_iif) - ) - - def main(args: Array[String]) = - tests foreach (tupled((name, prop) => - testStatsEx(name, testReport(check(Params(500, 0, 0, 500, StdRand), prop, propReport))))) -} - diff --git a/test/pending/scalacheck/array.scala b/test/pending/scalacheck/array.scala deleted file mode 100644 index 03c0217180..0000000000 --- a/test/pending/scalacheck/array.scala +++ /dev/null @@ -1,37 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ -import Arbitrary._ -import util._ -import Buildable._ -import scala.collection.mutable.ArraySeq - -object Test extends Properties("Array") { - /** At this moment the authentic scalacheck Array Builder/Arb bits are commented out. - */ - implicit def arbArray[T](implicit a: Arbitrary[T], m: Manifest[T]): Arbitrary[Array[T]] = - Arbitrary(containerOf[List,T](arbitrary[T]) map (_.toArray)) - - val arrGen: Gen[Array[_]] = oneOf( - arbitrary[Array[Int]], - arbitrary[Array[Array[Int]]], - arbitrary[Array[List[String]]], - arbitrary[Array[String]], - arbitrary[Array[Boolean]], - arbitrary[Array[AnyVal]] - ) - - // inspired by #1857 and #2352 - property("eq/ne") = forAll(arrGen, arrGen) { (c1, c2) => - (c1 eq c2) || (c1 ne c2) - } - - // inspired by #2299 - def smallInt = choose(1, 10) - property("ofDim") = forAll(smallInt, smallInt, smallInt) { (i1, i2, i3) => - val arr = Array.ofDim[String](i1, i2, i3) - val flattened = arr flatMap (x => x) flatMap (x => x) - flattened.length == i1 * i2 * i3 - } -} - diff --git a/test/pending/scalacheck/eqeq.scala b/test/pending/scalacheck/eqeq.scala deleted file mode 100644 index 60fe63c207..0000000000 --- a/test/pending/scalacheck/eqeq.scala +++ /dev/null @@ -1,37 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ - -object Test extends Properties("==") { - def equalObjectsEqualHashcodes(x: Any, y: Any) = (x != y) || (x == y && x.## == y.##) - - // ticket #2087 - property("short/char") = forAll { (x: Short) => { - val ch: Char = x.toChar - (x == ch) == (ch == x) - } - } - - property("symmetry") = forAll { (x: AnyVal, y: AnyVal) => (x == y) == (y == x) } - property("transitivity") = forAll { (x: AnyVal, y: AnyVal, z: AnyVal) => x != y || y != z || x == z } - - property("##") = forAll { - (x: Short) => { - val anyvals = List(x.toByte, x.toChar, x, x.toInt, x.toLong, x.toFloat, x.toDouble, BigInt(x), BigDecimal(x)) - val shortAndLarger = anyvals drop 2 - - val result = ( - ((anyvals, anyvals).zipped forall equalObjectsEqualHashcodes) && - ((shortAndLarger, shortAndLarger).zipped forall (_ == _)) && - ((shortAndLarger, shortAndLarger).zipped forall ((x, y) => (x: Any) == (y: Any))) - ) - result - } - } - property("## 2") = forAll { - (dv: Double) => { - val fv = dv.toFloat - (fv != dv) || (fv.## == dv.##) - } - } -} diff --git a/test/pending/scalacheck/list.scala b/test/pending/scalacheck/list.scala deleted file mode 100644 index 1caf35e872..0000000000 --- a/test/pending/scalacheck/list.scala +++ /dev/null @@ -1,21 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ - -object Test extends Properties("List") { - def sorted(xs: List[Int]) = xs sortWith (_ < _) - - property("concat size") = forAll { (l1: List[Int], l2: List[Int]) => (l1.size + l2.size) == (l1 ::: l2).size } - property("reverse") = forAll { (l1: List[Int]) => l1.reverse.reverse == l1 } - property("toSet") = forAll { (l1: List[Int]) => sorted(l1.toSet.toList) sameElements sorted(l1).distinct } - property("flatten") = forAll { (xxs: List[List[Int]]) => xxs.flatten.length == (xxs map (_.length) sum) } - property("startsWith/take") = forAll { (xs: List[Int], count: Int) => xs startsWith (xs take count) } - property("endsWith/takeRight") = forAll { (xs: List[Int], count: Int) => xs endsWith (xs takeRight count) } - property("fill") = forAll(choose(1, 100)) { count => - forAll { (x: Int) => - val xs = List.fill(count)(x) - (xs.length == count) && (xs.distinct == List(x)) - } - } -} - diff --git a/test/pending/scalacheck/range.scala b/test/pending/scalacheck/range.scala deleted file mode 100644 index faa1f5d479..0000000000 --- a/test/pending/scalacheck/range.scala +++ /dev/null @@ -1,205 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ -import Arbitrary._ - -class Counter(r: Range) { - var cnt = 0L - var last: Option[Int] = None - val str = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")") - def apply(x: Int) = { - cnt += 1L - if (cnt % 500000000L == 0L) { - println("Working: %s %d %d" format (str, cnt, x)) - } - if (cnt > (Int.MaxValue.toLong + 1) * 2) - error("Count exceeds maximum possible for an Int Range") - if ((r.step > 0 && last.exists(_ > x)) || (r.step < 0 && last.exists(_ < x))) - error("Range wrapped: %d %s" format (x, last.toString)) - last = Some(x) - } -} - -abstract class RangeTest(kind: String) extends Properties("Range "+kind) { - def myGen: Gen[Range] - - val genRange = for { - start <- arbitrary[Int] - end <- arbitrary[Int] - step <- Gen.choose(1, (start - end).abs + 1) - } yield if (start < end) Range(start, end, step) else Range(start, end, -step) - - val genReasonableSizeRange = for { - start <- choose(-Int.MinValue, Int.MaxValue) - end <- choose(-Int.MinValue, Int.MaxValue) - step <- choose(-Int.MaxValue, Int.MaxValue) - } yield Range(start, end, if (step == 0) 100 else step) - - val genSmallRange = for { - start <- choose(-100, 100) - end <- choose(-100, 100) - step <- choose(1, 1) - } yield if (start < end) Range(start, end, step) else Range(start, end, -step) - - val genRangeByOne = for { - start <- arbitrary[Int] - end <- arbitrary[Int] - if (end.toLong - start.toLong).abs <= 10000000L - } yield if (start < end) Range(start, end) else Range(end, start) - - def str(r: Range) = "Range["+r.start+", "+r.end+", "+r.step+(if (r.isInclusive) "]" else ")") - - def expectedSize(r: Range): Long = if (r.isInclusive) { - (r.end.toLong - r.start.toLong < 0, r.step < 0) match { - case (true, true) | (false, false) => (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong + 1L - case _ => if (r.start == r.end) 1L else 0L - } - } else { - (r.end.toLong - r.start.toLong < 0, r.step < 0) match { - case (true, true) | (false, false) => ( - (r.end.toLong - r.start.toLong).abs / r.step.abs.toLong - + (if ((r.end.toLong - r.start.toLong).abs % r.step.abs.toLong > 0L) 1L else 0L) - ) - case _ => 0L - } - } - - def within(r: Range, x: Int) = if (r.step > 0) - r.start <= x && (if (r.isInclusive) x <= r.end else x < r.end) - else - r.start >= x && (if (r.isInclusive) x >= r.end else x > r.end) - - def multiple(r: Range, x: Int) = (x.toLong - r.start) % r.step == 0 - - property("foreach.step") = forAll(myGen) { r => - var allValid = true - val cnt = new Counter(r) -// println("--------------------") -// println(r) - r foreach { x => cnt(x) -// println(x + ", " + (x - r.start) + ", " + (x.toLong - r.start) + ", " + ((x.toLong - r.start) % r.step)) - allValid &&= multiple(r, x) - } - allValid :| str(r) - } - - property("foreach.inside.range") = forAll(myGen) { r => - var allValid = true - var last: Option[Int] = None - val cnt = new Counter(r) - r foreach { x => cnt(x) - allValid &&= within(r, x) - } - allValid :| str(r) - } - - property("foreach.visited.size") = forAll(myGen) { r => - var visited = 0L - val cnt = new Counter(r) - r foreach { x => cnt(x) - visited += 1L - } -// println("----------") -// println(str(r)) -// println("size: " + r.size) -// println("expected: " + expectedSize(r)) -// println("visited: " + visited) - (visited == expectedSize(r)) :| str(r) - } - - property("length") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => - (r.length == expectedSize(r)) :| str(r) - } - - property("isEmpty") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => - (r.isEmpty == (expectedSize(r) == 0L)) :| str(r) - } - - property("contains") = forAll(myGen, arbInt.arbitrary) { (r, x) => -// println("----------------") -// println(str(r)) -// println(x) -// println("within: " + within(r, x)) -// println("multiple: " + multiple(r, x)) -// println("contains: " + r.contains(x)) - ((within(r, x) && multiple(r, x)) == r.contains(x)) :| str(r)+": "+x - } - - property("take") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => - val t = r take x - (t.size == (0 max x min r.size) && t.start == r.start && t.step == r.step) :| str(r)+" / "+str(t)+": "+x - } - - property("takeWhile") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => - val t = (if (r.step > 0) r takeWhile (_ <= x) else r takeWhile(_ >= x)) - if (r.size == 0) { - (t.size == 0) :| str(r)+" / "+str(t)+": "+x - } else { - val t2 = (if (r.step > 0) Range(r.start, x min r.last, r.step).inclusive else Range(r.start, x max r.last, r.step).inclusive) - (t.start == r.start && t.size == t2.size && t.step == r.step) :| str(r)+" / "+str(t)+" / "+str(t2)+": "+x - } - } - - property("reverse.toSet.equal") = forAll(myGen) { r => - val reversed = r.reverse - val aresame = r.toSet == reversed.toSet - if (!aresame) { - println(str(r)) - println(r) - println(reversed) - println(r.toSet) - println(reversed.toSet) - } - aresame - } -} - -object NormalRangeTest extends RangeTest("normal") { - override def myGen = genReasonableSizeRange - def genOne = for { - start <- arbitrary[Int] - end <- arbitrary[Int] - if (start.toLong - end.toLong).abs < Int.MaxValue.toLong - } yield Range(start, end, if (start < end) 1 else - 1) - property("by 1.size + 1 == inclusive.size") = forAll(genOne) { r => - (r.size + 1 == r.inclusive.size) :| str(r) - } -} - -object InclusiveRangeTest extends RangeTest("inclusive") { - override def myGen = for (r <- genReasonableSizeRange) yield r.inclusive -} - -object ByOneRangeTest extends RangeTest("byOne") { - override def myGen = genSmallRange -} - -object InclusiveByOneRangeTest extends RangeTest("inclusiveByOne") { - override def myGen = for (r <- genSmallRange) yield r.inclusive -} - -object SmallValuesRange extends RangeTest("smallValues") { - override def myGen = genSmallRange -} - -object Test extends Properties("Range") { - include(NormalRangeTest) - include(InclusiveRangeTest) - include(ByOneRangeTest) - include(InclusiveByOneRangeTest) -} - -/* Mini-benchmark -def testRange(i: Int, j: Int, k: Int) = { - var count = 0 - for { - vi <- 0 to i - vj <- 0 to j - vk <- 0 to k - } { count += 1 } -} - -testRange(10, 1000, 10000) -testRange(10000, 1000, 10) -*/ - diff --git a/test/pending/scalacheck/scan.scala b/test/pending/scalacheck/scan.scala deleted file mode 100644 index e9b25ce3df..0000000000 --- a/test/pending/scalacheck/scan.scala +++ /dev/null @@ -1,17 +0,0 @@ -import org.scalacheck._ -import Prop._ -import Gen._ - - -object Test extends Properties("TraversableLike.scanLeft") { - property("scanLeft") = forAll { (xs: List[Int], z: Int) => { - val sums = xs.scanLeft(z)(_ + _) - (xs.size == 0) || sums.zip(sums.tail).map(x => x._2 - x._1) == xs - }} -} - - - - - - diff --git a/test/pending/script/bug2365.sh b/test/pending/script/bug2365.sh new file mode 100755 index 0000000000..f3c44ad086 --- /dev/null +++ b/test/pending/script/bug2365.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# +# This script should fail with any build of scala where #2365 +# is not fixed, and otherwise succeed. Failure means running out +# of PermGen space. + +CP=.:/local/lib/java/ivy.jar +# SCALAC=/scala/inst/28/bin/scalac +SCALAC=scalac +RUN_OPTS="-XX:MaxPermSize=25M -verbose:gc" + +$SCALAC -cp $CP *.scala +JAVA_OPTS="${RUN_OPTS}" scala -cp $CP Test diff --git a/test/pending/script/error-messages.check b/test/pending/script/error-messages.check new file mode 100644 index 0000000000..1aee1fb44a --- /dev/null +++ b/test/pending/script/error-messages.check @@ -0,0 +1,7 @@ +errors.scala:7: error: in XML literal: expected closing tag of hello + + ^ +errors.scala:7: error: start tag was here: + + +two errors found diff --git a/test/pending/script/error-messages.scala b/test/pending/script/error-messages.scala new file mode 100644 index 0000000000..2e2025b203 --- /dev/null +++ b/test/pending/script/error-messages.scala @@ -0,0 +1,9 @@ +#!/bin/sh +exec scala -nocompdaemon "$0" +!# + +// test that error messages print nicely + + + + diff --git a/test/pending/script/errors.check b/test/pending/script/errors.check deleted file mode 100644 index 1aee1fb44a..0000000000 --- a/test/pending/script/errors.check +++ /dev/null @@ -1,7 +0,0 @@ -errors.scala:7: error: in XML literal: expected closing tag of hello - - ^ -errors.scala:7: error: start tag was here: - - -two errors found diff --git a/test/pending/script/errors.scala b/test/pending/script/errors.scala deleted file mode 100644 index 2e2025b203..0000000000 --- a/test/pending/script/errors.scala +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -exec scala -nocompdaemon "$0" -!# - -// test that error messages print nicely - - - - -- cgit v1.2.3