Skip to content

Commit f50b516

Browse files
authored
Merge pull request #3902 from dotty-staging/add-test-from-benchmarks
Add tests files from benchmarks
2 parents 6472ae3 + e6219ab commit f50b516

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

tests/pos/power-macro/Macro_1.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
import scala.quoted.Expr
3+
4+
object PowerMacro {
5+
6+
inline def power(inline n: Long, x: Double) = ~powerCode(n, '(x))
7+
8+
def powerCode(n: Long, x: Expr[Double]): Expr[Double] =
9+
if (n == 0) '(1.0)
10+
else if (n % 2 == 0) '{ { val y = ~x * ~x; ~powerCode(n / 2, '(y)) } }
11+
else '{ ~x * ~powerCode(n - 1, x) }
12+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object PowerInlined1 {
2+
import PowerMacro._
3+
4+
power(1, 5.0) // 1 quotes to unpickle
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
object PowerInlined1k {
2+
import PowerMacro._
3+
4+
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
5+
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
6+
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
7+
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
8+
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
9+
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
10+
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
11+
power(9223372036854775807L, 5.0) // 125 quotes to unpickle
12+
}

0 commit comments

Comments
 (0)