Skip to content

Commit 7354b95

Browse files
committed
Regression tests for quoted patterns for NaN and floating point zeros
1 parent cf6fa97 commit 7354b95

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

tests/neg-macros/i13033/Macro_1.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import scala.quoted.*
2+
3+
object Macro:
4+
def positiveImpl(using Quotes): Expr[Any] =
5+
'{ 0.0 } match
6+
case '{ -0.0 } => '{1}
7+
inline def positive: Any = ${positiveImpl}
8+
9+
def negativeImpl(using Quotes): Expr[Any] =
10+
'{ -0.0 } match
11+
case '{ 0.0 } => '{-1}
12+
inline def negative: Any = ${negativeImpl}
13+

tests/neg-macros/i13033/Test_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@main def test(): Unit =
2+
println(Macro.positive) // error
3+
println(Macro.negative) // error

tests/run-macros/i13033.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

tests/run-macros/i13033/Macro_1.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.quoted.*
2+
3+
object Macro:
4+
def nanImpl(using Quotes): Expr[Any] =
5+
'{ Double.NaN } match
6+
case '{ Double.NaN } => '{0}
7+
inline def nan: Any = ${nanImpl}
8+

tests/run-macros/i13033/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@main def Test(): Unit =
2+
println(Macro.nan)

0 commit comments

Comments
 (0)