Skip to content

Commit 280f625

Browse files
committed
Add tests
1 parent a093709 commit 280f625

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ class CompilationTests extends ParallelTesting {
195195
implicit val testGroup: TestGroup = TestGroup("runAll")
196196
compileFilesInDir("../tests/run", defaultOptions) +
197197
compileFilesInDir("../tests/run-no-optimise", defaultOptions) +
198-
compileFile("../tests/run-special/quote-run.scala", defaultRunWithCompilerOptions)
198+
compileFile("../tests/run-special/quote-run.scala", defaultRunWithCompilerOptions) +
199+
compileFile("../tests/run-special/quote-run-2.scala", defaultRunWithCompilerOptions)
199200
}.checkRuns()
200201

201202
// Generic java signatures tests ---------------------------------------------

tests/run-special/quote-run-2.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
1.0
2+
5.0

tests/run-special/quote-run-2.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
import dotty.tools.dotc.quoted.Runners._
3+
4+
import scala.quoted._
5+
6+
object Test {
7+
def main(args: Array[String]): Unit = {
8+
def powerCode(n: Int, x: Expr[Double]): Expr[Double] =
9+
if (n == 0) '(1.0)
10+
else if (n == 1) x
11+
else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } }
12+
else '{ ~x * ~powerCode(n - 1, x) }
13+
14+
println(powerCode(0, '(5)).show)
15+
println(powerCode(1, '(5)).show)
16+
// FIXME
17+
// println(powerCode(2, '(5)).show)
18+
// println(powerCode(3, '(5)).show)
19+
20+
}
21+
}

0 commit comments

Comments
 (0)