diff --git a/build.sbt b/build.sbt index c3a87e4a7d..c25f75549c 100644 --- a/build.sbt +++ b/build.sbt @@ -33,9 +33,9 @@ lazy val specs2Settings = Seq( organization := "org.specs2", GlobalScope / scalazVersion := "7.2.32", specs2ShellPrompt, - ThisBuild / scalaVersion := "2.13.10", + ThisBuild / scalaVersion := "2.13.14", SettingKey[Boolean]("ide-skip-project").withRank(KeyRanks.Invisible) := platformDepsCrossVersion.value == ScalaNativeCrossVersion.binary, - ThisBuild / crossScalaVersions := Seq("2.13.8", "2.12.17")) + ThisBuild / crossScalaVersions := Seq("2.13.14", "2.12.17")) lazy val tagName = Def.setting { s"specs2-${version.value}" @@ -424,7 +424,13 @@ lazy val compilationSettings = Seq( "-Xlint", "-Ywarn-numeric-widen", "-Ywarn-value-discard", - "-deprecation:false", "-Xcheckinit", "-unchecked", "-feature", "-language:_"), + "-deprecation:false", + "-Xcheckinit", + "-unchecked", + "-feature", + "-language:_", + "-Wunused:-nowarn", + ), Compile / scalacOptions ++= { CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, v)) if v <= 12 => @@ -449,7 +455,7 @@ lazy val compilationSettings = Seq( "-Xlint:-byname-implicit") } }, - addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.13.2" cross CrossVersion.full), + addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.13.3" cross CrossVersion.full), Test / scalacOptions += "-Yrangepos", Compile / doc / scalacOptions ++= Seq("-feature", "-language:_"), Compile / console / scalacOptions := Seq("-Yrangepos", "-feature", "-language:_"), diff --git a/common/js/src/main/scala/org/specs2/concurrent/ExecutionEnv.scala b/common/js/src/main/scala/org/specs2/concurrent/ExecutionEnv.scala index f66d07c159..eba13bf989 100644 --- a/common/js/src/main/scala/org/specs2/concurrent/ExecutionEnv.scala +++ b/common/js/src/main/scala/org/specs2/concurrent/ExecutionEnv.scala @@ -25,7 +25,7 @@ case class ExecutionEnv(executorServices: ExecutorServices, lazy val executionContext = executorServices.executionContext lazy val scheduler = executorServices.scheduler - implicit lazy val ec = executorServices.executionContext + implicit lazy val ec: ExecutionContext = executorServices.executionContext } object ExecutionEnv { diff --git a/common/native/src/main/scala/org/specs2/concurrent/ExecutionEnv.scala b/common/native/src/main/scala/org/specs2/concurrent/ExecutionEnv.scala index a497c8c0cf..d445bf1fd3 100644 --- a/common/native/src/main/scala/org/specs2/concurrent/ExecutionEnv.scala +++ b/common/native/src/main/scala/org/specs2/concurrent/ExecutionEnv.scala @@ -24,7 +24,7 @@ case class ExecutionEnv(executorServices: ExecutorServices, lazy val executionContext = executorServices.executionContext lazy val scheduler = executorServices.scheduler - implicit lazy val ec = executorServices.executionContext + implicit lazy val ec: ExecutionContext = executorServices.executionContext } object ExecutionEnv { diff --git a/common/shared/src/main/scala/org/specs2/control/eff/SafeEffect.scala b/common/shared/src/main/scala/org/specs2/control/eff/SafeEffect.scala index 868eb5ef8e..a06b8817f5 100644 --- a/common/shared/src/main/scala/org/specs2/control/eff/SafeEffect.scala +++ b/common/shared/src/main/scala/org/specs2/control/eff/SafeEffect.scala @@ -5,6 +5,7 @@ import org.specs2.fp._ import org.specs2.fp.syntax._ import eff._ import interpret._ +import SafeInterpretation._ import scala.reflect.ClassTag @@ -122,16 +123,16 @@ trait SafeInterpretation extends SafeCreation { outer => var error: Option[Throwable] = None val traversed: T[X] = xs.map { - case FailedFinalizer(t) => failedFinalizers.append(t); ().asInstanceOf[X] - case FailedValue(t) => error = Some(t); ().asInstanceOf[X] + case FailedFinalizer(t) => failedFinalizers.append(t); unitCastTo[X] + case FailedValue(t) => error = Some(t); unitCastTo[X] case EvaluateValue(v) => error match { case None => Either.catchNonFatal(v.value) match { case Right(a) => a - case Left(t) => error = Some(t); ().asInstanceOf[X] + case Left(t) => error = Some(t); unitCastTo[X] } - case Some(_) => ().asInstanceOf[X] + case Some(_) => unitCastTo[X] } } @@ -147,16 +148,16 @@ trait SafeInterpretation extends SafeCreation { outer => var error: Option[Throwable] = None val traversed: T[X] = xs.map { - case FailedFinalizer(t) => { failedFinalizers.append(t); ().asInstanceOf[X] } - case FailedValue(t) => { error = Some(t); ().asInstanceOf[X] } + case FailedFinalizer(t) => { failedFinalizers.append(t); unitCastTo[X] } + case FailedValue(t) => { error = Some(t); unitCastTo[X] } case EvaluateValue(v) => error match { case None => Either.catchNonFatal(v.value) match { case Right(a) => a - case Left(t) => error = Some(t); ().asInstanceOf[X] + case Left(t) => error = Some(t); unitCastTo[X] } - case Some(_) => ().asInstanceOf[X] + case Some(_) => unitCastTo[X] } } @@ -167,6 +168,7 @@ trait SafeInterpretation extends SafeCreation { outer => } } + } @@ -235,12 +237,12 @@ trait SafeInterpretation extends SafeCreation { outer => val failedValues = new collection.mutable.ListBuffer[FailedValue[X]] val traversed: T[X] = xs.map { - case FailedFinalizer(t) => ().asInstanceOf[X] - case FailedValue(t) => ().asInstanceOf[X] + case FailedFinalizer(t) => unitCastTo[X] + case FailedValue(t) => unitCastTo[X] case EvaluateValue(v) => Either.catchNonFatal(v.value) match { case Right(a) => a - case Left(t) => failedValues.append(FailedValue[X](t)); ().asInstanceOf[X] + case Left(t) => failedValues.append(FailedValue[X](t)); unitCastTo[X] } } @@ -262,12 +264,12 @@ trait SafeInterpretation extends SafeCreation { outer => val failedValues = new collection.mutable.ListBuffer[FailedValue[X]] val traversed: T[X] = xs.map { - case FailedFinalizer(t) => ().asInstanceOf[X] - case FailedValue(t) => ().asInstanceOf[X] + case FailedFinalizer(t) => unitCastTo[X] + case FailedValue(t) => unitCastTo[X] case EvaluateValue(v) => Either.catchNonFatal(v.value) match { case Right(a) => a - case Left(t) => failedValues.append(FailedValue[X](t)); ().asInstanceOf[X] + case Left(t) => failedValues.append(FailedValue[X](t)); unitCastTo[X] } } @@ -341,7 +343,11 @@ trait SafeInterpretation extends SafeCreation { outer => } -object SafeInterpretation extends SafeInterpretation + +object SafeInterpretation extends SafeInterpretation { + @annotation.nowarn + private def unitCastTo[X]: X = ().asInstanceOf[X] +} /** * The Safe type is a mix of a ThrowableEither / Eval effect diff --git a/core/jvm/src/test/scala/org/specs2/control/ActionsSpec.scala b/core/jvm/src/test/scala/org/specs2/control/ActionsSpec.scala index c59c41504f..db439576d0 100644 --- a/core/jvm/src/test/scala/org/specs2/control/ActionsSpec.scala +++ b/core/jvm/src/test/scala/org/specs2/control/ActionsSpec.scala @@ -2,7 +2,6 @@ package org.specs2.control import org.specs2._ import io._ -import eff._, syntax.all._ class ActionsSpec extends Specification { def is = s2""" diff --git a/core/jvm/src/test/scala/org/specs2/reporter/NotifierSpec.scala b/core/jvm/src/test/scala/org/specs2/reporter/NotifierSpec.scala index cef5d93f1d..618b036076 100644 --- a/core/jvm/src/test/scala/org/specs2/reporter/NotifierSpec.scala +++ b/core/jvm/src/test/scala/org/specs2/reporter/NotifierSpec.scala @@ -2,7 +2,6 @@ package org.specs2 package reporter import main._ -import control._ import execute._ import io.StringOutput import org.specs2.specification.{AfterAll, Tables} diff --git a/core/jvm/src/test/scala/org/specs2/runner/SbtSelectorSpec.scala b/core/jvm/src/test/scala/org/specs2/runner/SbtSelectorSpec.scala index 4c14e64b53..d036330258 100644 --- a/core/jvm/src/test/scala/org/specs2/runner/SbtSelectorSpec.scala +++ b/core/jvm/src/test/scala/org/specs2/runner/SbtSelectorSpec.scala @@ -72,6 +72,7 @@ class SbtSelectorSpec extends Specification { private def testName(event: Event): String = { event.selector() match { case ts: TestSelector => ts.testName() + case other => s"no test selector found. Got: ${other}" } } diff --git a/core/shared/src/main/scala/org/specs2/specification/script/StepParsers.scala b/core/shared/src/main/scala/org/specs2/specification/script/StepParsers.scala index 998f9b4041..e5dd2c4a35 100644 --- a/core/shared/src/main/scala/org/specs2/specification/script/StepParsers.scala +++ b/core/shared/src/main/scala/org/specs2/specification/script/StepParsers.scala @@ -2,8 +2,6 @@ package org.specs2 package specification package script -import scala.util.matching.Regex - import util.matching.Regex import control.{ImplicitParameters, Use} import control.Exceptions._ diff --git a/core/shared/src/test/scala/org/specs2/mutable/FutureExpectationsSpec.scala b/core/shared/src/test/scala/org/specs2/mutable/FutureExpectationsSpec.scala index 970703d562..36baa3d675 100644 --- a/core/shared/src/test/scala/org/specs2/mutable/FutureExpectationsSpec.scala +++ b/core/shared/src/test/scala/org/specs2/mutable/FutureExpectationsSpec.scala @@ -4,6 +4,7 @@ package mutable import scala.concurrent.Future import scala.concurrent.ExecutionContext.Implicits.global +@annotation.nowarn class FutureExpectationsImmutableSpec extends org.specs2.Specification { def is = s2""" A specification can return future results @@ -16,14 +17,15 @@ class FutureExpectationsImmutableSpec extends org.specs2.Specification { def is } +@annotation.nowarn class FutureExpectationsMutableSpec extends org.specs2.mutable.Specification { "A specification can return future results" >> { "For example here" in { - Future.apply(1 === 1) + Future.apply(1 === 1)(global) } "For example there" in { withTitle: String => - Future.apply(withTitle === "For example there") + Future.apply(withTitle === "For example there")(global) } } diff --git a/core/shared/src/test/scala/org/specs2/specification/SharedInstantiationSpec.scala b/core/shared/src/test/scala/org/specs2/specification/SharedInstantiationSpec.scala index 2833b4ff73..af304cebe4 100644 --- a/core/shared/src/test/scala/org/specs2/specification/SharedInstantiationSpec.scala +++ b/core/shared/src/test/scala/org/specs2/specification/SharedInstantiationSpec.scala @@ -9,6 +9,7 @@ import org.specs2.main._ * the following specifications should be instantiable from both the JVM and ScalaJS */ +@annotation.nowarn class Shared1Spec extends mutable.Specification { import scala.concurrent.ExecutionContext.Implicits.global "This must work with the global Execution Context" should { diff --git a/markdown/src/test/scala/org/specs2/text/MarkdownSpec.scala b/markdown/src/test/scala/org/specs2/text/MarkdownSpec.scala index e0964827af..2454488710 100644 --- a/markdown/src/test/scala/org/specs2/text/MarkdownSpec.scala +++ b/markdown/src/test/scala/org/specs2/text/MarkdownSpec.scala @@ -5,7 +5,7 @@ import org.specs2.main.Arguments import org.specs2.mutable._ class MarkdownSpec extends Spec { - implicit val defaultArgs = Arguments() + implicit val defaultArgs: Arguments = Arguments() "Emphasized text" >> { toHtmlNoPar("_hello_") must_== "hello" } diff --git a/matcher-extra/shared/src/main/scala/org/specs2/matcher/XmlMatchers.scala b/matcher-extra/shared/src/main/scala/org/specs2/matcher/XmlMatchers.scala index c5ecd9fe09..79f17554d4 100644 --- a/matcher-extra/shared/src/main/scala/org/specs2/matcher/XmlMatchers.scala +++ b/matcher-extra/shared/src/main/scala/org/specs2/matcher/XmlMatchers.scala @@ -19,43 +19,43 @@ object XmlMatchers extends XmlMatchers private[specs2] trait XmlBaseMatchers { outer => - - /** + + /** * match if `node` is contained anywhere inside the tested node - * an exact match on is required on attributes - */ + * an exact match on is required on attributes + */ def \\(node: Node, attributes: String*): XmlMatcher = deepMatch(node, attributes.toList) /** match if `node` is contained anywhere inside the tested node */ - def \\(node: Node): XmlMatcher = deepMatch(node, Nil) + def \\(node: Node): XmlMatcher = deepMatch(node, Nil) /** alias for `\\(node)` with the node label only */ def \\(label: String, attributes: String*) = deepMatch(label, attributes.toList) /** * match if `node` is contained anywhere inside the tested node and has exactly the `attributeValues` * as names and values for its attributes - */ - def \\(node: Node, attributeValues1: (String, String), attributeValues: (String, String)*) = + */ + def \\(node: Node, attributeValues1: (String, String), attributeValues: (String, String)*) = deepMatch(node, Map((attributeValues1 :: attributeValues.toList): _*)) /** alias for `\\(node, attributeValues)` with the node label only */ def \\(label: String, attributeValues1: (String, String), attributeValues: (String, String)*) = deepMatch(label, Map((attributeValues1 :: attributeValues.toList): _*)) - /** + /** * match if `node` is the first node of the tested node - * an exact match on is required on attributes - */ + * an exact match on is required on attributes + */ def \(node: Node, attributes: String*): XmlMatcher = firstMatch(node, attributes.toList) /** match if `node` is the first node of the tested node */ - def \(node: Node): XmlMatcher = firstMatch(node, Nil) + def \(node: Node): XmlMatcher = firstMatch(node, Nil) /** alias for `\(node)` with the node label only */ def \(label: String, attributes: String*) = firstMatch(label, attributes.toList) /** * match if `node` is the first node of the tested node and has exactly the `attributeValues` * as names and values for its attributes - */ - def \(node: Node, attributeValues1: (String, String), attributeValues: (String, String)*) = + */ + def \(node: Node, attributeValues1: (String, String), attributeValues: (String, String)*) = firstMatch(node, Map((attributeValues1 :: attributeValues.toList): _*)) /** alias for `\\(node, attributeValues)` with the node label only */ - def \(label: String, attributeValues1: (String, String), attributeValues: (String, String)*) = + def \(label: String, attributeValues1: (String, String), attributeValues: (String, String)*) = firstMatch(label, Map((attributeValues1 :: attributeValues.toList): _*)) /** match if `node` is equal to the tested node without testing empty text */ @@ -116,7 +116,7 @@ trait XmlBeHaveMatchers extends BeHaveMatchers { outer: XmlBaseMatchers => } /** * Matcher for equalIgnoreSpace comparison, ignoring the nodes order - */ + */ class EqualIgnoringSpaceMatcher(node: Seq[Node]) extends Matcher[Seq[Node]] with XmlMatcherKoMessage { def apply[S <: Seq[Node]](n: Expectable[S]) = { @@ -128,7 +128,7 @@ class EqualIgnoringSpaceMatcher(node: Seq[Node]) extends Matcher[Seq[Node]] with } /** * Matcher for equalIgnoreSpace comparison, considering the node order - */ + */ class EqualIgnoringSpaceMatcherOrdered(node: Seq[Node]) extends Matcher[Seq[Node]] with XmlMatcherKoMessage { def apply[S <: Seq[Node]](n: Expectable[S]) = { result(isEqualIgnoringSpaceOrdered(node.toList, n.value.toList), @@ -149,7 +149,7 @@ trait XmlMatcherKoMessage { *
  • a given direct child, with its label and/or attributes and/or attributes names and values *
  • a given child, direct or not (maybe deeply nested), with its label and/or attributes and/or attributes names and values * - * + * * XmlMatchers can be "chained" by using the \ or the \\ methods. In that case, the resulting matcher has a new * search function which tries to match the result of the preceding function. For example
      *  must \\("c").\("d")
    will be ok. @@ -163,26 +163,26 @@ case class XmlMatcher(functions: Seq[PathFunction]) extends Matcher[Seq[Node]] { def apply[S <: Seq[Node]](n: Expectable[S]) = { val nodes = n val (success, okMessage, koMessage) = checkFunctions(functions, nodes.value, (true, "", "")) - result(success, - nodes.description + okMessage, - nodes.description + koMessage, nodes) + result(success, + nodes.description + okMessage, + nodes.description + koMessage, nodes) } - def \(node: Node, attributeNames: String*): XmlMatcher = + def \(node: Node, attributeNames: String*): XmlMatcher = new XmlMatcher(functions :+ new PathFunction(node, firstNodeSearch _, attributeNames.toList)) - def \(node: Node, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher = + def \(node: Node, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher = new XmlMatcher(functions :+ new PathFunction(node, firstNodeSearch _, Nil, Map((attributeValues :: attributeValues2.toList):_*))) - def \\(node: Node, attributeNames: String*): XmlMatcher = + def \\(node: Node, attributeNames: String*): XmlMatcher = new XmlMatcher(functions :+ new PathFunction(node, deepNodeSearch _, attributeNames.toList)) - def \\(node: Node, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher = + def \\(node: Node, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher = new XmlMatcher(functions :+ new PathFunction(node, deepNodeSearch _, Nil, Map((attributeValues :: attributeValues2.toList):_*))) /** alias for \ using the node label only */ def \(label: String, attributeNames: String*): XmlMatcher = \(label.toElem, attributeNames:_*) - def \(label: String, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher = + def \(label: String, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher = \(label.toElem, attributeValues, attributeValues2:_*) /** alias for \\ using the node label only */ def \\(label: String, attributeNames: String*): XmlMatcher = \\(label.toElem, attributeNames:_*) - def \\(label: String, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher = + def \\(label: String, attributeValues: (String, String), attributeValues2: (String, String)*): XmlMatcher = \\(label.toElem, attributeValues, attributeValues2:_*) /** @@ -205,21 +205,21 @@ case class XmlMatcher(functions: Seq[PathFunction]) extends Matcher[Seq[Node]] { // check the rest of the functions, with the nodes returned by the current function // and build a MatcherResult being a success if the function retrieves some node pathFunctions match { - case search :: functions => { + case search :: fs => { val nextNodes = search(nodes) val searched = search.searchedElements val (ok, ko) = (messages._2, messages._3) - val (newOk, newKo) = - (ok + " contains " + searched, + val (newOk, newKo) = + (ok + " contains " + searched, ok + " doesn't contain " + searched) - + if (nextNodes.isEmpty) (false, newOk, newKo) - else checkFunctions(functions, nextNodes, (true, newOk, newKo)) + else checkFunctions(fs, nextNodes, (true, newOk, newKo)) } case _ => messages } } -} +} /** * This object provides XPath functions in order to use them as parameters @@ -231,12 +231,12 @@ trait XPathFunctions { /** * @return the \ XPath function */ - def firstNodeSearch(node: Node, label: String) = node \ label + def firstNodeSearch(node: Node, label: String) = node \ label /** * @return the \\ XPath function */ - def deepNodeSearch(node: Node, label: String) = node \\ label + def deepNodeSearch(node: Node, label: String) = node \\ label } /** @@ -254,10 +254,10 @@ case class PathFunction(val node: Node, /** * @return the node if it is found and matching the searched attributes and/or attribute values when specified */ - def apply(nodes: Seq[Node]): Seq[Node] = + def apply(nodes: Seq[Node]): Seq[Node] = for { n <- nodes found <- function(n, node.label) if (found.matchNode(node, attributes, attributeValues, exactMatch, textMatcher.test)) } - yield found + yield found def exactly = copy(exactMatch = true) /** add a matcher for the node text */ @@ -273,7 +273,7 @@ case class PathFunction(val node: Node, * @return a string representation of attributes or attributeValues (one of them being empty by construction) */ def searchedAttributes = attributes.mkString(", ") + attributeValues.map(a=> a._1 + "=\"" + a._2 + "\"").mkString(" ") - + /** * @return a string representing the searched nodes, attributes, attribute values */ diff --git a/matcher/shared/src/main/scala/org/specs2/matcher/MatchResultMessages.scala b/matcher/shared/src/main/scala/org/specs2/matcher/MatchResultMessages.scala index 2e1b9e20d0..11b9209368 100644 --- a/matcher/shared/src/main/scala/org/specs2/matcher/MatchResultMessages.scala +++ b/matcher/shared/src/main/scala/org/specs2/matcher/MatchResultMessages.scala @@ -29,8 +29,8 @@ trait MatchResultMessages { def append(m2: MatchResultMessage) = { m2 match { - case s: MatchSuccess[_] => SuccessMessage.create(okMessage+"; "+s.okMessage, koMessage+"; "+s.koMessage) - case f: MatchFailure[_] => FailureMessage.create(okMessage+"; "+f.okMessage, koMessage+"; "+f.koMessage) + case s: SuccessMessage => SuccessMessage.create(okMessage+"; "+s.ok(), koMessage+"; "+s.ko()) + case f: FailureMessage => FailureMessage.create(okMessage+"; "+f.ok(), koMessage+"; "+f.ko()) case NeutralMessage(m) => SuccessMessage.create(okMessage+"; "+m, koMessage+"; "+m) case _ => this } @@ -45,8 +45,8 @@ trait MatchResultMessages { def append(m2: MatchResultMessage) = { m2 match { - case s: MatchSuccess[_] => FailureMessage.create(okMessage+"; "+s.okMessage, koMessage+"; "+s.koMessage) - case f: MatchFailure[_] => FailureMessage.create(okMessage+"; "+f.okMessage, koMessage+"; "+f.koMessage) + case s: SuccessMessage => FailureMessage.create(okMessage+"; "+s.ok(), koMessage+"; "+s.ko()) + case f: FailureMessage => FailureMessage.create(okMessage+"; "+f.ok(), koMessage+"; "+f.ko()) case NeutralMessage(m) => FailureMessage.create(okMessage+"; "+m, koMessage+"; "+m) case _ => this } @@ -59,8 +59,8 @@ trait MatchResultMessages { case class NeutralMessage(message: String) extends MatchResultMessage { def append(m2: MatchResultMessage) = { m2 match { - case s: MatchSuccess[_] => SuccessMessage.create(message+"; "+s.okMessage, message+"; "+s.koMessage) - case f: MatchFailure[_] => FailureMessage.create(message+"; "+f.okMessage, message+"; "+f.koMessage) + case s: SuccessMessage => SuccessMessage.create(message+"; "+s.ok(), message+"; "+s.ko()) + case f: FailureMessage => FailureMessage.create(message+"; "+f.ok(), message+"; "+f.ko()) case NeutralMessage(m) => NeutralMessage(message+"; "+m) case _ => this } diff --git a/mock/jvm/src/test/scala/org/specs2/mock/HamcrestMatcherAdapterSpec.scala b/mock/jvm/src/test/scala/org/specs2/mock/HamcrestMatcherAdapterSpec.scala index e3f9ca6c79..2184066373 100644 --- a/mock/jvm/src/test/scala/org/specs2/mock/HamcrestMatcherAdapterSpec.scala +++ b/mock/jvm/src/test/scala/org/specs2/mock/HamcrestMatcherAdapterSpec.scala @@ -5,10 +5,10 @@ class HamcrestMatcherAdapterSpec extends mutable.Spec { "A specs2 matcher can be adapted to be used like a Hamcrest matcher" >> { "when the match is ok" >> { - HamcrestMatcherAdapter(beEqualTo(1)).matchesSafely(1) must beTrue + HamcrestMatcherAdapter[Int](beEqualTo(1)).matchesSafely(1) must beTrue } "when the match is ko" >> { - HamcrestMatcherAdapter(beEqualTo(1)).matchesSafely(2) must beFalse + HamcrestMatcherAdapter[Int](beEqualTo(1)).matchesSafely(2) must beFalse } } "A specs2 matcher adapted as will add to a Description" >> { @@ -21,7 +21,7 @@ class HamcrestMatcherAdapterSpec extends mutable.Spec { } - + def matchMessage(value1: Int, value2: Int) = { val m = HamcrestMatcherAdapter[Int](beEqualTo(value2)) m.matchesSafely(value1) @@ -29,5 +29,5 @@ class HamcrestMatcherAdapterSpec extends mutable.Spec { val description = new org.hamcrest.StringDescription m.describeTo(description) description.toString - } + } } diff --git a/mock/jvm/src/test/scala/org/specs2/mock/MockitoSpec.scala b/mock/jvm/src/test/scala/org/specs2/mock/MockitoSpec.scala index ec800897d6..191e00aa01 100644 --- a/mock/jvm/src/test/scala/org/specs2/mock/MockitoSpec.scala +++ b/mock/jvm/src/test/scala/org/specs2/mock/MockitoSpec.scala @@ -328,7 +328,7 @@ ${step(env)} vet.treat(Cat()) def isDog: Matcher[Dog] = (d: Dog) => (true, "ok", "ko") - (there was one(vet).treat(isDog)) must not(throwA[ClassCastException]) + (there was one(vet).treat(isDog)) must throwA[ClassCastException].not } eg := { list.contains(Set(1)) returns true @@ -537,9 +537,9 @@ ${step(env)} eg := { val s = new org.specs2.mutable.Specification with Mockito { "ex1" in new specification.Scope { - val (list1, list2) = (mock[ListOf[String]], mock[ListOf[String]]) + val (list1: ListOf[String], list2: ListOf[String]) = (mock[ListOf[String]], mock[ListOf[String]]) list1.add("two"); list2.add("one") - implicit val order = inOrder(list1, list2) + implicit val order: Option[org.mockito.InOrder] = inOrder(list1, list2) there was one(list2).add("two") andThen one(list1).add("one") } } diff --git a/project/depends.scala b/project/depends.scala index a99a3b927b..1915f8c3df 100644 --- a/project/depends.scala +++ b/project/depends.scala @@ -29,10 +29,10 @@ object depends { Seq(libraryDependencies ++= Seq( "org.scala-js" %% "scalajs-test-interface" % scalaJSVersion, "org.portable-scala" %%% "portable-scala-reflect" % "1.1.1"), - Test / scalaJSStage := FastOptStage) + Test / scalaJSStage := FastOptStage) ++ jsMacrotaskExecutor def jsMacrotaskExecutor = - Seq(libraryDependencies += "org.scala-js" %%% "scala-js-macrotask-executor" % "1.0.0") + Seq(libraryDependencies += "org.scala-js" %%% "scala-js-macrotask-executor" % "1.1.1") def nativeTest = Seq(libraryDependencies ++= Seq( diff --git a/tests/src/test/scala/org/specs2/matcher/TryMatchersSpec.scala b/tests/src/test/scala/org/specs2/matcher/TryMatchersSpec.scala index 07af6c4a63..e0b477a8be 100644 --- a/tests/src/test/scala/org/specs2/matcher/TryMatchersSpec.scala +++ b/tests/src/test/scala/org/specs2/matcher/TryMatchersSpec.scala @@ -36,7 +36,7 @@ class TryMatchersSpec extends Spec with TryMatchers with ResultMatchers { def is ${ (Failed[I](e) must beFailedTry.withThrowable[OtherException]) returns s"Failure(boom) is a Failure but '$e: ${classOf[MyException].getName}' is not an instance of '${classOf[OtherException].getName}'" } ${ Failed[I](e) must beAFailedTry.withThrowable[MyException](".*oo.*") } - ${ Failed[I](e) must beFailedTry.like { case e: MyException => e.getMessage must startWith("b") }} + ${ Failed[I](e) must beFailedTry.like { case ex: MyException => ex.getMessage must startWith("b") }} ${ Failed[I](e) must not be aFailedTry.withThrowable[MyException]("bang") } ${ (Failed[I](e) must beAFailedTry.withThrowable[MyException]("bang")) returns "Failure(boom) is a Failure but 'boom' doesn't match 'bang'" } ${ Failed[I](e) must not be aFailedTry.withThrowable[OtherException] } @@ -48,7 +48,7 @@ class TryMatchersSpec extends Spec with TryMatchers with ResultMatchers { def is class MyException(m: String) extends Exception(m) { override def toString = m override def equals(o: Any) = o match { - case e: MyException => e.getMessage == getMessage + case ex: MyException => ex.getMessage == getMessage case _ => false } } diff --git a/xml/shared/src/test/scala/org/specs2/xml/NodexSpec.scala b/xml/shared/src/test/scala/org/specs2/xml/NodexSpec.scala index b69fd33fd3..bf7c86baec 100644 --- a/xml/shared/src/test/scala/org/specs2/xml/NodexSpec.scala +++ b/xml/shared/src/test/scala/org/specs2/xml/NodexSpec.scala @@ -16,7 +16,7 @@ class NodexSpec extends Spec { def is = s2""" .child.last.isSpaceNode } - ${ Group().isSpaceNode must not(throwAn[UnsupportedOperationException]) } + ${ Group().isSpaceNode must throwAn[UnsupportedOperationException].not } isEqualIgnoringSpace returns true if 2 NodeSeq are without spaces nodes are equal ${ ==/ }