Skip to content

Commit

Permalink
Merge branch 'cheeseng-release-3.2.9' into 3.2.x-new
Browse files Browse the repository at this point in the history
  • Loading branch information
bvenners committed May 16, 2021
2 parents 174a1c8 + aae88a3 commit d3c223a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 10 deletions.
43 changes: 43 additions & 0 deletions jvm/diagrams/src/main/scala/org/scalatest/diagrams/Diagrams.scala
Expand Up @@ -346,6 +346,27 @@ object Diagrams extends Diagrams {
lines.mkString(Prettifier.lineSeparator)
}

private[this] def filterAndSortByAnchorOld(anchorValues: List[org.scalatest.AnchorValue]): Traversable[org.scalatest.AnchorValue] = {
var map = TreeMap[Int, org.scalatest.AnchorValue]()(Ordering.by(-_))
// values stemming from compiler generated code often have the same anchor as regular values
// and get recorded before them; let's filter them out
for (value <- anchorValues) if (!map.contains(value.anchor)) map += (value.anchor -> value)
map.values
}

private[this] def renderDiagramOld(sourceText: String, anchorValues: List[org.scalatest.AnchorValue]): String = {
val offset = sourceText.prefixLength(_.isWhitespace)
val intro = new StringBuilder().append(sourceText.trim())
val lines = ListBuffer(new StringBuilder)

val rightToLeft = filterAndSortByAnchorOld(anchorValues)
for (anchorValue <- rightToLeft) placeValue(lines, anchorValue.value, anchorValue.anchor - offset)

lines.prepend(intro)
lines.append(new StringBuilder)
lines.mkString(Prettifier.lineSeparator)
}

/**
* Assert that the passed in <code>Bool</code> is <code>true</code>, else fail with <code>TestFailedException</code>
* with error message that include a diagram showing expression values.
Expand All @@ -363,6 +384,17 @@ object Diagrams extends Diagrams {
Succeeded
}

@deprecated("This function is deprecated and will be removed in future, please use macroAssert that takes org.scalatest.diagrams.DiagrammedExpr")
def macroAssert(bool: org.scalatest.DiagrammedExpr[Boolean], clue: Any, sourceText: String, pos: source.Position): Assertion = {
requireNonNull(clue)
if (!bool.value) {
val failureMessage =
Some(clue.toString + Prettifier.lineSeparator + Prettifier.lineSeparator + renderDiagramOld(sourceText, bool.anchorValues))
throw newAssertionFailedException(failureMessage, None, pos, Vector.empty)
}
Succeeded
}

/**
* Assume that the passed in <code>Bool</code> is <code>true</code>, else throw <code>TestCanceledException</code>
* with error message that include a diagram showing expression values.
Expand All @@ -379,6 +411,17 @@ object Diagrams extends Diagrams {
}
Succeeded
}

@deprecated("This function is deprecated and will be removed in future, please use macroAssume that takes org.scalatest.diagrams.DiagrammedExpr")
def macroAssume(bool: org.scalatest.DiagrammedExpr[Boolean], clue: Any, sourceText: String, pos: source.Position): Assertion = {
requireNonNull(clue)
if (!bool.value) {
val failureMessage =
Some(clue.toString + Prettifier.lineSeparator + Prettifier.lineSeparator + renderDiagramOld(sourceText, bool.anchorValues))
throw newTestCanceledException(failureMessage, None, pos)
}
Succeeded
}
}

/**
Expand Down
8 changes: 4 additions & 4 deletions project/BuildCommons.scala
Expand Up @@ -16,12 +16,12 @@ trait BuildCommons {
"org.scala-js" %% "scalajs-test-interface" % scalaJSVersion
)

val releaseVersion = "3.2.8"
val releaseVersion = "3.2.9"

val previousReleaseVersion = "3.2.7"
val previousReleaseVersion = "3.2.8"

val plusJUnitVersion = "3.2.8.0"
val plusTestNGVersion = "3.2.8.0"
val plusJUnitVersion = "3.2.9.0"
val plusTestNGVersion = "3.2.9.0"
val flexmarkVersion = "0.36.8"

def rootProject: Project
Expand Down
7 changes: 4 additions & 3 deletions project/DottyBuild.scala
@@ -1,3 +1,4 @@
import dotty.tools.sbtplugin.DottyPlugin.autoImport._
import sbt._
import Keys._
import com.typesafe.tools.mima.plugin.MimaKeys.{mimaPreviousArtifacts, mimaCurrentClassfiles, mimaBinaryIssueFilters}
Expand All @@ -15,7 +16,7 @@ trait DottyBuild { this: BuildCommons =>

// List of available night build at https://repo1.maven.org/maven2/ch/epfl/lamp/dotty-compiler_0.27/
// lazy val dottyVersion = dottyLatestNightlyBuild.get
lazy val dottyVersion = System.getProperty("scalatest.dottyVersion", "3.0.0-RC3")
lazy val dottyVersion = System.getProperty("scalatest.dottyVersion", "3.0.0")
lazy val dottySettings = List(
scalaVersion := dottyVersion,
scalacOptions ++= List("-language:implicitConversions", "-noindent", "-Xprint-suspension")
Expand Down Expand Up @@ -232,8 +233,8 @@ trait DottyBuild { this: BuildCommons =>
initialCommands in console := """|import org.scalatest._
|import org.scalactic._
|import Matchers._""".stripMargin,
libraryDependencies += "org.scala-lang.modules" %%% "scala-xml" % "2.0.0-RC1",
libraryDependencies += ("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion).cross(CrossVersion.for3Use2_13),
libraryDependencies += "org.scala-lang.modules" %%% "scala-xml" % "2.0.0",
libraryDependencies += ("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion).withDottyCompat(dottyVersion),
packageManagedSources,
sourceGenerators in Compile += Def.task {
GenModulesDotty.genScalaTestCoreJS((sourceManaged in Compile).value, version.value, scalaVersion.value) ++
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
@@ -1 +1 @@
sbt.version=1.5.2
sbt.version=1.4.9
2 changes: 2 additions & 0 deletions project/plugins.sbt
Expand Up @@ -17,3 +17,5 @@ val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).getOrElse(
addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)

addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.7.0")

addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.5")
4 changes: 2 additions & 2 deletions project/scalatest.scala
Expand Up @@ -131,7 +131,7 @@ object ScalatestBuild extends BuildCommons with DottyBuild with NativeBuild with
def scalaXmlDependency(theScalaVersion: String): Seq[ModuleID] =
CrossVersion.partialVersion(theScalaVersion) match {
case Some((scalaEpoch, scalaMajor)) if scalaEpoch == 3 =>
Seq(("org.scala-lang.modules" %% "scala-xml" % "2.0.0-RC1"))
Seq(("org.scala-lang.modules" %% "scala-xml" % "2.0.0"))
case Some((scalaEpoch, scalaMajor)) if scalaEpoch == 2 && scalaMajor >= 11 =>
Seq(("org.scala-lang.modules" %% "scala-xml" % "1.3.0"))
case other =>
Expand Down Expand Up @@ -164,7 +164,7 @@ object ScalatestBuild extends BuildCommons with DottyBuild with NativeBuild with

case Some((3, _)) =>
Seq(
"org.scala-lang.modules" %%% "scala-parser-combinators" % "1.2.0-RC2"
"org.scala-lang.modules" %%% "scala-parser-combinators" % "2.0.0"
)

case Some((2, scalaMajor)) if scalaMajor >= 11 =>
Expand Down

0 comments on commit d3c223a

Please sign in to comment.