summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2007-09-01 06:51:58 +0000
committerBurak Emir <emir@epfl.ch>2007-09-01 06:51:58 +0000
commit8af1dfade7e0fafcbe7adb4dbea14d734d9b8dea (patch)
tree3ec75d2046cb589b9c7d4d0ae4bffa27f1159b26 /test/files/run
parent77de72ce86f2fd83c646cfc1c5fd21de26318477 (diff)
downloadscala-8af1dfade7e0fafcbe7adb4dbea14d734d9b8dea.tar.gz
scala-8af1dfade7e0fafcbe7adb4dbea14d734d9b8dea.tar.bz2
scala-8af1dfade7e0fafcbe7adb4dbea14d734d9b8dea.zip
fixed ticket #2 (patch from tags/R_2_6_0-RC2), ...
fixed ticket #2 (patch from tags/R_2_6_0-RC2), reorganized test cases
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/bug1093.check1
-rw-r--r--test/files/run/bug1093.scala9
-rw-r--r--test/files/run/bug1094.check1
-rw-r--r--test/files/run/bug1094.scala11
-rw-r--r--test/files/run/bug508.check3
-rw-r--r--test/files/run/bug508.scala20
-rw-r--r--test/files/run/bug789.check2
-rw-r--r--test/files/run/bug789.scala31
-rw-r--r--test/files/run/bug995.check1
-rw-r--r--test/files/run/bug995.scala12
-rw-r--r--test/files/run/patmatnew.scala143
11 files changed, 119 insertions, 115 deletions
diff --git a/test/files/run/bug1093.check b/test/files/run/bug1093.check
deleted file mode 100644
index 0cfbf08886..0000000000
--- a/test/files/run/bug1093.check
+++ /dev/null
@@ -1 +0,0 @@
-2
diff --git a/test/files/run/bug1093.scala b/test/files/run/bug1093.scala
deleted file mode 100644
index 4cc6181e81..0000000000
--- a/test/files/run/bug1093.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-// contribution bug #460
-
-object Test extends Application {
- val x = Some(3) match {
- case Some(1 | 2) => 1
- case Some(3) => 2
- }
- println(x)
-}
diff --git a/test/files/run/bug1094.check b/test/files/run/bug1094.check
deleted file mode 100644
index bc56c4d894..0000000000
--- a/test/files/run/bug1094.check
+++ /dev/null
@@ -1 +0,0 @@
-Foo
diff --git a/test/files/run/bug1094.scala b/test/files/run/bug1094.scala
deleted file mode 100644
index 7fe8072b5f..0000000000
--- a/test/files/run/bug1094.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-// contribution bug #461
-
-object Test extends Application {
- def foo(ps: String*) = "Foo"
- case class X(p: String, ps: String*)
- def bar =
- X("a", "b") match {
- case X(p, ps @ _*) => foo(ps : _*)
- }
- println(bar)
-}
diff --git a/test/files/run/bug508.check b/test/files/run/bug508.check
deleted file mode 100644
index 4539bbf2d2..0000000000
--- a/test/files/run/bug508.check
+++ /dev/null
@@ -1,3 +0,0 @@
-0
-1
-2
diff --git a/test/files/run/bug508.scala b/test/files/run/bug508.scala
deleted file mode 100644
index 80485371ea..0000000000
--- a/test/files/run/bug508.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-object Test {
- case class Operator(x: Int);
- val EQ = new Operator(2);
-
- def main(args: Array[String]): Unit = {
- val x = Pair(EQ, 0);
- analyze(x); // should print "0"
- val y = Pair(EQ, 1);
- analyze(y); // should print "1"
- val z = Pair(EQ, 2);
- analyze(z); // should print "2"
- }
-
- def analyze(x: Pair[Operator, Int]) = x match {
- case Pair(EQ, 0) => Console.println("0")
- case Pair(EQ, 1) => Console.println("1")
- case Pair(EQ, 2) => Console.println("2")
- case _ => Console.println("undefined on " + x)
- }
-}
diff --git a/test/files/run/bug789.check b/test/files/run/bug789.check
deleted file mode 100644
index a98c09dcac..0000000000
--- a/test/files/run/bug789.check
+++ /dev/null
@@ -1,2 +0,0 @@
-hello size 42
-hello size 42
diff --git a/test/files/run/bug789.scala b/test/files/run/bug789.scala
deleted file mode 100644
index 8cd4102dcf..0000000000
--- a/test/files/run/bug789.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-object Test { // don't do this at home
-
- trait Impl
-
- trait SizeImpl extends Impl { def size = 42 }
-
- trait ColorImpl extends Impl { def color = "red" }
-
- type Both = SizeImpl with ColorImpl
-
- def info(x:Impl) = x match {
- case x:Both => "size "+x.size+" color "+x.color // you wish
- case x:SizeImpl => "size "+x.size
- case x:ColorImpl => "color "+x.color
- case _ => "n.a."
- }
-
- def info2(x:Impl) = x match {
- case x:SizeImpl with ColorImpl => "size "+x.size+" color "+x.color // you wish
- case x:SizeImpl => "size "+x.size
- case x:ColorImpl => "color "+x.color
- case _ => "n.a."
- }
-
- def main(args:Array[String]): Unit = {
- // make up some class that has a size
- class MyNode extends SizeImpl
- Console.println("hello " + info(new MyNode))
- Console.println("hello " + info2(new MyNode))
- }
-}
diff --git a/test/files/run/bug995.check b/test/files/run/bug995.check
deleted file mode 100644
index f0f0e34bb3..0000000000
--- a/test/files/run/bug995.check
+++ /dev/null
@@ -1 +0,0 @@
-Seq
diff --git a/test/files/run/bug995.scala b/test/files/run/bug995.scala
deleted file mode 100644
index f7f75b6a02..0000000000
--- a/test/files/run/bug995.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-object Test extends Application {
- def foo(v: Any): String = v match {
- case s: Seq[_] =>
- "Seq"
- // see Burak's hack in object Seq.unapplySeq
- //case a: AnyRef if runtime.ScalaRunTime.isArray(a) =>
- // "Array"
- case _ =>
- v.toString
- }
- Console.println(foo(Array(0)))
-}
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala
index fdb01c9aec..09b12f710c 100644
--- a/test/files/run/patmatnew.scala
+++ b/test/files/run/patmatnew.scala
@@ -33,11 +33,16 @@ object Test extends TestConsoleMain {
TestEqualsPatternOpt,
new TestStream,
new Test903,
- new Test1093,
new Test1163_Order,
new TestUnbox,
+ Bug457,
+ Bug508,
+ Bug789,
+ Bug995,
+ Bug1093,
+ Bug1094,
ClassDefInGuard,
- Bug457
+ Ticket_2
)
class Foo(j:Int) {
@@ -225,16 +230,6 @@ object Test extends TestConsoleMain {
Some(p.father)
}
- class Test1093 extends TestCase("bug1093") {
- override def runTest {
- val x = Some(3) match {
- case Some(1 | 2) => 1
- case Some(3) => 2
- }
- assertEquals("ok", 2, x)
- }
- }
-
class Test903 extends TestCase("bug903") {
override def runTest = {
@@ -451,24 +446,18 @@ object Test extends TestConsoleMain {
}
}
-
+ // bug#457
object Bug457 extends TestCase("Bug457") {
-
def method1() = {
- val x = "Hello, world";
- val y = 100;
-
+ val x = "Hello, world"; val y = 100;
y match {
case _: Int if (x match { case t => t.trim().length() > 0 }) => false;
case _ => true;
- }
- }
+ }}
def method2(): scala.Boolean = {
- val x: String = "Hello, world";
- val y: scala.Int = 100;
- {
+ val x: String = "Hello, world"; val y: scala.Int = 100; {
var temp1: scala.Int = y;
var result: scala.Boolean = false;
if (
@@ -483,16 +472,122 @@ object Test extends TestConsoleMain {
result
else
throw new MatchError("crazybox.scala, line 9")
- }
- }
+ }}
override def runTest {
method1();
method2();
}
+ }
+
+ // bug#508
+
+ object Bug508 extends TestCase("aladdin #508") {
+ case class Operator(x: Int);
+ val EQ = new Operator(2);
+
+ def analyze(x: Pair[Operator, Int]) = x match {
+ case Pair(EQ, 0) => "0"
+ case Pair(EQ, 1) => "1"
+ case Pair(EQ, 2) => "2"
+ }
+ override def runTest {
+ val x = Pair(EQ, 0);
+ assertEquals("0", analyze(x)); // should print "0"
+ val y = Pair(EQ, 1);
+ assertEquals("1", analyze(y)); // should print "1"
+ val z = Pair(EQ, 2);
+ assertEquals("2", analyze(z)); // should print "2"
+ }
+ }
+
+ // bug#789
+
+ object Bug789 extends TestCase("aladdin #789") { // don't do this at home
+
+ trait Impl
+
+ trait SizeImpl extends Impl { def size = 42 }
+
+ trait ColorImpl extends Impl { def color = "red" }
+
+ type Both = SizeImpl with ColorImpl
+
+ def info(x:Impl) = x match {
+ case x:Both => "size "+x.size+" color "+x.color // you wish
+ case x:SizeImpl => "!size "+x.size
+ case x:ColorImpl => "color "+x.color
+ case _ => "n.a."
+ }
+ def info2(x:Impl) = x match {
+ case x:SizeImpl with ColorImpl => "size "+x.size+" color "+x.color // you wish
+ case x:SizeImpl => "!size "+x.size
+ case x:ColorImpl => "color "+x.color
+ case _ => "n.a."
+ }
+
+ override def runTest {
+ // make up some class that has a size
+ class MyNode extends SizeImpl
+ assertEquals("!size 42", info(new MyNode))
+ assertEquals("!size 42", info2(new MyNode))
+ }
}
+ // bug#995
+
+ object Bug995 extends TestCase("aladdin #995") {
+ def foo(v: Any): String = v match {
+ case s: Seq[_] => "Seq" // see hack in object Seq.unapplySeq
+ //case a: AnyRef if runtime.ScalaRunTime.isArray(a) => "Array"
+ case _ => v.toString
+ }
+ override def runTest { assertEquals("Seq", foo(Array(0))) }
+ }
+
+ // bug#1093 (contribution #460)
+
+ object Bug1093 extends TestCase("aladdin #1093") {
+ override def runTest {assertTrue(Some(3) match {
+ case Some(1 | 2) => false
+ case Some(3) => true
+ })}
+ }
+
+ // bug#1094 (contribution #461)
+
+ object Bug1094 extends TestCase("aladdin #1094") {
+ def foo(ps: String*) = "Foo"
+ case class X(p: String, ps: String*)
+ def bar =
+ X("a", "b") match {
+ case X(p, ps @ _*) => foo(ps : _*)
+ }
+ override def runTest { assertEquals("Foo", bar) }
+ }
+
+ // #2
+
+ class Outer_2 {
+ case class Foo(x: int, y: int) {
+ override def equals(other: Any) = other match {
+ case Outer_2.this.Foo(`x`, `y`) => true
+ case _ => false
+ }
+ }
+ }
+
+ object Ticket_2 extends TestCase("#2") { override def runTest {
+ val o1 = new Outer_2; val o2 = new Outer_2; val x: Any = o1.Foo(1, 2); val y: Any = o2.Foo(1, 2)
+ assertFalse("equals test returns true (but should not)", x equals y)
+ assertTrue("match enters wrong case", x match {
+ case o2.Foo(x, y) => false;
+ case o1.Foo(x, y) => true
+ case _ => false
+ })
+ }}
}
+