@@ -12,51 +12,89 @@ class RegexCoverageFilterTest extends FreeSpec with Matchers with MockitoSugar {
12
12
" isClassIncluded" - {
13
13
14
14
" should return true for empty excludes" in {
15
- assert(new RegexCoverageFilter (Nil , Nil ).isClassIncluded(" x" ))
15
+ assert(new RegexCoverageFilter (Nil , Nil , Nil ).isClassIncluded(" x" ))
16
16
}
17
17
18
18
" should not crash for empty input" in {
19
- assert(new RegexCoverageFilter (Nil , Nil ).isClassIncluded(" " ))
19
+ assert(new RegexCoverageFilter (Nil , Nil , Nil ).isClassIncluded(" " ))
20
20
}
21
21
22
22
" should exclude scoverage -> scoverage" in {
23
- assert(! new RegexCoverageFilter (Seq (" scoverage" ), Nil ).isClassIncluded(" scoverage" ))
23
+ assert(! new RegexCoverageFilter (Seq (" scoverage" ), Nil , Nil ).isClassIncluded(" scoverage" ))
24
24
}
25
25
26
26
" should include scoverage -> scoverageeee" in {
27
- assert(new RegexCoverageFilter (Seq (" scoverage" ), Nil ).isClassIncluded(" scoverageeee" ))
27
+ assert(new RegexCoverageFilter (Seq (" scoverage" ), Nil , Nil ).isClassIncluded(" scoverageeee" ))
28
28
}
29
29
30
30
" should exclude scoverage* -> scoverageeee" in {
31
- assert(! new RegexCoverageFilter (Seq (" scoverage*" ), Nil ).isClassIncluded(" scoverageeee" ))
31
+ assert(! new RegexCoverageFilter (Seq (" scoverage*" ), Nil , Nil ).isClassIncluded(" scoverageeee" ))
32
32
}
33
33
34
34
" should include eee -> scoverageeee" in {
35
- assert(new RegexCoverageFilter (Seq (" eee" ), Nil ).isClassIncluded(" scoverageeee" ))
35
+ assert(new RegexCoverageFilter (Seq (" eee" ), Nil , Nil ).isClassIncluded(" scoverageeee" ))
36
36
}
37
37
38
38
" should exclude .*eee -> scoverageeee" in {
39
- assert(! new RegexCoverageFilter (Seq (" .*eee" ), Nil ).isClassIncluded(" scoverageeee" ))
39
+ assert(! new RegexCoverageFilter (Seq (" .*eee" ), Nil , Nil ).isClassIncluded(" scoverageeee" ))
40
40
}
41
41
}
42
42
" isFileIncluded" - {
43
43
val abstractFile = mock[AbstractFile ]
44
44
Mockito .when(abstractFile.path).thenReturn(" sammy.scala" )
45
45
" should return true for empty excludes" in {
46
46
val file = new BatchSourceFile (abstractFile, Array .emptyCharArray)
47
- new RegexCoverageFilter (Nil , Nil ).isFileIncluded(file) shouldBe true
47
+ new RegexCoverageFilter (Nil , Nil , Nil ).isFileIncluded(file) shouldBe true
48
48
}
49
49
" should exclude by filename" in {
50
50
val file = new BatchSourceFile (abstractFile, Array .emptyCharArray)
51
- new RegexCoverageFilter (Nil , Seq (" sammy" )).isFileIncluded(file) shouldBe false
51
+ new RegexCoverageFilter (Nil , Seq (" sammy" ), Nil ).isFileIncluded(file) shouldBe false
52
52
}
53
53
" should exclude by regex wildcard" in {
54
54
val file = new BatchSourceFile (abstractFile, Array .emptyCharArray)
55
- new RegexCoverageFilter (Nil , Seq (" sam.*" )).isFileIncluded(file) shouldBe false
55
+ new RegexCoverageFilter (Nil , Seq (" sam.*" ), Nil ).isFileIncluded(file) shouldBe false
56
56
}
57
57
" should not exclude non matching regex" in {
58
58
val file = new BatchSourceFile (abstractFile, Array .emptyCharArray)
59
- new RegexCoverageFilter (Nil , Seq (" qweqeqwe" )).isFileIncluded(file) shouldBe true
59
+ new RegexCoverageFilter (Nil , Seq (" qweqeqwe" ), Nil ).isFileIncluded(file) shouldBe true
60
+ }
61
+ }
62
+ " isSymbolIncluded" - {
63
+ val options = new ScoverageOptions ()
64
+ " should return true for empty excludes" in {
65
+ assert(new RegexCoverageFilter (Nil , Nil , Nil ).isSymbolIncluded(" x" ))
66
+ }
67
+
68
+ " should not crash for empty input" in {
69
+ assert(new RegexCoverageFilter (Nil , Nil , Nil ).isSymbolIncluded(" " ))
70
+ }
71
+
72
+ " should exclude scoverage -> scoverage" in {
73
+ assert(! new RegexCoverageFilter (Nil , Nil , Seq (" scoverage" )).isSymbolIncluded(" scoverage" ))
74
+ }
75
+
76
+ " should include scoverage -> scoverageeee" in {
77
+ assert(new RegexCoverageFilter (Nil , Nil , Seq (" scoverage" )).isSymbolIncluded(" scoverageeee" ))
78
+ }
79
+ " should exclude scoverage* -> scoverageeee" in {
80
+ assert(! new RegexCoverageFilter (Nil , Nil , Seq (" scoverage*" )).isSymbolIncluded(" scoverageeee" ))
81
+ }
82
+
83
+ " should include eee -> scoverageeee" in {
84
+ assert(new RegexCoverageFilter (Nil , Nil , Seq (" eee" )).isSymbolIncluded(" scoverageeee" ))
85
+ }
86
+
87
+ " should exclude .*eee -> scoverageeee" in {
88
+ assert(! new RegexCoverageFilter (Nil , Nil , Seq (" .*eee" )).isSymbolIncluded(" scoverageeee" ))
89
+ }
90
+ " should exclude scala.reflect.api.Exprs.Expr" in {
91
+ assert(! new RegexCoverageFilter (Nil , Nil , options.excludedSymbols).isSymbolIncluded(" scala.reflect.api.Exprs.Expr" ))
92
+ }
93
+ " should exclude scala.reflect.macros.Universe.Tree" in {
94
+ assert(! new RegexCoverageFilter (Nil , Nil , options.excludedSymbols).isSymbolIncluded(" scala.reflect.macros.Universe.Tree" ))
95
+ }
96
+ " should exclude scala.reflect.api.Trees.Tree" in {
97
+ assert(! new RegexCoverageFilter (Nil , Nil , options.excludedSymbols).isSymbolIncluded(" scala.reflect.api.Trees.Tree" ))
60
98
}
61
99
}
62
100
" getExcludedLineNumbers" - {
@@ -72,7 +110,7 @@ class RegexCoverageFilterTest extends FreeSpec with Matchers with MockitoSugar {
72
110
|8
73
111
""" .stripMargin
74
112
75
- val numbers = new RegexCoverageFilter (Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
113
+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
76
114
numbers === List .empty
77
115
}
78
116
" should exclude lines between magic comments" in {
@@ -95,7 +133,7 @@ class RegexCoverageFilterTest extends FreeSpec with Matchers with MockitoSugar {
95
133
|16
96
134
""" .stripMargin
97
135
98
- val numbers = new RegexCoverageFilter (Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
136
+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
99
137
numbers === List (Range (4 , 9 ), Range (12 , 14 ))
100
138
}
101
139
" should exclude all lines after an upaired magic comment" in {
@@ -117,7 +155,7 @@ class RegexCoverageFilterTest extends FreeSpec with Matchers with MockitoSugar {
117
155
|15
118
156
""" .stripMargin
119
157
120
- val numbers = new RegexCoverageFilter (Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
158
+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
121
159
numbers === List (Range (4 , 9 ), Range (12 , 16 ))
122
160
}
123
161
" should allow text comments on the same line as the markers" in {
@@ -139,7 +177,7 @@ class RegexCoverageFilterTest extends FreeSpec with Matchers with MockitoSugar {
139
177
|15
140
178
""" .stripMargin
141
179
142
- val numbers = new RegexCoverageFilter (Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
180
+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
143
181
numbers === List (Range (4 , 9 ), Range (12 , 16 ))
144
182
}
145
183
}
0 commit comments