diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/continuations-neg/lazy.check | 6 | ||||
-rw-r--r-- | test/files/continuations-neg/lazy.scala | 16 | ||||
-rw-r--r-- | test/files/continuations-run/t2864.check | 1 | ||||
-rw-r--r-- | test/files/continuations-run/t2864.scala | 30 | ||||
-rw-r--r-- | test/files/continuations-run/t2934.check | 1 | ||||
-rw-r--r-- | test/files/continuations-run/t2934.scala (renamed from test/pending/continuations-run/t2934.scala) | 6 | ||||
-rw-r--r-- | test/files/continuations-run/t3223.check | 1 | ||||
-rw-r--r-- | test/files/continuations-run/t3223.scala | 19 | ||||
-rw-r--r-- | test/files/continuations-run/t3225.check | 12 | ||||
-rw-r--r-- | test/files/continuations-run/t3225.scala | 56 | ||||
-rw-r--r-- | test/pending/continuations-run/t2864.scala | 18 |
11 files changed, 143 insertions, 23 deletions
diff --git a/test/files/continuations-neg/lazy.check b/test/files/continuations-neg/lazy.check new file mode 100644 index 0000000000..bfa44c59a4 --- /dev/null +++ b/test/files/continuations-neg/lazy.check @@ -0,0 +1,6 @@ +lazy.scala:5: error: type mismatch; + found : Unit @scala.util.continuations.cpsParam[Unit,Unit] + required: Unit + def foo = { + ^ +one error found diff --git a/test/files/continuations-neg/lazy.scala b/test/files/continuations-neg/lazy.scala new file mode 100644 index 0000000000..dffc57ffa0 --- /dev/null +++ b/test/files/continuations-neg/lazy.scala @@ -0,0 +1,16 @@ +import scala.util.continuations._ + +object Test { + + def foo = { + lazy val x = shift((k:Unit=>Unit)=>k()) + println(x) + } + + def main(args: Array[String]) { + reset { + foo + } + } + +}
\ No newline at end of file diff --git a/test/files/continuations-run/t2864.check b/test/files/continuations-run/t2864.check new file mode 100644 index 0000000000..d411bb7c1a --- /dev/null +++ b/test/files/continuations-run/t2864.check @@ -0,0 +1 @@ +400 diff --git a/test/files/continuations-run/t2864.scala b/test/files/continuations-run/t2864.scala new file mode 100644 index 0000000000..7a2579e45c --- /dev/null +++ b/test/files/continuations-run/t2864.scala @@ -0,0 +1,30 @@ +import scala.util.continuations._ +object Test { + + def double[B](n : Int)(k : Int => B) : B = k(n * 2) + + def main(args : Array[String]) { + reset { + val result1 = shift(double[Unit](100)) + val result2 = shift(double[Unit](result1)) + println(result2) + } + } + + def foo: Int @cps[Int] = { + val a0 = shift((k:Int=>Int) => k(0)) + val x0 = 2 + val a1 = shift((k:Int=>Int) => x0) + 0 + } + +/* + def bar: ControlContext[Int,Int,Int] = { + shiftR((k:Int=>Int) => k(0)).flatMap { a0 => + val x0 = 2 + shiftR((k:Int=>Int) => x0).map { a1 => + 0 + }} + } +*/ +}
\ No newline at end of file diff --git a/test/files/continuations-run/t2934.check b/test/files/continuations-run/t2934.check new file mode 100644 index 0000000000..a92586538e --- /dev/null +++ b/test/files/continuations-run/t2934.check @@ -0,0 +1 @@ +List(3, 4, 5) diff --git a/test/pending/continuations-run/t2934.scala b/test/files/continuations-run/t2934.scala index 6089355bcf..a1b8ca9e04 100644 --- a/test/pending/continuations-run/t2934.scala +++ b/test/files/continuations-run/t2934.scala @@ -1,14 +1,10 @@ -// $Id$ - import scala.util.continuations._ - object Test { - def main(args : Array[String]) { println(reset { val x = shift(List(1,2,3).flatMap[Int, List[Int]]) List(x + 2) }) } -}
\ No newline at end of file +} diff --git a/test/files/continuations-run/t3223.check b/test/files/continuations-run/t3223.check new file mode 100644 index 0000000000..ec635144f6 --- /dev/null +++ b/test/files/continuations-run/t3223.check @@ -0,0 +1 @@ +9 diff --git a/test/files/continuations-run/t3223.scala b/test/files/continuations-run/t3223.scala new file mode 100644 index 0000000000..4e510178e6 --- /dev/null +++ b/test/files/continuations-run/t3223.scala @@ -0,0 +1,19 @@ +import scala.util.continuations._ +object Test { + + def foo(x:Int) = { + try { + throw new Exception + shiftUnit0[Int,Int](7) + } catch { + case ex => + val g = (a:Int)=>a + 9 + } + } + + def main(args: Array[String]) { + println(reset(foo(0))) + } + +}
\ No newline at end of file diff --git a/test/files/continuations-run/t3225.check b/test/files/continuations-run/t3225.check new file mode 100644 index 0000000000..df1a8a9ce4 --- /dev/null +++ b/test/files/continuations-run/t3225.check @@ -0,0 +1,12 @@ +8 +8 +9 +9 +8 +9 +8 +8 +9 +9 +8 +9 diff --git a/test/files/continuations-run/t3225.scala b/test/files/continuations-run/t3225.scala new file mode 100644 index 0000000000..ecfde279cf --- /dev/null +++ b/test/files/continuations-run/t3225.scala @@ -0,0 +1,56 @@ +// $Id$ + +import scala.util.continuations._ + + +object Test { + + class Bla { + val x = 8 + def y[T] = 9 + } + +/* + def bla[A] = shift { k:(Bla=>A) => k(new Bla) } +*/ + + def bla1 = shift { k:(Bla=>Bla) => k(new Bla) } + def bla2 = shift { k:(Bla=>Int) => k(new Bla) } + + def fooA = bla2.x + def fooB[T] = bla2.y[T] + + def testMono() = { + println(reset(bla1).x) + println(reset(bla2.x)) + println(reset(bla2.y[Int])) + println(reset(bla2.y)) + println(reset(fooA)) + println(reset(fooB)) + 0 + } + + def blaX[A] = shift { k:(Bla=>A) => k(new Bla) } + + def fooX[A] = blaX[A].x + def fooY[A] = blaX[A].y[A] + + def testPoly() = { + println(reset(blaX[Bla]).x) + println(reset(blaX[Int].x)) + println(reset(blaX[Int].y[Int])) + println(reset(blaX[Int].y)) + println(reset(fooX[Int])) + println(reset(fooY[Int])) + 0 + } + + + // TODO: check whether this also applies to a::shift { k => ... } + + def main(args: Array[String]) = { + testMono() + testPoly() + } + +} diff --git a/test/pending/continuations-run/t2864.scala b/test/pending/continuations-run/t2864.scala deleted file mode 100644 index 291e739332..0000000000 --- a/test/pending/continuations-run/t2864.scala +++ /dev/null @@ -1,18 +0,0 @@ -// $Id$ - -import scala.util.continuations._ - - - -object Test { - - def double[B](n : Int)(k : Int => B) : B = k(n * 2) - - def main(args : Array[String]) { - reset { - val result1 = shift(double[Unit](100)) - val result2 = shift(double[Unit](result1)) - println(result2) - } - } -}
\ No newline at end of file |