From 6e9ae187a05b1ca4fe748d8a7b45440a55ceb589 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 5 Dec 2011 17:00:55 +0100 Subject: Another test pack for reflection Also see https://github.com/scala/scala/pull/25. --- test/files/run/reify_for1.check | 0 test/files/run/reify_for1.scala | 16 ++++++++++++++++ test/files/run/reify_varargs.check | 1 + test/files/run/reify_varargs.scala | 17 +++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 test/files/run/reify_for1.check create mode 100644 test/files/run/reify_for1.scala create mode 100644 test/files/run/reify_varargs.check create mode 100644 test/files/run/reify_varargs.scala (limited to 'test/files/run') diff --git a/test/files/run/reify_for1.check b/test/files/run/reify_for1.check new file mode 100644 index 0000000000..e69de29bb2 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) +} diff --git a/test/files/run/reify_varargs.check b/test/files/run/reify_varargs.check new file mode 100644 index 0000000000..e300a570a7 --- /dev/null +++ b/test/files/run/reify_varargs.check @@ -0,0 +1 @@ +Message=On the fifth of August there was a disturbance in the Force on planet Hoth. diff --git a/test/files/run/reify_varargs.scala b/test/files/run/reify_varargs.scala new file mode 100644 index 0000000000..d38cbf2aac --- /dev/null +++ b/test/files/run/reify_varargs.scala @@ -0,0 +1,17 @@ +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 msg = java.text.MessageFormat.format( + "On {1} there was {2} on planet {0}.", + "Hoth", "the fifth of August", "a disturbance in the Force") + println("Message="+msg) + }; + + val reporter = new ConsoleReporter(new Settings) + val toolbox = new ToolBox(reporter) + val ttree = toolbox.typeCheck(code.tree) + toolbox.runExpr(ttree) +} -- cgit v1.2.3