summaryrefslogtreecommitdiff
path: root/test/files/run/reify_for1.scala
blob: d1b60d878b52aafaeebe296e15067e4db6b395ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)
  toolbox.runExpr(code.tree)
}