diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2005-12-14 17:01:30 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2005-12-14 17:01:30 +0000 |
commit | 6eef38afc1eb6ffb7eda604607009ca154d5831d (patch) | |
tree | 936485b9ed26406853b34b7360fd4c365c1c8c4a | |
parent | 79c0c5404daf502157e4c5788f774fafc53dab91 (diff) | |
download | scala-6eef38afc1eb6ffb7eda604607009ca154d5831d.tar.gz scala-6eef38afc1eb6ffb7eda604607009ca154d5831d.tar.bz2 scala-6eef38afc1eb6ffb7eda604607009ca154d5831d.zip |
Updated test files to reflex syntax changes and...
Updated test files to reflex syntax changes and added test in try.scala.
-rwxr-xr-x | test-nsc/files/run/Course-2002-02.scala | 30 | ||||
-rwxr-xr-x | test-nsc/files/run/Course-2002-04.scala | 2 | ||||
-rw-r--r-- | test-nsc/files/run/Course-2002-06.scala | 4 | ||||
-rwxr-xr-x | test-nsc/files/run/Course-2002-07.scala | 2 | ||||
-rw-r--r-- | test-nsc/files/run/try.check | 1 | ||||
-rw-r--r-- | test-nsc/files/run/try.scala | 19 |
6 files changed, 41 insertions, 17 deletions
diff --git a/test-nsc/files/run/Course-2002-02.scala b/test-nsc/files/run/Course-2002-02.scala index a86ffebaf5..435b84484f 100755 --- a/test-nsc/files/run/Course-2002-02.scala +++ b/test-nsc/files/run/Course-2002-02.scala @@ -92,7 +92,7 @@ object M3 { //############################################################################ object M4 { - def sum(f: Int => Double) = { + def sum(f: Int => Double): (Int, Int) => Double = { def sumF(a: Int, b: Int): Double = if (a > b) 0 else f(a) + sumF(a + 1, b); @@ -140,9 +140,9 @@ object M6 { if (a > b) 0 else f(a) + sum(f)(a + 1, b); - def sumInts = sum(x => x); - def sumCubes = sum(x => x * x * x); - def sumReciprocals = sum(x => 1.0/x); + def sumInts: (Int, Int) => Double = sum(x => x); + def sumCubes: (Int, Int) => Double = sum(x => x * x * x); + def sumReciprocals: (Int, Int) => Double = sum(x => 1.0/x); def sumPi = (n: Int => 4 + sum(x => 4.0/(4*x+1) - 4.0/(4*x-1))(1, n)); Console.println(sumInts(1,4)); @@ -163,9 +163,9 @@ object M7 { iter(a, 0) } - def sumInts = sum(x => x); - def sumCubes = sum(x => x * x * x); - def sumReciprocals = sum(x => 1.0/x); + def sumInts: (Int, Int) => Double = sum(x => x); + def sumCubes: (Int, Int) => Double = sum(x => x * x * x); + def sumReciprocals: (Int, Int) => Double = sum(x => 1.0/x); def sumPi = (n: Int => 4 + sum(x => 4.0/(4*x+1) - 4.0/(4*x-1))(1, n)); Console.println(sumInts(1,4)); @@ -201,8 +201,10 @@ object M9 { def inc(x: Int) = x + 1; - def sum(f: Int => Double) = accumulate((x: Double, y: Double) => x + y, 0d, f, inc); - def product(f: Int => Double) = accumulate((x: Double, y: Double) => x * y, 1d, f, inc); + def sum(f: Int => Double): (Int, Int) => Double = accumulate((x: Double, y: Double) => x + y, + 0d, f, inc); + def product(f: Int => Double): (Int, Int) => Double = accumulate((x: Double, y: Double) => x * y, + 1d, f, inc); def sumInts = sum(x => x); def sumCubes = sum(x => x * x * x); @@ -325,8 +327,10 @@ object MD { iter(a, zero) } - def plus (x:Double,y:Double) = x+y; val sum = reduce(plus , 0); - def times(x:Double,y:Double) = x*y; val product = reduce(times, 1); + def plus (x:Double,y:Double) = x+y; + val sum: (Int => Double) => (Int, Int) => Double = reduce(plus , 0); + def times(x:Double,y:Double) = x*y; + val product: (Int => Double) => (Int, Int) => Double = reduce(times, 1); def factorial(n: Int) = product(x => x)(1 , n); @@ -368,8 +372,8 @@ object ME { iter(a, zero) } - def sum = reduce((x,y) => x + y, 0); - def product = reduce((x,y) => x * y, 1); + def sum: (Int => Double) => (Int, Int) => Double = reduce((x,y) => x + y, 0); + def product: (Int => Double) => (Int, Int) => Double = reduce((x,y) => x * y, 1); def factorial(n: Int) = product(x => x)(1 , n); diff --git a/test-nsc/files/run/Course-2002-04.scala b/test-nsc/files/run/Course-2002-04.scala index 31aaa44c23..48d14d9125 100755 --- a/test-nsc/files/run/Course-2002-04.scala +++ b/test-nsc/files/run/Course-2002-04.scala @@ -19,7 +19,7 @@ object M0 { } def test = { - val isort = quicksort[Int]((x,y) => x < y); + val isort: List[Int] => List[Int] = quicksort[Int]((x,y) => x < y); val list0 = List(6,3,1,8,7,1,2,5,8,4,3,4,8); val list1 = quicksort[Int]((x,y) => x < y)(list0); val list2 = quicksort[Int]((x,y) => x < y)(list1); diff --git a/test-nsc/files/run/Course-2002-06.scala b/test-nsc/files/run/Course-2002-06.scala index 76bd581a73..df73daa08f 100644 --- a/test-nsc/files/run/Course-2002-06.scala +++ b/test-nsc/files/run/Course-2002-06.scala @@ -168,14 +168,14 @@ object M0 { /** Flip the painter vertically */ - def flipVert = + def flipVert: Painter => Painter = transformPainter(new Vector(0.0, 1.0), new Vector(1.0, 1.0), new Vector(0.0, 0.0)); /** Flip the painter horizontally */ - def flipHoriz = + def flipHoriz: Painter => Painter = transformPainter(new Vector(1.0, 0.0), new Vector(0.0, 0.0), new Vector(1.0, 1.0)); diff --git a/test-nsc/files/run/Course-2002-07.scala b/test-nsc/files/run/Course-2002-07.scala index 5ebb1ad7ab..98f09aafb7 100755 --- a/test-nsc/files/run/Course-2002-07.scala +++ b/test-nsc/files/run/Course-2002-07.scala @@ -419,7 +419,7 @@ object MA { case Prod(e1, e2) => eval(e1) * eval(e2) } - def evalvars(xs: List[Pair[String,int]]) = { + def evalvars(xs: List[Pair[String,int]]): Expr => Int = { def loop(e: Expr): int = e match { case Number(n) => n case Var(name) => lookup(xs,name) diff --git a/test-nsc/files/run/try.check b/test-nsc/files/run/try.check index 30d3881906..3983e26060 100644 --- a/test-nsc/files/run/try.check +++ b/test-nsc/files/run/try.check @@ -1,5 +1,6 @@ 1 + 1 = 2 1 + 1 = 2 1 + 1 = 2 +1 + 1 = 2 1 + 1 = 2 diff --git a/test-nsc/files/run/try.scala b/test-nsc/files/run/try.scala index bc339b71da..fca6bf5c55 100644 --- a/test-nsc/files/run/try.scala +++ b/test-nsc/files/run/try.scala @@ -57,6 +57,23 @@ object Test extends AnyRef with Application { } } + def try5 = try { + Console.print("1 + 1 = "); + try { + if (true) + error("exit"); + 1+1; + () + } catch { + case _ => + Console.println("2"); + error("for good"); + } + Console.println("a"); + } catch { + case _ => (); + } + class A { private val result = { val y = try { x } catch { @@ -85,6 +102,8 @@ object Test extends AnyRef with Application { try1; try2; try3; + try4; + try5; Console.println; new A(); () |