@@ -12,51 +12,89 @@ class RegexCoverageFilterTest extends FreeSpec with Matchers with MockitoSugar {
1212 " isClassIncluded" - {
1313
1414 " should return true for empty excludes" in {
15- assert(new RegexCoverageFilter (Nil , Nil ).isClassIncluded(" x" ))
15+ assert(new RegexCoverageFilter (Nil , Nil , Nil ).isClassIncluded(" x" ))
1616 }
1717
1818 " should not crash for empty input" in {
19- assert(new RegexCoverageFilter (Nil , Nil ).isClassIncluded(" " ))
19+ assert(new RegexCoverageFilter (Nil , Nil , Nil ).isClassIncluded(" " ))
2020 }
2121
2222 " should exclude scoverage -> scoverage" in {
23- assert(! new RegexCoverageFilter (Seq (" scoverage" ), Nil ).isClassIncluded(" scoverage" ))
23+ assert(! new RegexCoverageFilter (Seq (" scoverage" ), Nil , Nil ).isClassIncluded(" scoverage" ))
2424 }
2525
2626 " should include scoverage -> scoverageeee" in {
27- assert(new RegexCoverageFilter (Seq (" scoverage" ), Nil ).isClassIncluded(" scoverageeee" ))
27+ assert(new RegexCoverageFilter (Seq (" scoverage" ), Nil , Nil ).isClassIncluded(" scoverageeee" ))
2828 }
2929
3030 " should exclude scoverage* -> scoverageeee" in {
31- assert(! new RegexCoverageFilter (Seq (" scoverage*" ), Nil ).isClassIncluded(" scoverageeee" ))
31+ assert(! new RegexCoverageFilter (Seq (" scoverage*" ), Nil , Nil ).isClassIncluded(" scoverageeee" ))
3232 }
3333
3434 " should include eee -> scoverageeee" in {
35- assert(new RegexCoverageFilter (Seq (" eee" ), Nil ).isClassIncluded(" scoverageeee" ))
35+ assert(new RegexCoverageFilter (Seq (" eee" ), Nil , Nil ).isClassIncluded(" scoverageeee" ))
3636 }
3737
3838 " should exclude .*eee -> scoverageeee" in {
39- assert(! new RegexCoverageFilter (Seq (" .*eee" ), Nil ).isClassIncluded(" scoverageeee" ))
39+ assert(! new RegexCoverageFilter (Seq (" .*eee" ), Nil , Nil ).isClassIncluded(" scoverageeee" ))
4040 }
4141 }
4242 " isFileIncluded" - {
4343 val abstractFile = mock[AbstractFile ]
4444 Mockito .when(abstractFile.path).thenReturn(" sammy.scala" )
4545 " should return true for empty excludes" in {
4646 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
4848 }
4949 " should exclude by filename" in {
5050 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
5252 }
5353 " should exclude by regex wildcard" in {
5454 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
5656 }
5757 " should not exclude non matching regex" in {
5858 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" ))
6098 }
6199 }
62100 " getExcludedLineNumbers" - {
@@ -72,7 +110,7 @@ class RegexCoverageFilterTest extends FreeSpec with Matchers with MockitoSugar {
72110 |8
73111 """ .stripMargin
74112
75- val numbers = new RegexCoverageFilter (Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
113+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
76114 numbers === List .empty
77115 }
78116 " should exclude lines between magic comments" in {
@@ -95,7 +133,7 @@ class RegexCoverageFilterTest extends FreeSpec with Matchers with MockitoSugar {
95133 |16
96134 """ .stripMargin
97135
98- val numbers = new RegexCoverageFilter (Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
136+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
99137 numbers === List (Range (4 , 9 ), Range (12 , 14 ))
100138 }
101139 " should exclude all lines after an upaired magic comment" in {
@@ -117,7 +155,7 @@ class RegexCoverageFilterTest extends FreeSpec with Matchers with MockitoSugar {
117155 |15
118156 """ .stripMargin
119157
120- val numbers = new RegexCoverageFilter (Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
158+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
121159 numbers === List (Range (4 , 9 ), Range (12 , 16 ))
122160 }
123161 " should allow text comments on the same line as the markers" in {
@@ -139,7 +177,7 @@ class RegexCoverageFilterTest extends FreeSpec with Matchers with MockitoSugar {
139177 |15
140178 """ .stripMargin
141179
142- val numbers = new RegexCoverageFilter (Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
180+ val numbers = new RegexCoverageFilter (Nil , Nil , Nil ).getExcludedLineNumbers(mockSourceFile(file))
143181 numbers === List (Range (4 , 9 ), Range (12 , 16 ))
144182 }
145183 }
0 commit comments