diff options
Diffstat (limited to 'test/files/run/reify_for1.scala')
-rw-r--r-- | test/files/run/reify_for1.scala | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/files/run/reify_for1.scala b/test/files/run/reify_for1.scala new file mode 100644 index 0000000000..4b03330293 --- /dev/null +++ b/test/files/run/reify_for1.scala @@ -0,0 +1,16 @@ +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{ + val sumOfSquares1 = (for (i <- 1 to 100; if (i % 3 == 0)) yield Math.pow(i, 2)).sum + val sumOfSquares2 = (1 to 100).filter(_ % 3 == 0).map(Math.pow(_, 2)).sum + assert(sumOfSquares1 == sumOfSquares2) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} |