diff --git a/shared/src/main/scala-2/verify/sourcecode/Compat.scala b/shared/src/main/scala-2/verify/sourcecode/Compat.scala index 02ee309..07afc9d 100644 --- a/shared/src/main/scala-2/verify/sourcecode/Compat.scala +++ b/shared/src/main/scala-2/verify/sourcecode/Compat.scala @@ -26,5 +26,6 @@ object Compat { nearestEnclosingMethod(enclosingOwner(c)).asMethod.paramLists } - def isDotty: Boolean = false + def isScala3: Boolean = false + def isDotty: Boolean = isScala3 } diff --git a/shared/src/main/scala-3/verify/asserts/RecorderMacro.scala b/shared/src/main/scala-3/verify/asserts/RecorderMacro.scala index 2cd11d7..6a36ac3 100644 --- a/shared/src/main/scala-3/verify/asserts/RecorderMacro.scala +++ b/shared/src/main/scala-3/verify/asserts/RecorderMacro.scala @@ -131,21 +131,24 @@ class RecorderMacro(using qctx0: Quotes) { runtime.select(m) } def skipIdent(sym: Symbol): Boolean = - sym.fullName match { - case "scala" | "java" => true - case fullName if fullName.startsWith("scala.") => true - case fullName if fullName.startsWith("java.") => true - case _ => false + sym match { + case sym if sym.isDefDef => sym.signature.paramSigs.nonEmpty + case _ => + sym.fullName match { + case "scala" | "java" => true + case fullName if fullName.startsWith("scala.") => true + case fullName if fullName.startsWith("java.") => true + case _ => false + } } - def skipSelect(sym: Symbol): Boolean = { + def skipSelect(sym: Symbol): Boolean = (sym match { - case sym if sym.isDefDef => sym.signature.paramSigs.nonEmpty + case sym if sym.isDefDef => skipIdent(sym) case sym if sym.isValDef => skipIdent(sym) case _ => true }) - } expr match { case Select(_, _) if skipSelect(expr.symbol) => expr case TypeApply(_, _) => expr diff --git a/shared/src/main/scala-3/verify/sourcecode/Compat.scala b/shared/src/main/scala-3/verify/sourcecode/Compat.scala index c57cc1e..db44501 100644 --- a/shared/src/main/scala-3/verify/sourcecode/Compat.scala +++ b/shared/src/main/scala-3/verify/sourcecode/Compat.scala @@ -14,5 +14,6 @@ package verify package sourcecode object Compat { - def isDotty: Boolean = true + def isScala3: Boolean = true + def isDotty: Boolean = isScala3 } diff --git a/shared/src/test/scala/example/asserttest/RenderingTest.scala b/shared/src/test/scala/example/asserttest/RenderingTest.scala index 44af754..216c066 100644 --- a/shared/src/test/scala/example/asserttest/RenderingTest.scala +++ b/shared/src/test/scala/example/asserttest/RenderingTest.scala @@ -13,7 +13,7 @@ package example.asserttest import verify._ -import verify.sourcecode.Compat.isDotty +import verify.sourcecode.Compat.isScala3 object RenderingTest extends BasicTestSuite { test("literals") { @@ -22,7 +22,7 @@ object RenderingTest extends BasicTestSuite { "abc".length() == 2 | | 3 false - """) { + """) { assert { "abc".length() == 2 } @@ -30,7 +30,7 @@ object RenderingTest extends BasicTestSuite { } test("List.apply") { - if (isDotty) { + if (isScala3) { outputs("""assertion failed List() == List(1, 2) @@ -58,7 +58,7 @@ List() == List(1, 2) } test("List.apply2") { - if (isDotty) { + if (isScala3) { outputs("""assertion failed List(1, 2) == List() @@ -239,7 +239,7 @@ Person(Fred,42) val brand = "BMW" val model = "M5" - if (isDotty) { + if (isScala3) { outputs("""assertion failed Car(brand, model).brand == "Audi" @@ -266,8 +266,22 @@ BMW M5 } } + test("method apply") { + outputs("""assertion failed + +something(0) == "something1" +| | +something false + + """) { + assert { + something(0) == "something1" + } + } + } + test("tuple") { - if (isDotty) { + if (isScala3) { outputs("""assertion failed (1, 2)._1 == 3 @@ -308,7 +322,7 @@ Some(23) | Some(22) test("message") { val person = Person() - if (isDotty) { + if (isScala3) { outputs("""assertion failed: something something person.age == 43 @@ -346,7 +360,7 @@ assert(person.age == 43, "something something") |have it sterile with idleness, or manured with industry, why, the power |and corrigible authority of this lies in our wills.""".stripMargin - if (isDotty) { + if (isScala3) { outputs( """assertion failed: custom message @@ -407,6 +421,8 @@ and corrigible authority of this lies in our wills. | } } + def something(x: Int): String = "something" + case class Person(name: String = "Fred", age: Int = 42) { def doIt() = "done" def sayTwice(word: String) = word * 2 @@ -417,4 +433,5 @@ and corrigible authority of this lies in our wills. | case class Car(val brand: String, val model: String) { override def toString = brand + " " + model } + }