summaryrefslogtreecommitdiff
path: root/test/pending/run
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-02-02 14:39:44 +0100
committerEugene Burmako <xeno.by@gmail.com>2012-02-02 14:39:44 +0100
commitd940371bd50098c4146e52941880ccdbcb4ea47a (patch)
tree2d4f7093fad48fcaf44ac491bf3a13e3cc2bcbe0 /test/pending/run
parent3aebe255b87f534239f0c46a2a6e0d696c8a31d4 (diff)
downloadscala-d940371bd50098c4146e52941880ccdbcb4ea47a.tar.gz
scala-d940371bd50098c4146e52941880ccdbcb4ea47a.tar.bz2
scala-d940371bd50098c4146e52941880ccdbcb4ea47a.zip
Miscellaneous fixes to reification
More specifically: * Importers now preserve wasEmpty and original * ToolBoxes no longer auto-evaluate nullary functions returned by runExpr * All local symbols from previous typechecks are now correctly erased by ResetAttrs * Originals are now reified
Diffstat (limited to 'test/pending/run')
-rw-r--r--test/pending/run/reify_closure6.check6
-rw-r--r--test/pending/run/reify_closure6.scala2
-rw-r--r--test/pending/run/reify_closure7.check6
-rw-r--r--test/pending/run/reify_closure7.scala32
-rw-r--r--test/pending/run/reify_closure8a.check1
-rw-r--r--test/pending/run/reify_closure8a.scala17
-rw-r--r--test/pending/run/reify_closure8b.check1
-rw-r--r--test/pending/run/reify_closure8b.scala17
-rw-r--r--test/pending/run/reify_closure9a.check1
-rw-r--r--test/pending/run/reify_closure9a.scala20
-rw-r--r--test/pending/run/reify_closure9b.check1
-rw-r--r--test/pending/run/reify_closure9b.scala20
-rw-r--r--test/pending/run/reify_closures10.check2
-rw-r--r--test/pending/run/reify_closures10.scala (renamed from test/pending/run/t5275.scala)10
-rw-r--r--test/pending/run/reify_closures11.check1
-rw-r--r--test/pending/run/reify_closures11.scala (renamed from test/pending/run/t5277_2.scala)18
-rw-r--r--test/pending/run/reify_complex.check1
-rw-r--r--test/pending/run/reify_complex.scala31
-rw-r--r--test/pending/run/reify_extendbuiltins.check1
-rw-r--r--test/pending/run/reify_extendbuiltins.scala21
-rw-r--r--test/pending/run/reify_sort1.check2
-rw-r--r--test/pending/run/reify_sort1.scala27
-rw-r--r--test/pending/run/reify_this.check5
-rw-r--r--test/pending/run/reify_this.scala31
-rw-r--r--test/pending/run/t5269.check1
-rw-r--r--test/pending/run/t5269.scala22
-rw-r--r--test/pending/run/t5274_1.check3
-rw-r--r--test/pending/run/t5274_1.scala20
-rw-r--r--test/pending/run/t5275.check1
-rw-r--r--test/pending/run/t5277_1.check1
-rw-r--r--test/pending/run/t5277_1.scala21
-rw-r--r--test/pending/run/t5277_2.check2
-rw-r--r--test/pending/run/t5415.check0
-rw-r--r--test/pending/run/t5415.scala14
34 files changed, 190 insertions, 169 deletions
diff --git a/test/pending/run/reify_closure6.check b/test/pending/run/reify_closure6.check
index 3526d04b0e..e521ea874d 100644
--- a/test/pending/run/reify_closure6.check
+++ b/test/pending/run/reify_closure6.check
@@ -1,3 +1,7 @@
+q = 1
+y = 1
first invocation = 15
-second invocation = 18
+q = 2
+y = 1
+second invocation = 17
q after second invocation = 2
diff --git a/test/pending/run/reify_closure6.scala b/test/pending/run/reify_closure6.scala
index 909071aa44..43ddfde28d 100644
--- a/test/pending/run/reify_closure6.scala
+++ b/test/pending/run/reify_closure6.scala
@@ -10,6 +10,8 @@ object Test extends App {
val fun: reflect.Code[Int => Int] = x => {
y += 1
q += 1
+ println("q = " + q)
+ println("y = " + y)
x + ys.length * z + q + y
}
diff --git a/test/pending/run/reify_closure7.check b/test/pending/run/reify_closure7.check
new file mode 100644
index 0000000000..bf58b52bce
--- /dev/null
+++ b/test/pending/run/reify_closure7.check
@@ -0,0 +1,6 @@
+q = 1
+y = 1
+first invocation = 15
+q = 2
+y = 2
+second invocation = 17
diff --git a/test/pending/run/reify_closure7.scala b/test/pending/run/reify_closure7.scala
new file mode 100644
index 0000000000..8933df23fa
--- /dev/null
+++ b/test/pending/run/reify_closure7.scala
@@ -0,0 +1,32 @@
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import reflect.runtime.Mirror.ToolBox
+
+object Test extends App {
+ var q = 0
+ var clo: Int => Int = null
+ def foo[T](ys: List[T]): Int => Int = {
+ val z = 1
+ var y = 0
+ val fun: reflect.Code[Int => Int] = x => {
+ y += 1
+ q += 1
+ println("q = " + q)
+ println("y = " + y)
+ x + ys.length * z + q + y
+ }
+
+ if (clo == null) {
+ val reporter = new ConsoleReporter(new Settings)
+ val toolbox = new ToolBox(reporter)
+ val ttree = toolbox.typeCheck(fun.tree)
+ val dyn = toolbox.runExpr(ttree)
+ clo = dyn.asInstanceOf[Int => Int]
+ }
+
+ clo
+ }
+
+ println("first invocation = " + foo(List(1, 2, 3))(10))
+ println("second invocation = " + foo(List(1, 2, 3, 4))(10))
+}
diff --git a/test/pending/run/reify_closure8a.check b/test/pending/run/reify_closure8a.check
new file mode 100644
index 0000000000..9a037142aa
--- /dev/null
+++ b/test/pending/run/reify_closure8a.check
@@ -0,0 +1 @@
+10 \ No newline at end of file
diff --git a/test/pending/run/reify_closure8a.scala b/test/pending/run/reify_closure8a.scala
new file mode 100644
index 0000000000..5e54bfc8c7
--- /dev/null
+++ b/test/pending/run/reify_closure8a.scala
@@ -0,0 +1,17 @@
+import scala.reflect.Code._
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import reflect.runtime.Mirror.ToolBox
+
+object Test extends App {
+ class Foo(val y: Int) {
+ def fun = lift{y}
+ }
+
+ val reporter = new ConsoleReporter(new Settings)
+ val toolbox = new ToolBox(reporter)
+ val ttree = toolbox.typeCheck(new Foo(10).fun.tree)
+ val dyn = toolbox.runExpr(ttree)
+ val foo = dyn.asInstanceOf[Int]
+ println(foo)
+}
diff --git a/test/pending/run/reify_closure8b.check b/test/pending/run/reify_closure8b.check
new file mode 100644
index 0000000000..9a037142aa
--- /dev/null
+++ b/test/pending/run/reify_closure8b.check
@@ -0,0 +1 @@
+10 \ No newline at end of file
diff --git a/test/pending/run/reify_closure8b.scala b/test/pending/run/reify_closure8b.scala
new file mode 100644
index 0000000000..9e37e4e09a
--- /dev/null
+++ b/test/pending/run/reify_closure8b.scala
@@ -0,0 +1,17 @@
+import scala.reflect.Code._
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import reflect.runtime.Mirror.ToolBox
+
+object Test extends App {
+ class Foo(y: Int) {
+ def fun = lift{y}
+ }
+
+ val reporter = new ConsoleReporter(new Settings)
+ val toolbox = new ToolBox(reporter)
+ val ttree = toolbox.typeCheck(new Foo(10).fun.tree)
+ val dyn = toolbox.runExpr(ttree)
+ val foo = dyn.asInstanceOf[Int]
+ println(foo)
+}
diff --git a/test/pending/run/reify_closure9a.check b/test/pending/run/reify_closure9a.check
new file mode 100644
index 0000000000..9a037142aa
--- /dev/null
+++ b/test/pending/run/reify_closure9a.check
@@ -0,0 +1 @@
+10 \ No newline at end of file
diff --git a/test/pending/run/reify_closure9a.scala b/test/pending/run/reify_closure9a.scala
new file mode 100644
index 0000000000..f3ee153d3c
--- /dev/null
+++ b/test/pending/run/reify_closure9a.scala
@@ -0,0 +1,20 @@
+import scala.reflect.Code._
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import reflect.runtime.Mirror.ToolBox
+
+object Test extends App {
+ def foo(y: Int) = {
+ class Foo(val y: Int) {
+ def fun = lift{y}
+ }
+
+ val reporter = new ConsoleReporter(new Settings)
+ val toolbox = new ToolBox(reporter)
+ val ttree = toolbox.typeCheck(new Foo(y).fun.tree)
+ val dyn = toolbox.runExpr(ttree)
+ dyn.asInstanceOf[Int]
+ }
+
+ println(foo(10))
+}
diff --git a/test/pending/run/reify_closure9b.check b/test/pending/run/reify_closure9b.check
new file mode 100644
index 0000000000..9a037142aa
--- /dev/null
+++ b/test/pending/run/reify_closure9b.check
@@ -0,0 +1 @@
+10 \ No newline at end of file
diff --git a/test/pending/run/reify_closure9b.scala b/test/pending/run/reify_closure9b.scala
new file mode 100644
index 0000000000..8d349e8701
--- /dev/null
+++ b/test/pending/run/reify_closure9b.scala
@@ -0,0 +1,20 @@
+import scala.reflect.Code._
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import reflect.runtime.Mirror.ToolBox
+
+object Test extends App {
+ def foo(y: Int) = {
+ class Foo(y: Int) {
+ def fun = lift{y}
+ }
+
+ val reporter = new ConsoleReporter(new Settings)
+ val toolbox = new ToolBox(reporter)
+ val ttree = toolbox.typeCheck(new Foo(y).fun.tree)
+ val dyn = toolbox.runExpr(ttree)
+ dyn.asInstanceOf[Int]
+ }
+
+ println(foo(10))
+}
diff --git a/test/pending/run/reify_closures10.check b/test/pending/run/reify_closures10.check
new file mode 100644
index 0000000000..fd3c81a4d7
--- /dev/null
+++ b/test/pending/run/reify_closures10.check
@@ -0,0 +1,2 @@
+5
+5
diff --git a/test/pending/run/t5275.scala b/test/pending/run/reify_closures10.scala
index d419834ded..d0f895ae4d 100644
--- a/test/pending/run/t5275.scala
+++ b/test/pending/run/reify_closures10.scala
@@ -1,15 +1,15 @@
+import scala.reflect.Code._
import scala.tools.nsc.reporters._
import scala.tools.nsc.Settings
import reflect.runtime.Mirror.ToolBox
object Test extends App {
- val code = scala.reflect.Code.lift{
- class C(val foo: Int)
- println(new C(2).foo)
- };
+ val x = 2
+ val y = 3
+ val code = lift{println(x + y); x + y}
val reporter = new ConsoleReporter(new Settings)
val toolbox = new ToolBox(reporter)
val ttree = toolbox.typeCheck(code.tree)
- toolbox.runExpr(ttree)
+ println(toolbox.runExpr(ttree))
}
diff --git a/test/pending/run/reify_closures11.check b/test/pending/run/reify_closures11.check
new file mode 100644
index 0000000000..d8263ee986
--- /dev/null
+++ b/test/pending/run/reify_closures11.check
@@ -0,0 +1 @@
+2 \ No newline at end of file
diff --git a/test/pending/run/t5277_2.scala b/test/pending/run/reify_closures11.scala
index 67b6b000bc..42053bd029 100644
--- a/test/pending/run/t5277_2.scala
+++ b/test/pending/run/reify_closures11.scala
@@ -1,18 +1,18 @@
+import scala.reflect.Code._
import scala.tools.nsc.reporters._
import scala.tools.nsc.Settings
import reflect.runtime.Mirror.ToolBox
object Test extends App {
- val code = scala.reflect.Code.lift{
- def p(implicit i: Int) = print(i)
- implicit val v = 2
-
- println(p)
- println(p(1))
- };
+ def fun() = {
+ def z() = 2
+ lift{z}
+ }
val reporter = new ConsoleReporter(new Settings)
val toolbox = new ToolBox(reporter)
- val ttree = toolbox.typeCheck(code.tree)
- toolbox.runExpr(ttree)
+ val ttree = toolbox.typeCheck(fun().tree)
+ val dyn = toolbox.runExpr(ttree)
+ val foo = dyn.asInstanceOf[Int]
+ println(foo)
}
diff --git a/test/pending/run/reify_complex.check b/test/pending/run/reify_complex.check
deleted file mode 100644
index 7df35e33a0..0000000000
--- a/test/pending/run/reify_complex.check
+++ /dev/null
@@ -1 +0,0 @@
-3.0+4.0*i
diff --git a/test/pending/run/reify_complex.scala b/test/pending/run/reify_complex.scala
deleted file mode 100644
index aae4d558cf..0000000000
--- a/test/pending/run/reify_complex.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-import scala.tools.nsc.reporters._
-import scala.tools.nsc.Settings
-import reflect.runtime.Mirror.ToolBox
-
-object Test extends App {
- val code = scala.reflect.Code.lift{
- class Complex(val re: Double, val im: Double) {
- def + (that: Complex) =
- new Complex(re + that.re, im + that.im)
- def - (that: Complex) =
- new Complex(re - that.re, im - that.im)
- def * (that: Complex) =
- new Complex(re * that.re - im * that.im,
- re * that.im + im * that.re)
- def / (that: Complex) = {
- val denom = that.re * that.re + that.im * that.im
- new Complex((re * that.re + im * that.im) / denom,
- (im * that.re - re * that.im) / denom)
- }
- override def toString =
- re + (if (im < 0) "-" + (-im) else "+" + im) + "*i"
- }
- val x = new Complex(2, 1); val y = new Complex(1, 3)
- println(x + y)
- };
-
- val reporter = new ConsoleReporter(new Settings)
- val toolbox = new ToolBox(reporter)
- val ttree = toolbox.typeCheck(code.tree)
- toolbox.runExpr(ttree)
-}
diff --git a/test/pending/run/reify_extendbuiltins.check b/test/pending/run/reify_extendbuiltins.check
deleted file mode 100644
index a48033a30d..0000000000
--- a/test/pending/run/reify_extendbuiltins.check
+++ /dev/null
@@ -1 +0,0 @@
-10! = 3628800
diff --git a/test/pending/run/reify_extendbuiltins.scala b/test/pending/run/reify_extendbuiltins.scala
deleted file mode 100644
index 57acd699ff..0000000000
--- a/test/pending/run/reify_extendbuiltins.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-import scala.tools.nsc.reporters._
-import scala.tools.nsc.Settings
-import reflect.runtime.Mirror.ToolBox
-
-object Test extends App {
- val code = scala.reflect.Code.lift{
- def fact(n: Int): BigInt =
- if (n == 0) 1 else fact(n-1) * n
- class Factorizer(n: Int) {
- def ! = fact(n)
- }
- implicit def int2fact(n: Int) = new Factorizer(n)
-
- println("10! = " + (10!))
- };
-
- val reporter = new ConsoleReporter(new Settings)
- val toolbox = new ToolBox(reporter)
- val ttree = toolbox.typeCheck(code.tree)
- toolbox.runExpr(ttree)
-}
diff --git a/test/pending/run/reify_sort1.check b/test/pending/run/reify_sort1.check
deleted file mode 100644
index 0d30805141..0000000000
--- a/test/pending/run/reify_sort1.check
+++ /dev/null
@@ -1,2 +0,0 @@
-List(6, 2, 8, 5, 1)
-List(1, 2, 5, 6, 8)
diff --git a/test/pending/run/reify_sort1.scala b/test/pending/run/reify_sort1.scala
deleted file mode 100644
index 42f4c824a5..0000000000
--- a/test/pending/run/reify_sort1.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-import scala.tools.nsc.reporters._
-import scala.tools.nsc.Settings
-import reflect.runtime.Mirror.ToolBox
-
-object Test extends App {
- val code = scala.reflect.Code.lift{
- def sort(a: List[Int]): List[Int] = {
- if (a.length < 2)
- a
- else {
- val pivot = a(a.length / 2)
- sort(a.filter(_ < pivot)) :::
- a.filter(_ == pivot) :::
- sort(a.filter(_ > pivot))
- }
- }
-
- val xs = List(6, 2, 8, 5, 1)
- println(xs)
- println(sort(xs))
- };
-
- val reporter = new ConsoleReporter(new Settings)
- val toolbox = new ToolBox(reporter)
- val ttree = toolbox.typeCheck(code.tree)
- toolbox.runExpr(ttree)
-}
diff --git a/test/pending/run/reify_this.check b/test/pending/run/reify_this.check
new file mode 100644
index 0000000000..af3d0652a9
--- /dev/null
+++ b/test/pending/run/reify_this.check
@@ -0,0 +1,5 @@
+foo
+false
+2
+bar
+2 \ No newline at end of file
diff --git a/test/pending/run/reify_this.scala b/test/pending/run/reify_this.scala
new file mode 100644
index 0000000000..38ef72b6eb
--- /dev/null
+++ b/test/pending/run/reify_this.scala
@@ -0,0 +1,31 @@
+import scala.reflect._
+import scala.reflect.Code._
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import reflect.runtime.Mirror.ToolBox
+
+trait Eval {
+ def eval(code: Code[_]): Any = eval(code.tree)
+
+ def eval(tree: Tree): Any = {
+ val settings = new Settings
+ val reporter = new ConsoleReporter(settings)
+ val toolbox = new ToolBox(reporter)
+ val ttree = toolbox.typeCheck(tree)
+ toolbox.runExpr(ttree)
+ }
+}
+
+object Test extends App with Eval {
+ // select a value from package
+ eval(lift{println("foo")})
+ eval(lift{println((new Object).toString == (new Object).toString)})
+
+ // select a type from package
+ eval(lift{val x: Any = 2; println(x)})
+ eval(lift{val x: Object = "bar"; println(x)})
+
+ // select a value from module
+ val x = 2
+ eval(lift{println(x)})
+}
diff --git a/test/pending/run/t5269.check b/test/pending/run/t5269.check
deleted file mode 100644
index 0cfbf08886..0000000000
--- a/test/pending/run/t5269.check
+++ /dev/null
@@ -1 +0,0 @@
-2
diff --git a/test/pending/run/t5269.scala b/test/pending/run/t5269.scala
deleted file mode 100644
index a30509f3fe..0000000000
--- a/test/pending/run/t5269.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-import scala.tools.nsc.reporters._
-import scala.tools.nsc.Settings
-import reflect.runtime.Mirror.ToolBox
-
-object Test extends App {
- val code = scala.reflect.Code.lift{
- trait Z {
- val z = 2
- }
-
- class X extends Z {
- def println() = Predef.println(z)
- }
-
- new X().println()
- };
-
- val reporter = new ConsoleReporter(new Settings)
- val toolbox = new ToolBox(reporter)
- val ttree = toolbox.typeCheck(code.tree)
- toolbox.runExpr(ttree)
-}
diff --git a/test/pending/run/t5274_1.check b/test/pending/run/t5274_1.check
deleted file mode 100644
index fca8bc3d3e..0000000000
--- a/test/pending/run/t5274_1.check
+++ /dev/null
@@ -1,3 +0,0 @@
-50! = 30414093201713378043612608166064768844377641568960512000000000000
-49! = 608281864034267560872252163321295376887552831379210240000000000
-50!/49! = 50
diff --git a/test/pending/run/t5274_1.scala b/test/pending/run/t5274_1.scala
deleted file mode 100644
index c501172518..0000000000
--- a/test/pending/run/t5274_1.scala
+++ /dev/null
@@ -1,20 +0,0 @@
-import scala.tools.nsc.reporters._
-import scala.tools.nsc.Settings
-import reflect.runtime.Mirror.ToolBox
-
-object Test extends App {
- val code = scala.reflect.Code.lift{
- def factorial(n: BigInt): BigInt =
- if (n == 0) 1 else n * factorial(n-1)
-
- val f50 = factorial(50); val f49 = factorial(49)
- println("50! = " + f50)
- println("49! = " + f49)
- println("50!/49! = " + (f50 / f49))
- };
-
- val reporter = new ConsoleReporter(new Settings)
- val toolbox = new ToolBox(reporter)
- val ttree = toolbox.typeCheck(code.tree)
- toolbox.runExpr(ttree)
-}
diff --git a/test/pending/run/t5275.check b/test/pending/run/t5275.check
deleted file mode 100644
index 0cfbf08886..0000000000
--- a/test/pending/run/t5275.check
+++ /dev/null
@@ -1 +0,0 @@
-2
diff --git a/test/pending/run/t5277_1.check b/test/pending/run/t5277_1.check
deleted file mode 100644
index a48033a30d..0000000000
--- a/test/pending/run/t5277_1.check
+++ /dev/null
@@ -1 +0,0 @@
-10! = 3628800
diff --git a/test/pending/run/t5277_1.scala b/test/pending/run/t5277_1.scala
deleted file mode 100644
index 57acd699ff..0000000000
--- a/test/pending/run/t5277_1.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-import scala.tools.nsc.reporters._
-import scala.tools.nsc.Settings
-import reflect.runtime.Mirror.ToolBox
-
-object Test extends App {
- val code = scala.reflect.Code.lift{
- def fact(n: Int): BigInt =
- if (n == 0) 1 else fact(n-1) * n
- class Factorizer(n: Int) {
- def ! = fact(n)
- }
- implicit def int2fact(n: Int) = new Factorizer(n)
-
- println("10! = " + (10!))
- };
-
- val reporter = new ConsoleReporter(new Settings)
- val toolbox = new ToolBox(reporter)
- val ttree = toolbox.typeCheck(code.tree)
- toolbox.runExpr(ttree)
-}
diff --git a/test/pending/run/t5277_2.check b/test/pending/run/t5277_2.check
deleted file mode 100644
index 5f1d0ecea5..0000000000
--- a/test/pending/run/t5277_2.check
+++ /dev/null
@@ -1,2 +0,0 @@
-2
-1
diff --git a/test/pending/run/t5415.check b/test/pending/run/t5415.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/pending/run/t5415.check
diff --git a/test/pending/run/t5415.scala b/test/pending/run/t5415.scala
new file mode 100644
index 0000000000..3db356da86
--- /dev/null
+++ b/test/pending/run/t5415.scala
@@ -0,0 +1,14 @@
+import scala.tools.nsc.reporters._
+import scala.tools.nsc.Settings
+import scala.reflect.runtime.Mirror.ToolBox
+
+object Test extends App{
+ case class Queryable2[T]() { def filter(predicate: T => Boolean) = ??? }
+ trait CoffeesTable{ def sales : Int }
+ val q = Queryable2[CoffeesTable]()
+ val code = scala.reflect.Code.lift{q.filter(_.sales > 5)}
+
+ val reporter = new ConsoleReporter(new Settings)
+ val toolbox = new ToolBox(reporter)
+ val ttree = toolbox.typeCheck(code.tree)
+}