summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2010-09-01 13:25:57 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2010-09-01 13:25:57 +0000
commit27c9348ba828374df3e36b86103cf70abd82647e (patch)
treea77c3aed74add58639ae816ccf0b647de2737c8e /test/files
parent01c28cdc53d5655eb04c393565a482daaff038ff (diff)
downloadscala-27c9348ba828374df3e36b86103cf70abd82647e.tar.gz
scala-27c9348ba828374df3e36b86103cf70abd82647e.tar.bz2
scala-27c9348ba828374df3e36b86103cf70abd82647e.zip
Merged revisions 22121,22393,22416,22426,22524-...
Merged revisions 22121,22393,22416,22426,22524-22525,22549 via svnmerge from https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk ........ r22121 | rytz | 2010-06-02 11:57:41 +0200 (Wed, 02 Jun 2010) | 1 line some tests. no review ........ r22393 | rytz | 2010-06-24 18:43:40 +0200 (Thu, 24 Jun 2010) | 1 line close #3543 ........ r22416 | rytz | 2010-06-29 14:32:45 +0200 (Tue, 29 Jun 2010) | 1 line close #2413. maybe there's better place to this conversion, therefore review by odersky. ........ r22426 | rytz | 2010-06-30 13:03:00 +0200 (Wed, 30 Jun 2010) | 1 line moved toScalaRepeatedParam TypeMap to refchecks. no review ........ r22524 | rytz | 2010-07-09 11:51:03 +0200 (Fri, 09 Jul 2010) | 1 line close #3649. no review ........ r22525 | rytz | 2010-07-09 11:51:06 +0200 (Fri, 09 Jul 2010) | 1 line close #3648. default getters for constructor defaults are now static. however, they still need to live in the companion object to avoid name conflicts when subclasses also define constructor defaults. review by odersky. ........ r22549 | rytz | 2010-07-13 09:14:37 +0200 (Tue, 13 Jul 2010) | 1 line close #3648 (again). objects extending their companion class can no longer use default constructor arguments. review by odersky ........
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/names-defaults-neg.check13
-rw-r--r--test/files/neg/names-defaults-neg.scala5
-rw-r--r--test/files/pos/t2413/TestJava.java7
-rw-r--r--test/files/pos/t2413/TestScalac.scala23
-rw-r--r--test/files/run/bitsets-msil.check32
-rw-r--r--test/files/run/exceptions-nest.check12
-rw-r--r--test/files/run/exceptions-nest.scala139
-rw-r--r--test/files/run/names-defaults.scala5
8 files changed, 215 insertions, 21 deletions
diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check
index 38bacc0888..b2b00b7050 100644
--- a/test/files/neg/names-defaults-neg.check
+++ b/test/files/neg/names-defaults-neg.check
@@ -104,17 +104,20 @@ names-defaults-neg.scala:82: error: type mismatch;
Error occurred in an application involving default arguments.
new A2[String]()
^
-names-defaults-neg.scala:115: error: reference to var2 is ambiguous; it is both, a parameter
+names-defaults-neg.scala:86: error: module extending its companion class cannot use default constructor arguments
+ object C extends C()
+ ^
+names-defaults-neg.scala:120: error: reference to var2 is ambiguous; it is both, a parameter
name of the method and the name of a variable currently in scope.
delay(var2 = 40)
^
-names-defaults-neg.scala:118: error: missing parameter type for expanded function ((x$1) => a = x$1)
+names-defaults-neg.scala:123: error: missing parameter type for expanded function ((x$1) => a = x$1)
val taf2: Int => Unit = testAnnFun(a = _, b = get("+"))
^
-names-defaults-neg.scala:119: error: parameter specified twice: a
+names-defaults-neg.scala:124: error: parameter specified twice: a
val taf3 = testAnnFun(b = _: String, a = get(8))
^
-names-defaults-neg.scala:120: error: wrong number of parameters; expected = 2
+names-defaults-neg.scala:125: error: wrong number of parameters; expected = 2
val taf4: (Int, String) => Unit = testAnnFun(_, b = _)
^
-28 errors found
+29 errors found
diff --git a/test/files/neg/names-defaults-neg.scala b/test/files/neg/names-defaults-neg.scala
index e73dc71c9b..43883540a0 100644
--- a/test/files/neg/names-defaults-neg.scala
+++ b/test/files/neg/names-defaults-neg.scala
@@ -81,6 +81,11 @@ object Test extends Application {
// correct error message
new A2[String]()
+ object t3648 {
+ class C(val s: String = "")
+ object C extends C()
+ }
+
// DEFINITIONS
def test1(a: Int, b: String) = a +": "+ b
def test2(x: Unit) = println("test2")
diff --git a/test/files/pos/t2413/TestJava.java b/test/files/pos/t2413/TestJava.java
new file mode 100644
index 0000000000..252c01fbc0
--- /dev/null
+++ b/test/files/pos/t2413/TestJava.java
@@ -0,0 +1,7 @@
+package pack;
+
+public class TestJava {
+ protected String repeatParam(String ... items) {
+ return "nothing";
+ }
+}
diff --git a/test/files/pos/t2413/TestScalac.scala b/test/files/pos/t2413/TestScalac.scala
new file mode 100644
index 0000000000..098e852dd7
--- /dev/null
+++ b/test/files/pos/t2413/TestScalac.scala
@@ -0,0 +1,23 @@
+import pack.TestJava
+
+class Foo extends TestJava {
+
+ // THIS METHOD YIELDS TO CRASH
+/* def foomethod : Option[String] => Unit = {
+ case None =>
+ val path = repeatParam("s","a","b","c")
+ ()
+ case Some(error) =>
+ ()
+ }
+
+ // THIS IS OK
+ def foomethod2 : String = repeatParam("s","a");
+
+ // THIS IS OK
+ val aVal = repeatParam("1","2","3") */
+
+ // THIS YIELDS TO CRASH
+ for (a <- 1 to 4 ; anotherVal = repeatParam("1","2","3"))
+ yield anotherVal
+}
diff --git a/test/files/run/bitsets-msil.check b/test/files/run/bitsets-msil.check
index 9fefa3125e..b187571bff 100644
--- a/test/files/run/bitsets-msil.check
+++ b/test/files/run/bitsets-msil.check
@@ -1,23 +1,23 @@
-ms0 = Set(2)
-ms1 = Set(2)
-ms2 = Set(2)
+ms0 = BitSet(2)
+ms1 = BitSet(2)
+ms2 = BitSet(2)
mb0 = False
mb1 = True
mb2 = False
xs0 = List(2)
xs1 = List(2)
xs2 = List(2)
-ma0 = List(4)
-ma1 = List(4)
-ma2 = List(4)
-mi0 = Set(2)
-mi1 = Set(2)
-mi2 = Set(2)
+ma0 = List(2)
+ma1 = List(2)
+ma2 = List(2)
+mi0 = BitSet(2)
+mi1 = BitSet(2)
+mi2 = BitSet(2)
-is0 = Set()
-is1 = Set()
-is2 = Set(2)
-is3 = Set()
+is0 = BitSet()
+is1 = BitSet()
+is2 = BitSet(2)
+is3 = BitSet()
ib0 = False
ib1 = False
ib2 = True
@@ -26,8 +26,8 @@ ys0 = List()
ys1 = List()
ys2 = List(2)
ys3 = List()
-ia0 = List(0)
-ia1 = List(0)
-ia2 = List(4)
+ia0 = List()
+ia1 = List()
+ia2 = List(2)
ia3 = List()
diff --git a/test/files/run/exceptions-nest.check b/test/files/run/exceptions-nest.check
new file mode 100644
index 0000000000..ae66da0a99
--- /dev/null
+++ b/test/files/run/exceptions-nest.check
@@ -0,0 +1,12 @@
+2
+23
+2
+5
+2
+4
+OK
+4
+OK
+10
+1
+()
diff --git a/test/files/run/exceptions-nest.scala b/test/files/run/exceptions-nest.scala
new file mode 100644
index 0000000000..40b00988e4
--- /dev/null
+++ b/test/files/run/exceptions-nest.scala
@@ -0,0 +1,139 @@
+object Test extends Application {
+
+ println(test1)
+ println(test2)
+ println(test3)
+ println(test4)
+ println(test5)
+ try { println(test6) } catch { case _ => println("OK") }
+ println(test7)
+ try { println(test8) } catch { case _ => println("OK") }
+ println(test9)
+ println(test10)
+ println(test11)
+
+ def test1 = {
+ var x = 1
+ try {
+ x = 2
+ } catch {
+ case _: NullPointerException => x = 3
+ case _ => x = 4
+ }
+ x
+ }
+
+ def test2 = {
+ var x = 1
+ try {
+ x = 2
+ try {
+ x = 21
+ } catch {
+ case _ => x = 22
+ }
+ x = 23
+ } catch {
+ case _: NullPointerException => x = 3
+ case _ => x = 4
+ }
+ x
+ }
+
+ def test3 = {
+ var x = 1
+ try {
+ try{x = 2} catch { case _ => x = 4 }
+ } catch {
+ case _: NullPointerException => x = 3
+ case _ => x = 4
+ }
+ x
+ }
+
+ def test4 = {
+ var x = 1
+ try {
+ x = 2
+ } catch {
+ case _: NullPointerException => x = 3
+ case _ => x = 4
+ }
+ try {
+ x = 5
+ } catch {
+ case _: NullPointerException => x = 6
+ }
+ x
+ }
+
+ def test5 = {
+ var x = 1
+ try {
+ x = 2
+ } catch {
+ case _: NullPointerException => try { x = 3 } catch { case f => throw f }
+ case _ => x = 4; try { x = 41 } catch { case _: Exception => x = 42 }; x = 43
+ }
+ x
+ }
+
+ def test6: Int = {
+ var x = 1
+ try {
+ x = 2
+ (null: String).toString
+ } catch {
+ case e: NullPointerException =>
+ throw e
+ case _ =>
+ x = 3
+ return 1000
+ } finally {
+ x = 4
+ println(x)
+ }
+ x
+ }
+
+ def test7 = {
+ var x = 1
+ try {
+ x = 2
+ } finally {
+ try {
+ x = 4
+ } catch {
+ case _ => x = 5
+ }
+ }
+ x
+ }
+
+ def test8 = {
+ var x = 1
+ try {
+ throw new NullPointerException
+ } catch {
+ case e => throw e
+ }
+ x
+ }
+
+ def test9 = {
+ try { "" match {
+ case s: String => 10
+ }} catch { case _ => 20 }
+ }
+
+ var x10 = 1
+ def test10: Int = {
+ try { 1 }
+ catch { case e if (x10 == 1) => 1 }
+ }
+
+ def test11 {
+ try { () }
+ catch { case e => () }
+ }
+}
diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala
index f197d2ff11..8ddfcd950d 100644
--- a/test/files/run/names-defaults.scala
+++ b/test/files/run/names-defaults.scala
@@ -345,6 +345,11 @@ object Test extends Application {
(new t3338.Test).a
+ // subclassing and defaults in both class constructors
+ class CBLAH(val x: Int = 1)
+ class DBLAH(val y: String = "2") extends CBLAH()
+ (new DBLAH())
+
// DEFINITIONS
def test1(a: Int, b: String) = println(a +": "+ b)