Skip to content

Commit ca46b08

Browse files
committed
Adding test for #93
1 parent c6ae6e2 commit ca46b08

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class PluginCoverageTest
240240
compiler.assertNMeasuredStatements(3)
241241
}
242242

243-
test("scoverage should support yields") {
243+
test("plugin should support yields") {
244244
val compiler = ScoverageCompiler.default
245245
compiler.compileCodeSnippet( """
246246
| object Yielder {
@@ -255,7 +255,7 @@ class PluginCoverageTest
255255
compiler.assertNMeasuredStatements(11)
256256
}
257257

258-
test("scoverage should not instrument local macro implementation") {
258+
test("plugin should not instrument local macro implementation") {
259259
val compiler = ScoverageCompiler.default
260260
compiler.compileCodeSnippet( """
261261
| object MyMacro {
@@ -273,8 +273,7 @@ class PluginCoverageTest
273273
compiler.assertNoCoverage()
274274
}
275275

276-
// https://github.com/skinny-framework/skinny-framework/issues/97
277-
test("scoverage should not instrument expanded macro code") {
276+
test("plugin should not instrument expanded macro code github.com/skinny-framework/skinny-framework/issues/97") {
278277
val compiler = ScoverageCompiler.default
279278
compiler.addToClassPath("org.slf4j", "slf4j-api", "1.7.7")
280279
compiler
@@ -293,4 +292,28 @@ class PluginCoverageTest
293292
assert(!compiler.reporter.hasWarnings)
294293
compiler.assertNoCoverage()
295294
}
295+
296+
test("plugin should handle return inside catch github.com/scoverage/scalac-scoverage-plugin/issues/93") {
297+
val compiler = ScoverageCompiler.default
298+
compiler.compileCodeSnippet(
299+
"""
300+
| object bob {
301+
| def fail(): Boolean = {
302+
| try {
303+
| true
304+
| } catch {
305+
| case _: Throwable =>
306+
| Option(true) match {
307+
| case Some(bool) => return bool // comment this return and instrumentation succeeds
308+
| case _ =>
309+
| }
310+
| false
311+
| }
312+
| }
313+
| }
314+
""".stripMargin)
315+
assert(!compiler.reporter.hasErrors)
316+
assert(!compiler.reporter.hasWarnings)
317+
compiler.assertNMeasuredStatements(11)
318+
}
296319
}

0 commit comments

Comments
 (0)