Skip to content

Commit c921574

Browse files
committed
Simplify macro tests with custom args
[Cherry-picked cc90bf3][modified]
1 parent 451838f commit c921574

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+125
-24
lines changed

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

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ class BootstrappedOnlyCompilationTests {
2929
aggregateTests(
3030
compileFilesInDir("tests/bench", defaultOptions.without("-Yno-deep-subtypes")),
3131
compileFilesInDir("tests/pos-macros", defaultOptions.and("-Xcheck-macros")),
32-
compileFilesInDir("tests/pos-custom-args/semanticdb", defaultOptions.and("-Xsemanticdb")),
33-
compileDir("tests/pos-special/i7592", defaultOptions.and("-Yretain-trees")),
34-
compileDir("tests/pos-special/i11331.1", defaultOptions),
35-
compileDir("tests/pos-custom-args/i13405", defaultOptions.and("-Xfatal-warnings")),
3632
).checkCompile()
3733
}
3834

@@ -107,12 +103,8 @@ class BootstrappedOnlyCompilationTests {
107103

108104
@Test def negMacros: Unit = {
109105
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
110-
aggregateTests(
111-
compileFilesInDir("tests/neg-macros", defaultOptions.and("-Xcheck-macros")),
112-
compileFile("tests/pos-macros/i9570.scala", defaultOptions.and("-Xfatal-warnings")),
113-
compileFile("tests/pos-macros/macro-deprecation.scala", defaultOptions.and("-Xfatal-warnings", "-deprecation")),
114-
compileFile("tests/pos-macros/macro-experimental.scala", defaultOptions.and("-Yno-experimental")),
115-
).checkExpectedErrors()
106+
compileFilesInDir("tests/neg-macros", defaultOptions.and("-Xcheck-macros"))
107+
.checkExpectedErrors()
116108
}
117109

118110
@Test def negWithCompiler: Unit = {
@@ -127,15 +119,9 @@ class BootstrappedOnlyCompilationTests {
127119

128120
@Test def runMacros: Unit = {
129121
implicit val testGroup: TestGroup = TestGroup("runMacros")
130-
aggregateTests(
131-
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros")),
132-
compileFilesInDir("tests/run-custom-args/Yretain-trees", defaultOptions and "-Yretain-trees"),
133-
compileFilesInDir("tests/run-custom-args/Yread-comments", defaultOptions and "-Yread-docs"),
134-
compileFilesInDir("tests/run-custom-args/run-macros-erased", defaultOptions.and("-language:experimental.erasedDefinitions").and("-Xcheck-macros")),
135-
compileDir("tests/run-custom-args/Xmacro-settings/simple", defaultOptions.and("-Xmacro-settings:one,two,three")),
136-
compileDir("tests/run-custom-args/Xmacro-settings/compileTimeEnv", defaultOptions.and("-Xmacro-settings:a,b=1,c.b.a=x.y.z=1,myLogger.level=INFO")),
137-
)
138-
}.checkRuns()
122+
compileFilesInDir("tests/run-macros", defaultOptions.and("-Xcheck-macros"))
123+
.checkRuns()
124+
}
139125

140126
@Test def runWithCompiler: Unit = {
141127
implicit val testGroup: TestGroup = TestGroup("runWithCompiler")

tests/pos-macros/i9570.scala renamed to tests/neg-macros/i9570.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xfatal-warnings
2+
13
import scala.quoted.*
24

35
object Macros {

tests/pos-macros/macro-deprecation.scala renamed to tests/neg-macros/macro-deprecation.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xfatal-warnings -deprecation
2+
13
import scala.quoted.*
24

35
inline def f = ${ impl } // error

tests/pos-macros/macro-experimental.scala renamed to tests/neg-macros/macro-experimental.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yno-experimental
2+
13
import scala.quoted.*
24
import scala.annotation.experimental
35

tests/neg/i9685bis.check

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- [E008] Not Found Error: tests/neg/i9685bis.scala:25:4 ---------------------------------------------------------------
2+
25 | 1.asdf // error
3+
| ^^^^^^
4+
| value asdf is not a member of Int, but could be made available as an extension method.
5+
|
6+
| The following import might make progress towards fixing the problem:
7+
|
8+
| import foo.Baz.toBaz
9+
|

tests/neg/i9685bis.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// scalac: -source future
2+
3+
package foo
4+
5+
import scala.language.implicitConversions
6+
7+
class Foo
8+
9+
object Foo:
10+
11+
inline implicit def toFoo(x: Int): Foo = Foo()
12+
13+
class Bar
14+
15+
object Bar:
16+
inline given Conversion[Int, Bar] with
17+
def apply(x: Int): Bar = Bar()
18+
19+
class Baz
20+
21+
object Baz:
22+
transparent inline implicit def toBaz(x: Int): Baz = Baz()
23+
24+
object Usage:
25+
1.asdf // error

tests/pos-custom-args/i13405/Test.scala

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/pos-macros/i13405/Test.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// scalac: -Xfatal-warnings
2+
3+
@main def main: Unit = hh()

tests/pos-special/i7592/Test_2.scala renamed to tests/pos-macros/i7592/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yretain-trees
2+
13
def return1 = 1
24

35
def testReturn1 = {

tests/pos-custom-args/semanticdb/inline-unapply/App_2.scala renamed to tests/pos-macros/semanticdb-inline-unapply/App_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Xsemanticdb
12

23
object Test {
34
def main(args: Array[String]): Unit = {

tests/pos-custom-args/semanticdb/inline-unapply/Macro_1.scala renamed to tests/pos-macros/semanticdb-inline-unapply/Macro_1.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xsemanticdb
2+
13
import scala.quoted.*
24

35
object Succ:

tests/pos-custom-args/semanticdb/macro-pos/example_1.scala renamed to tests/pos-macros/semanticdb-macro-pos/example_1.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xsemanticdb
2+
13
import quoted.*
24

35
object CodeImpl {

tests/pos-custom-args/semanticdb/macro-pos/example_2.scala renamed to tests/pos-macros/semanticdb-macro-pos/example_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xsemanticdb
2+
13
import quoted.*
24

35
object TestImpl {

tests/pos-custom-args/semanticdb/macro-pos/example_3.scala renamed to tests/pos-macros/semanticdb-macro-pos/example_3.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xsemanticdb
2+
13
object Test {
24

35
def test = TestImpl.fun("")

tests/run-custom-args/Xmacro-settings/compileTimeEnv/Test.scala renamed to tests/run-macros/Xmacro-settings-compileTimeEnv/Test.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xmacro-settings:a,b=1,c.b.a=x.y.z=1,myLogger.level=INFO
2+
13
import scala.compiletime.*
24

35
object Test {
@@ -16,10 +18,10 @@ object Test {
1618
}
1719

1820
def runBasic(): Unit = {
19-
printEnv("a")
20-
printEnv("b")
21-
printEnv("c.b.a")
22-
printEnv("wat")
21+
printEnv("a")
22+
printEnv("b")
23+
printEnv("c.b.a")
24+
printEnv("wat")
2325
}
2426

2527
inline def printEnv(inline k: String): Unit =

tests/run-custom-args/Xmacro-settings/simple/Test.scala renamed to tests/run-macros/Xmacro-settings-simple/Test.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Xmacro-settings:one,two,three
2+
13
import x.*
24

35
object Test {

tests/run-custom-args/Yread-comments/i12351/Test_2.scala renamed to tests/run-macros/i12351/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yread-docs
2+
13
@main def Test(): Unit = {
24
println(getDocString[Data])
35
assert(getDocString[Data].nonEmpty)

tests/run-custom-args/Yread-comments/i12352/Main.scala renamed to tests/run-macros/i12352/Main.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yread-docs
2+
13
@main def Test(): Unit = {
24
val res = getDocString[scala.quoted.Quotes]
35
println(res)

tests/run-macros/i17105b.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
case erased: [erased case]
2+
case erased nested: c
3+
case erased nested 2: d
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import scala.language.experimental.erasedDefinitions
2+
3+
import scala.quoted.*
4+
5+
inline def testExpr(inline body: Any) = ${ testExprImpl('body) }
6+
def testExprImpl(body: Expr[Any])(using Quotes): Expr[String] =
7+
body match
8+
// Erased Types
9+
case '{ def erasedfn(y: String) = "placeholder"; $a(erasedfn): String } =>
10+
Expr("This case should not match")
11+
case '{ def erasedfn(erased y: String) = "placeholder"; $a(erasedfn): String } =>
12+
'{ $a((erased z: String) => "[erased case]") }
13+
case '{
14+
def erasedfn(a: String, b: String)(c: String, d: String): String = a
15+
$y(erasedfn): String
16+
} => Expr("This should not match")
17+
case '{
18+
def erasedfn(a: String, erased b: String)(erased c: String, d: String): String = a
19+
$y(erasedfn): String
20+
} =>
21+
'{ $y((a: String, erased b: String) => (erased c: String, d: String) => d) }
22+
case '{
23+
def erasedfn(a: String, erased b: String)(c: String, erased d: String): String = a
24+
$y(erasedfn): String
25+
} =>
26+
'{ $y((a: String, erased b: String) => (c: String, erased d: String) => c) }
27+
case _ => Expr("not matched")

tests/run-macros/i17105b/Test_2.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import scala.language.experimental.erasedDefinitions
2+
3+
@main def Test: Unit =
4+
println("case erased: " + testExpr { def erasedfn1(erased x: String) = "placeholder"; erasedfn1("arg1")})
5+
println("case erased nested: " + testExpr {
6+
def erasedfn2(p: String, erased q: String)(r: String, erased s: String) = p
7+
erasedfn2("a", "b")("c", "d")
8+
})
9+
println("case erased nested 2: " + testExpr {
10+
def erasedfn2(p: String, erased q: String)(erased r: String, s: String) = p
11+
erasedfn2("a", "b")("c", "d")
12+
})

tests/run-custom-args/run-macros-erased/macro-erased/1.scala renamed to tests/run-macros/macro-erased/Macro_1.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import scala.language.experimental.erasedDefinitions
2+
13
import scala.quoted.*
24

35
object Macro {

tests/run-custom-args/run-macros-erased/reflect-isFunctionType/test_2.scala renamed to tests/run-macros/reflect-isFunctionType/test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import scala.language.experimental.erasedDefinitions
2+
13
trait Box {
24
type T
35
}

tests/run-macros/tasty-definitions-1/quoted_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Yretain-trees
12

23
object Test {
34
def main(args: Array[String]): Unit = {

tests/run-custom-args/Yretain-trees/tasty-definitions-2/Test_2.scala renamed to tests/run-macros/tasty-definitions-2/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yretain-trees
2+
13
object Test {
24
def main(args: Array[String]): Unit = {
35
println(Foo.inspectBody(Foo.foo))

tests/run-custom-args/Yretain-trees/tasty-definitions-3/Test_2.scala renamed to tests/run-macros/tasty-definitions-3/Test_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// scalac: -Yretain-trees
2+
13
object Test {
24

35
def main(args: Array[String]): Unit = {

tests/run-custom-args/Yretain-trees/tasty-extractors-owners/quoted_2.scala renamed to tests/run-macros/tasty-extractors-owners/quoted_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Yretain-trees
12

23
import Macros.*
34

tests/run-custom-args/Yretain-trees/tasty-load-tree-1/quoted_2.scala renamed to tests/run-macros/tasty-load-tree-1/quoted_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Yretain-trees
12

23
object Test {
34
def main(args: Array[String]): Unit = {

tests/run-custom-args/Yretain-trees/tasty-load-tree-2/quoted_2.scala renamed to tests/run-macros/tasty-load-tree-2/quoted_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// scalac: -Yretain-trees
12

23
object Test {
34
def main(args: Array[String]): Unit = {

0 commit comments

Comments
 (0)