-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathCheckMacroPrivateTest.scala
More file actions
60 lines (54 loc) · 1.61 KB
/
CheckMacroPrivateTest.scala
File metadata and controls
60 lines (54 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.avsystem.commons
package analyzer
import org.scalatest.funsuite.AnyFunSuite
final class CheckMacroPrivateTest extends AnyFunSuite with AnalyzerTest {
test("macro private method invoked directly should be rejected") {
assertErrors(1,
scala"""
|import com.avsystem.commons.analyzer.TestUtils
|
|object test {
| TestUtils.macroPrivateMethod
|}
|""".stripMargin
)
}
test("macro private extractor used directly should be rejected") {
assertErrors(1,
scala"""
|import com.avsystem.commons.analyzer.TestUtils
|
|object test {
| 123 match {
| case TestUtils.Extractor(_) =>
| }
|}
|""".stripMargin
)
}
test("macro private method invoked by macro-generated code should not be rejected") {
assertNoErrors(
scala"""
|import com.avsystem.commons.analyzer.TestUtils
|
|object test {
| TestUtils.invokeMacroPrivateMethod
|}
|""".stripMargin
)
}
test("definitions of macro private symbols themselves should not be rejected") {
assertNoErrors(
scala"""
|import com.avsystem.commons.annotation.macroPrivate
|
|object test {
| @macroPrivate def macroPrivateMethod = { println("whatever"); 5 }
| @macroPrivate object macroPrivateObject {
| final val X = 42
| }
|}
|""".stripMargin
)
}
}