summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-02-14 13:37:19 +0000
committerMartin Odersky <odersky@gmail.com>2007-02-14 13:37:19 +0000
commit979180ca5f30752d94d64b083b6dbca57dab0c4b (patch)
tree5566e84f9803ef46fd9a24fb1e451babec53190c /test
parente5b3a8a6b49dd4ab333781e3e7ce595ba14b06eb (diff)
downloadscala-979180ca5f30752d94d64b083b6dbca57dab0c4b.tar.gz
scala-979180ca5f30752d94d64b083b6dbca57dab0c4b.tar.bz2
scala-979180ca5f30752d94d64b083b6dbca57dab0c4b.zip
more changes to make tuples (...)
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/bug835.check4
-rw-r--r--test/files/neg/bug876.check2
-rw-r--r--test/files/neg/patmatexhaust.check4
-rw-r--r--test/files/neg/patmatexhaust.scala6
-rw-r--r--test/files/pos/unapplySeq.scala2
-rw-r--r--test/files/run/patmatnew.scala4
-rw-r--r--test/files/run/runtime.scala4
-rw-r--r--test/files/run/tuples.check3
-rw-r--r--test/files/run/tuples.scala28
-rw-r--r--test/files/run/unapply.scala14
10 files changed, 48 insertions, 23 deletions
diff --git a/test/files/neg/bug835.check b/test/files/neg/bug835.check
index 16b311ff4c..83db589280 100644
--- a/test/files/neg/bug835.check
+++ b/test/files/neg/bug835.check
@@ -1,4 +1,4 @@
-bug835.scala:2: error: `)' expected
+bug835.scala:2: error: _*-argument may not appear after other arguments matching a *-parameter
Console.println(List(List(1, 2, 3) : _*, List(4, 5, 6) : _*))
- ^
+ ^
one error found
diff --git a/test/files/neg/bug876.check b/test/files/neg/bug876.check
index 54c27fc96a..e7d5d5d78f 100644
--- a/test/files/neg/bug876.check
+++ b/test/files/neg/bug876.check
@@ -1,4 +1,4 @@
-bug876.scala:25: error: wrong number of arguments for method apply: (AssertionError.this.A)manager.B
+bug876.scala:25: error: wrong number of arguments for method apply: (AssertionError.this.A)manager.B in trait Map
assert(manager.map(A2) == List(manager.map(A2, A1)))
^
one error found
diff --git a/test/files/neg/patmatexhaust.check b/test/files/neg/patmatexhaust.check
index 6a0eda5861..19e79b2928 100644
--- a/test/files/neg/patmatexhaust.check
+++ b/test/files/neg/patmatexhaust.check
@@ -5,10 +5,10 @@ patmatexhaust.scala:12: warning: does not cover case {class Bar}
def ma2(x:Foo) = x match {
^
patmatexhaust.scala:24: warning: does not cover case {class Kult}
- case {Kult(_), Qult()} => // Kult missing
+ case (Kult(_), Qult()) => // Kult missing
^
patmatexhaust.scala:26: warning: does not cover case {class Qult}
- case {Qult(), Kult(_)} => // Qult missing
+ case (Qult(), Kult(_)) => // Qult missing
^
patmatexhaust.scala:44: warning: does not cover cases {object Gu,class Gp}
def ma4(x:Deep) = x match { // missing cases: Gu, Gp
diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala
index e1b52a61ef..204bf2f170 100644
--- a/test/files/neg/patmatexhaust.scala
+++ b/test/files/neg/patmatexhaust.scala
@@ -20,10 +20,10 @@ class TestSealedExhaustive { // compile only
def ma33(x:Kult) = x match { // exhaustive
case Kult(_) => // exhaustive
}
- def ma3(x:Mult) = {x,x} match { // not exhaustive
- case Pair(Kult(_), Qult()) => // Kult missing
+ def ma3(x:Mult) = (x,x) match { // not exhaustive
+ case (Kult(_), Qult()) => // Kult missing
//case Pair(Kult(_), Kult(_)) =>
- case Pair(Qult(), Kult(_)) => // Qult missing
+ case (Qult(), Kult(_)) => // Qult missing
//case Pair(Qult(), Qult()) =>
}
diff --git a/test/files/pos/unapplySeq.scala b/test/files/pos/unapplySeq.scala
index aac211de5a..6d13cc8b52 100644
--- a/test/files/pos/unapplySeq.scala
+++ b/test/files/pos/unapplySeq.scala
@@ -2,7 +2,7 @@ object FooSeq {
def unapplySeq(x:Any): Option[Product2[Int,Seq[String]]] = {
if(x.isInstanceOf[Bar]) {
val y = x.asInstanceOf[Bar]
- Some({y.size, y.name})
+ Some(y.size, y.name)
} else None
}
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala
index e77e10abeb..daa1f9898a 100644
--- a/test/files/run/patmatnew.scala
+++ b/test/files/run/patmatnew.scala
@@ -99,7 +99,7 @@ object Test {
// these are exhaustive matches
// should not generate any warnings
- def f[A](z:{Option[A],Option[A]}) = z match {
+ def f[A](z:(Option[A],Option[A])) = z match {
case Pair(None,Some(x)) => 1
case Pair(Some(x),None ) => 2
case Pair(Some(x),Some(y)) => 3
@@ -118,7 +118,7 @@ object Test {
case _ => true
}
- def h[A](x:{Option[A],Option[A]}) = x match {
+ def h[A](x: (Option[A],Option[A])) = x match {
case Pair(None,_:Some[_]) => 1
case Pair(_:Some[_],None ) => 2
case Pair(_:Some[_],_:Some[_]) => 3
diff --git a/test/files/run/runtime.scala b/test/files/run/runtime.scala
index 192d405eba..45fdf91c95 100644
--- a/test/files/run/runtime.scala
+++ b/test/files/run/runtime.scala
@@ -66,7 +66,7 @@ object Test1Test {
// {System.out.print(12); java.lang}.System.out.println();
// {System.out.print(13); java.lang.System}.out.println();
{Console.print(14); Console}.println;
- {Console.print(15); (() => Console.println):(() => Unit)}();
+ {Console.print(15); (() => Console.println):(() => Unit)} apply ();
{Console.print(16); Console.println};
{Console.print(20)}; test1.bar.System.out.println();
@@ -74,7 +74,7 @@ object Test1Test {
// {System.out.print(22); test1.bar}.System.out.println();
{Console.print(23); test1.bar.System}.out.println();
{Console.print(24); test1.bar.System.out}.println();
- {Console.print(25); test1.bar.System.out.println:(() => Unit)}();
+ {Console.print(25); test1.bar.System.out.println:(() => Unit)} apply ();
{Console.print(26); test1.bar.System.out.println()};
}
diff --git a/test/files/run/tuples.check b/test/files/run/tuples.check
index 731f2746c9..ff7fb4fe7a 100644
--- a/test/files/run/tuples.check
+++ b/test/files/run/tuples.check
@@ -1,2 +1,5 @@
{1,abc,true}
OK
+x = 2; y = xxx; z = 3.14159
+x = 2; y = xxx; z = 3.14159
+x = 2; y = xxx; z = 3.14159
diff --git a/test/files/run/tuples.scala b/test/files/run/tuples.scala
index 3d0dcf7ac0..857b166917 100644
--- a/test/files/run/tuples.scala
+++ b/test/files/run/tuples.scala
@@ -1,8 +1,30 @@
+import Function._
+
object Test extends Application {
- var xyz: Triple(int, String, boolean) = _
- xyz = Triple(1, "abc", true)
+ var xyz: (int, String, boolean) = _
+ xyz = (1, "abc", true)
Console.println(xyz)
xyz match {
- case Triple(1, "abc", true) => Console.println("OK")
+ case (1, "abc", true) => Console.println("OK")
}
+ def func(x : int, y : String, z : double) : unit = {
+ Console.println("x = " + x + "; y = " + y + "; z = " + z);
+ }
+
+ def params = (2, "xxx", 3.14159) // (*****)
+
+ tupled(&func)(params) // call the function with all the params at once
+ func(2, "xxx", 3.14159) // the same call
+ (&func).apply(2, "xxx", 3.14159) // the same call
+
+ // Composing a tuple
+ def t = (1, "Hello", false)
+
+ // Decomposing a tuple
+ val (i, s, b) = t
+
+ // all the assertions are passed
+ assert(i == 1)
+ assert(s == "Hello")
+ assert(b == false)
}
diff --git a/test/files/run/unapply.scala b/test/files/run/unapply.scala
index 8b913ee593..fb154cf192 100644
--- a/test/files/run/unapply.scala
+++ b/test/files/run/unapply.scala
@@ -34,7 +34,7 @@ object Foo extends Assert {
case _ => None
}
def doMatch1(b:Bar) = b match {
- case Foo(s:Int, n:String) => {s,n}
+ case Foo(s:Int, n:String) => (s,n)
}
def doMatch2(b:Bar) = b match {
case Fii() => null
@@ -50,7 +50,7 @@ object Foo extends Assert {
}
def run {
val b = new Bar
- assertEquals(doMatch1(b),{50,"medium"})
+ assertEquals(doMatch1(b),(50,"medium"))
assertEquals(doMatch2(b),null)
assertEquals(doMatch3(b),"medium")
assertEquals(doMatch4(b),"medium")
@@ -73,16 +73,16 @@ object Mas extends Assert {
def run {
val b = new Baz
assertEquals(b match {
- case Gaz(s:Int, n:String) => {s,n}
- }, {60,"too large"})
+ case Gaz(s:Int, n:String) => (s,n)
+ }, (60,"too large"))
}
}
object LisSeqArr extends Assert {
def run {
- assertEquals((List(1,2,3): Any) match { case List(x,y,_*) => {x,y}}, {1,2})
- assertEquals((List(1,2,3): Any) match { case Seq(x,y,_*) => {x,y}}, {1,2})
- assertEquals((Array(1,2,3): Any) match { case Seq(x,y,_*) => {x,y}}, {1,2})
+ assertEquals((List(1,2,3): Any) match { case List(x,y,_*) => (x,y)}, (1,2))
+ assertEquals((List(1,2,3): Any) match { case Seq(x,y,_*) => (x,y)}, (1,2))
+ assertEquals((Array(1,2,3): Any) match { case Seq(x,y,_*) => (x,y)}, (1,2))
//assertEquals((Array(1,2,3): Any) match { case Array(x,y,_*) => {x,y}}, {1,2})
}
}