summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run')
-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
5 files changed, 39 insertions, 14 deletions
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})
}
}