Skip to content

Commit

Permalink
Merge pull request #279 from tgodzik/add-support-for-3.0.0-M3
Browse files Browse the repository at this point in the history
Add support for Scala 3.0.0-M3
  • Loading branch information
tgodzik authored Dec 17, 2020
2 parents d3188d5 + 8034155 commit ca98bda
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 60 deletions.
6 changes: 4 additions & 2 deletions bin/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ coursier resolve \
org.scalameta:munit_2.11:$version \
org.scalameta:munit_2.12:$version \
org.scalameta:munit_2.13:$version \
org.scalameta:munit_3.0.0-M1:$version \
org.scalameta:munit_3.0.0-M2:$version \
org.scalameta:munit_3.0.0-M3:$version \
org.scalameta:munit_0.27:$version \
org.scalameta:munit_native0.4.0-M2_2.11:$version \
org.scalameta:munit_sjs1_2.11:$version \
Expand All @@ -19,7 +20,8 @@ coursier resolve \
org.scalameta:munit-scalacheck_2.12:$version \
org.scalameta:munit-scalacheck_2.13:$version \
org.scalameta:munit-scalacheck_0.27:$version \
org.scalameta:munit-scalacheck_3.0.0-M1:$version \
org.scalameta:munit-scalacheck_3.0.0-M2:$version \
org.scalameta:munit-scalacheck_3.0.0-M3:$version \
org.scalameta:munit-scalacheck_native0.4.0-M2_2.11:$version \
org.scalameta:munit-scalacheck_sjs1_2.11:$version \
org.scalameta:munit-scalacheck_sjs1_2.12:$version \
Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def previousVersion = "0.7.0"
def scala213 = "2.13.2"
def scala212 = "2.12.11"
def scala211 = "2.11.12"
def scala3Stable = "3.0.0-M2"
def scala3Previous = List("3.0.0-M1", "0.27.0-RC1")
def scala3Stable = "3.0.0-M3"
def scala3Previous = List("3.0.0-M2")
def junitVersion = "4.13"
def gcp = "com.google.cloud" % "google-cloud-storage" % "1.113.6"
inThisBuild(
Expand Down Expand Up @@ -251,7 +251,7 @@ lazy val munitScalacheck = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(
moduleName := "munit-scalacheck",
sharedSettings,
libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.15.1"
libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.15.2"
)
.jvmSettings(
sharedJVMSettings
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ object MacroCompat {
inline implicit def generate: Location = ${ locationImpl() }
}

def locationImpl()(using qctx: QuoteContext): Expr[Location] = {
import qctx.tasty.{_, given _}
val path = rootPosition.sourceFile.jpath.toString
val startLine = rootPosition.startLine + 1
def locationImpl()(using Quotes): Expr[Location] = {
import quotes.reflect._
val pos = Position.ofMacroExpansion
val path = pos.sourceFile.jpath.toString
val startLine = pos.startLine + 1
'{ new Location(${Expr(path)}, ${Expr(startLine)}) }
}

trait ClueMacro {
inline implicit def generate[T](value: T): Clue[T] = ${ clueImpl('value) }
}

def clueImpl[T:Type](value: Expr[T])(using qctx: QuoteContext): Expr[Clue[T]] = {
import qctx.tasty.{_, given _}
val source = value.unseal.pos.sourceCode
val valueType = implicitly[scala.quoted.Type[T]].show
def clueImpl[T: Type](value: Expr[T])(using Quotes): Expr[Clue[T]] = {
import quotes.reflect._
val source = Term.of(value).pos.sourceCode.getOrElse("")
val valueType = TypeTree.of[T].show(using Printer.TreeShortCode)
'{ new Clue(${Expr(source)}, $value, ${Expr(valueType)}) }
}

Expand Down
1 change: 1 addition & 0 deletions tests/shared/src/main/scala/munit/Tags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package munit

object OnlyJVM extends Tag("OnlyJVm") {}
object NoDotty extends Tag("NoDotty") {}
object OnlyFromM3 extends Tag("OnlyFromM3") {}
object Only213 extends Tag("Only213") {}
2 changes: 1 addition & 1 deletion tests/shared/src/test/scala/munit/AssertionsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AssertionsSuite extends BaseSuite {
cond: => Boolean,
expected: String
)(implicit loc: Location): Unit =
test(name.tag(NoDotty)) {
test(name.tag(OnlyFromM3)) {
val (_, clues) = munitCaptureClues(cond)
assertNoDiff(Printers.print(clues), expected)
}
Expand Down
4 changes: 4 additions & 0 deletions tests/shared/src/test/scala/munit/BaseSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class BaseSuite extends FunSuite {
BuildInfo.scalaVersion.startsWith("2.13") || isDotty
if (test.tags(NoDotty) && isDotty) {
test.tag(Ignore)
} else if (
test.tags(OnlyFromM3) && "3.0.0-M2" == BuildInfo.scalaVersion
) {
test.tag(Ignore)
} else if (test.tags(Only213) && !is213) {
test.tag(Ignore)
} else if (test.tags(OnlyJVM) && !PlatformCompat.isJVM) {
Expand Down

0 comments on commit ca98bda

Please sign in to comment.