From 3af7b0d59054e2d0a5d95251297a0b5c92ff36ab Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 6 Jun 2025 00:29:44 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.9.7 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 22bab12b..b2c0df22 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -7,5 +7,5 @@ rewrite.rules = [RedundantBraces, RedundantParens, SortImports] spaces.inImportCurlyBraces = true indentOperator.preset = spray -version=3.9.6 +version=3.9.7 From 6140c78f063f429304c3195435068432de309492 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 6 Jun 2025 00:30:19 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.9.7 Executed command: scalafmt --non-interactive --- build.sbt | 4 +-- .../scala/org/mockito/ReflectionUtils.scala | 6 ++--- .../internal/handler/ScalaMockHandler.scala | 14 +++++----- .../internal/invocation/ScalaInvocation.scala | 4 +-- .../mockito/stubbing/ScalaBaseStubbing.scala | 2 +- .../mockito/stubbing/ScalaFirstStubbing.scala | 2 +- .../stubbing/ScalaOngoingStubbing.scala | 2 +- .../org/mockito/IdiomaticMockitoBase.scala | 8 +++--- .../internal/ValueClassExtractor.scala | 2 +- .../scala/org/mockito/DoSomethingMacro.scala | 4 +-- .../scala/org/mockito/Specs2VerifyMacro.scala | 2 +- .../main/scala/org/mockito/VerifyMacro.scala | 8 +++--- .../main/scala/org/mockito/WhenMacro.scala | 26 +++++++++---------- project/Dependencies.scala | 4 +-- .../scala/user/org/mockito/Issue251.scala | 2 +- .../mockito/specs2/MockitoSpecs2Support.scala | 14 +++++----- .../specs2/MockitoScalaNewSyntaxSpec.scala | 2 +- .../org/mockito/specs2/MockitoScalaSpec.scala | 2 +- 18 files changed, 54 insertions(+), 54 deletions(-) diff --git a/build.sbt b/build.sbt index 95a026c0..36af3561 100644 --- a/build.sbt +++ b/build.sbt @@ -64,7 +64,7 @@ lazy val commonSettings = lazy val publishSettings = Seq( licenses := Seq("MIT" -> url("https://opensource.org/licenses/MIT")), homepage := Some(url("https://github.com/mockito/mockito-scala")), - scmInfo := Some( + scmInfo := Some( ScmInfo( url("https://github.com/mockito/mockito-scala"), "git@github.com:mockito/mockito-scala.git" @@ -123,7 +123,7 @@ lazy val cats = (project in file("cats")) publishSettings, libraryDependencies ++= Seq( Dependencies.cats, - Dependencies.catsLaws % "test", + Dependencies.catsLaws % "test", Dependencies.disciplineScalatest % "test", Dependencies.scalatest % "test" ) diff --git a/common/src/main/scala/org/mockito/ReflectionUtils.scala b/common/src/main/scala/org/mockito/ReflectionUtils.scala index 935f29a8..119c083c 100644 --- a/common/src/main/scala/org/mockito/ReflectionUtils.scala +++ b/common/src/main/scala/org/mockito/ReflectionUtils.scala @@ -24,7 +24,7 @@ object ReflectionUtils { implicit def symbolToMethodSymbol(sym: Symbol): Symbols#MethodSymbol = sym.asInstanceOf[Symbols#MethodSymbol] - private val mirror = runtimeMirror(getClass.getClassLoader) + private val mirror = runtimeMirror(getClass.getClassLoader) private val customMirror = mirror.asInstanceOf[{ def methodToJava(sym: Symbols#MethodSymbol): Method }] @@ -130,7 +130,7 @@ object ReflectionUtils { field.setAccessible(true) val modifiersField: Field = uTry(clazz.getDeclaredField("modifiers")) match { case Success(modifiers) => modifiers - case Failure(e) => + case Failure(e) => uTry { val getDeclaredFields0 = clazz.getDeclaredMethod("getDeclaredFields0", classOf[Boolean]) val accessibleBeforeSet: Boolean = getDeclaredFields0.isAccessible @@ -142,7 +142,7 @@ object ReflectionUtils { declaredFields.find("modifiers" == _.getName).get } match { case Success(modifiers) => modifiers - case Failure(ex) => + case Failure(ex) => e.addSuppressed(ex) throw e } diff --git a/common/src/main/scala/org/mockito/internal/handler/ScalaMockHandler.scala b/common/src/main/scala/org/mockito/internal/handler/ScalaMockHandler.scala index a50bef8f..4dcd9747 100644 --- a/common/src/main/scala/org/mockito/internal/handler/ScalaMockHandler.scala +++ b/common/src/main/scala/org/mockito/internal/handler/ScalaMockHandler.scala @@ -27,7 +27,7 @@ class ScalaMockHandler[T](mockSettings: MockCreationSettings[T], methodsToProces i.callRealMethod() else { val rawArguments = i.getRawArguments - val arguments = + val arguments = if (rawArguments != null && rawArguments.nonEmpty && !isCallRealMethod) unwrapArgs(method, rawArguments) else rawArguments @@ -42,10 +42,10 @@ class ScalaMockHandler[T](mockSettings: MockCreationSettings[T], methodsToProces val transformed = methodsToProcess .collectFirst { case (mtd, indices) if method === mtd => - val argumentMatcherStorage = mockingProgress().getArgumentMatcherStorage - val matchers = argumentMatcherStorage.pullLocalizedMatchers().asScala.toIterator - val matchersWereUsed = matchers.nonEmpty - def reportMatcher(): Unit = if (matchers.nonEmpty) argumentMatcherStorage.reportMatcher(matchers.next().getMatcher) + val argumentMatcherStorage = mockingProgress().getArgumentMatcherStorage + val matchers = argumentMatcherStorage.pullLocalizedMatchers().asScala.toIterator + val matchersWereUsed = matchers.nonEmpty + def reportMatcher(): Unit = if (matchers.nonEmpty) argumentMatcherStorage.reportMatcher(matchers.next().getMatcher) def reportMatchers(varargs: Iterable[_]): Unit = if (matchersWereUsed && varargs.nonEmpty) { def reportAsEqTo(): Unit = varargs.map(EqTo(_)).foreach(argumentMatcherStorage.reportMatcher(_)) @@ -53,7 +53,7 @@ class ScalaMockHandler[T](mockSettings: MockCreationSettings[T], methodsToProces matcher match { case EqTo(value: Array[_]) if varargs.sameElements(value) => reportAsEqTo() case EqTo(value) if varargs == value => reportAsEqTo() - case other => + case other => argumentMatcherStorage.reportMatcher(other) varargs.drop(1).foreach(_ => reportMatcher()) } @@ -100,7 +100,7 @@ object ScalaMockHandler { mockSettings ) - private val InvocationClassName = classOf[ScalaInvocation].getName + private val InvocationClassName = classOf[ScalaInvocation].getName private def isCallRealMethod: Boolean = (new Exception).getStackTrace.toList.exists { t => t.getClassName == InvocationClassName && diff --git a/common/src/main/scala/org/mockito/internal/invocation/ScalaInvocation.scala b/common/src/main/scala/org/mockito/internal/invocation/ScalaInvocation.scala index 1e8701af..84f59268 100644 --- a/common/src/main/scala/org/mockito/internal/invocation/ScalaInvocation.scala +++ b/common/src/main/scala/org/mockito/internal/invocation/ScalaInvocation.scala @@ -45,7 +45,7 @@ class ScalaInvocation( override def isVerified: Boolean = verified || isIgnoredForVerification override def getMock: AnyRef = mockRef.get override def getMethod: Method = mockitoMethod.getJavaMethod - override def callRealMethod(): AnyRef = + override def callRealMethod(): AnyRef = if (realMethod.isInvokable) realMethod.invoke else throw cannotCallAbstractRealMethod @@ -62,7 +62,7 @@ class ScalaInvocation( val state = Seq(super.hashCode(), getMock, mockitoMethod, arguments.toSeq) state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b) } - override def toString: String = new PrintSettings().print(getArgumentsAsMatchers, this) + override def toString: String = new PrintSettings().print(getArgumentsAsMatchers, this) override def getArgumentsAsMatchers: util.List[ArgumentMatcher[_]] = arguments.map(EqTo(_)(serialisableEquality[AnyRef], ValueClassExtractor.instance[AnyRef], $pt): ArgumentMatcher[_]).toList.asJava } diff --git a/common/src/main/scala/org/mockito/stubbing/ScalaBaseStubbing.scala b/common/src/main/scala/org/mockito/stubbing/ScalaBaseStubbing.scala index febe9a30..3dbec728 100644 --- a/common/src/main/scala/org/mockito/stubbing/ScalaBaseStubbing.scala +++ b/common/src/main/scala/org/mockito/stubbing/ScalaBaseStubbing.scala @@ -29,7 +29,7 @@ abstract class ScalaBaseStubbing[T: ValueClassExtractor] { protected def _thenCallRealMethod(): ScalaOngoingStubbing[T] = delegate.thenCallRealMethod() - protected def _thenAnswer(f: => T): ScalaOngoingStubbing[T] = delegate thenAnswer invocationToAnswer(_ => f) + protected def _thenAnswer(f: => T): ScalaOngoingStubbing[T] = delegate thenAnswer invocationToAnswer(_ => f) protected def _thenAnswer[P0: ClassTag: ValueClassWrapper](f: P0 => T): ScalaOngoingStubbing[T] = clazz[P0] match { case c if c == classOf[InvocationOnMock] => delegate thenAnswer invocationToAnswer(i => f(i.asInstanceOf[P0])) diff --git a/common/src/main/scala/org/mockito/stubbing/ScalaFirstStubbing.scala b/common/src/main/scala/org/mockito/stubbing/ScalaFirstStubbing.scala index ef65d8bd..df37086f 100644 --- a/common/src/main/scala/org/mockito/stubbing/ScalaFirstStubbing.scala +++ b/common/src/main/scala/org/mockito/stubbing/ScalaFirstStubbing.scala @@ -98,7 +98,7 @@ case class ScalaFirstStubbing[T: ValueClassExtractor](delegate: OngoingStubbing[ } } - def thenAnswer(f: => T): ScalaOngoingStubbing[T] = _thenAnswer(f) + def thenAnswer(f: => T): ScalaOngoingStubbing[T] = _thenAnswer(f) def thenAnswer[P0: ValueClassWrapper](f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0]): ScalaOngoingStubbing[T] = _thenAnswer(f) def thenAnswer[P0: ValueClassWrapper, P1: ValueClassWrapper](f: (P0, P1) => T): ScalaOngoingStubbing[T] = diff --git a/common/src/main/scala/org/mockito/stubbing/ScalaOngoingStubbing.scala b/common/src/main/scala/org/mockito/stubbing/ScalaOngoingStubbing.scala index 828ef9c5..31785bf9 100644 --- a/common/src/main/scala/org/mockito/stubbing/ScalaOngoingStubbing.scala +++ b/common/src/main/scala/org/mockito/stubbing/ScalaOngoingStubbing.scala @@ -78,7 +78,7 @@ case class ScalaOngoingStubbing[T: ValueClassExtractor](delegate: OngoingStubbin */ def andThenCallRealMethod(): ScalaOngoingStubbing[T] = _thenCallRealMethod() - def andThenAnswer(f: => T): ScalaOngoingStubbing[T] = _thenAnswer(f) + def andThenAnswer(f: => T): ScalaOngoingStubbing[T] = _thenAnswer(f) def andThenAnswer[P0: ValueClassWrapper](f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0]): ScalaOngoingStubbing[T] = _thenAnswer(f) def andThenAnswer[P0: ValueClassWrapper, P1: ValueClassWrapper](f: (P0, P1) => T): ScalaOngoingStubbing[T] = diff --git a/core/src/main/scala/org/mockito/IdiomaticMockitoBase.scala b/core/src/main/scala/org/mockito/IdiomaticMockitoBase.scala index 68bcdb16..267e09b9 100644 --- a/core/src/main/scala/org/mockito/IdiomaticMockitoBase.scala +++ b/core/src/main/scala/org/mockito/IdiomaticMockitoBase.scala @@ -32,7 +32,7 @@ object IdiomaticMockitoBase { case class Times(times: Int) extends ScalaVerificationMode { override def verificationMode: VerificationMode = Mockito.times(times) - def within(d: Duration): ScalaVerificationMode = + def within(d: Duration): ScalaVerificationMode = new ScalaVerificationMode { override def verificationMode: VerificationMode = Mockito.timeout(d.toMillis).times(times) } @@ -53,7 +53,7 @@ object IdiomaticMockitoBase { case class AtLeast(times: Int) extends ScalaVerificationMode { override def verificationMode: VerificationMode = Mockito.atLeast(times) - def within(d: Duration): ScalaVerificationMode = + def within(d: Duration): ScalaVerificationMode = new ScalaVerificationMode { override def verificationMode: VerificationMode = Mockito.timeout(d.toMillis).atLeast(times) } @@ -65,7 +65,7 @@ object IdiomaticMockitoBase { case class AtMost(times: Int) extends ScalaVerificationMode { override def verificationMode: VerificationMode = Mockito.atMost(times) - def after(d: Duration): ScalaVerificationMode = + def after(d: Duration): ScalaVerificationMode = new ScalaVerificationMode { override def verificationMode: VerificationMode = Mockito.after(d.toMillis).atMost(times) } @@ -73,7 +73,7 @@ object IdiomaticMockitoBase { object OnlyOn extends ScalaVerificationMode { override def verificationMode: VerificationMode = Mockito.only - def within(d: Duration): ScalaVerificationMode = + def within(d: Duration): ScalaVerificationMode = new ScalaVerificationMode { override def verificationMode: VerificationMode = Mockito.timeout(d.toMillis).only } diff --git a/macro-common/src/main/scala/org/mockito/internal/ValueClassExtractor.scala b/macro-common/src/main/scala/org/mockito/internal/ValueClassExtractor.scala index 42046f78..77799e22 100644 --- a/macro-common/src/main/scala/org/mockito/internal/ValueClassExtractor.scala +++ b/macro-common/src/main/scala/org/mockito/internal/ValueClassExtractor.scala @@ -19,7 +19,7 @@ class NormalClassExtractor[T] extends ValueClassExtractor[T] { class ReflectionExtractor[VC] extends ValueClassExtractor[VC] { override def extract(vc: VC): Any = { val constructorParam = vc.getClass.getConstructors.head.getParameters.head - val accessor = vc.getClass.getMethods + val accessor = vc.getClass.getMethods .filter(m => m.getName == constructorParam.getName || m.getName.endsWith("$$" + constructorParam.getName)) .head accessor.setAccessible(true) diff --git a/macro/src/main/scala/org/mockito/DoSomethingMacro.scala b/macro/src/main/scala/org/mockito/DoSomethingMacro.scala index 1bfecf39..4a26065a 100644 --- a/macro/src/main/scala/org/mockito/DoSomethingMacro.scala +++ b/macro/src/main/scala/org/mockito/DoSomethingMacro.scala @@ -187,7 +187,7 @@ object DoSomethingMacro { if (pf.isDefinedAt(invocation)) pf(invocation) else if (pf.isDefinedAt(invocation.children.last)) { - val vals = invocation.children.dropRight(1) + val vals = invocation.children.dropRight(1) val valsByName = vals.collect { case line @ q"$_ val $name:$_ = $value" => name.toString -> (value.asInstanceOf[c.Tree], line) }.toMap @@ -203,7 +203,7 @@ object DoSomethingMacro { q"$action.when($obj).$method[..$targs](...$newArgs)" } - val call = show(inlinedArgsCall) + val call = show(inlinedArgsCall) val usedVals = valsByName.collect { case (name, (_, line)) if call.contains(name) => line } diff --git a/macro/src/main/scala/org/mockito/Specs2VerifyMacro.scala b/macro/src/main/scala/org/mockito/Specs2VerifyMacro.scala index 8c7df761..68d212b7 100644 --- a/macro/src/main/scala/org/mockito/Specs2VerifyMacro.scala +++ b/macro/src/main/scala/org/mockito/Specs2VerifyMacro.scala @@ -57,7 +57,7 @@ object Specs2VerifyMacro extends VerificationMacroTransformer { case q"$_.got[$_]({..$block})($order)" => block.foldLeft(q"") { - case (q"", t) => if (transformSpecs2Verification.isDefinedAt(t)) transformSpecs2Verification(t) else q"$t" + case (q"", t) => if (transformSpecs2Verification.isDefinedAt(t)) transformSpecs2Verification(t) else q"$t" case (other, t) => if (transformSpecs2Verification.isDefinedAt(t)) q"$other and ${transformSpecs2Verification(t)}" else q"$other and $t" } diff --git a/macro/src/main/scala/org/mockito/VerifyMacro.scala b/macro/src/main/scala/org/mockito/VerifyMacro.scala index 4d4e508a..3bc48486 100644 --- a/macro/src/main/scala/org/mockito/VerifyMacro.scala +++ b/macro/src/main/scala/org/mockito/VerifyMacro.scala @@ -62,7 +62,7 @@ private[mockito] trait VerificationMacroTransformer { if (pf.isDefinedAt(invocation)) pf(invocation) else if (invocation.children.nonEmpty && pf.isDefinedAt(invocation.children.last)) { - val vals = invocation.children.dropRight(1) + val vals = invocation.children.dropRight(1) val valsByName = vals.collect { case line @ q"$_ val $name:$_ = $value" => name.toString -> (value.asInstanceOf[c.Tree], line) }.toMap @@ -78,7 +78,7 @@ private[mockito] trait VerificationMacroTransformer { q"verification($order.verifyWithMode($obj, $times).$method[..$targs](...$newArgs))" } - val call = show(inlinedArgsCall) + val call = show(inlinedArgsCall) val usedVals = valsByName.collect { case (name, (_, line)) if call.contains(name) => line } @@ -92,8 +92,8 @@ private[mockito] trait VerificationMacroTransformer { def transformMockWasNeverCalled(obj: c.Tree, called: c.Tree): c.Tree = called match { - case q"$_.called" => q"verification(_root_.org.mockito.MockitoSugar.verifyZeroInteractions($obj))" - case q"$_.calledAgain" => q"verification(_root_.org.mockito.MockitoSugar.verifyNoMoreInteractions($obj))" + case q"$_.called" => q"verification(_root_.org.mockito.MockitoSugar.verifyZeroInteractions($obj))" + case q"$_.calledAgain" => q"verification(_root_.org.mockito.MockitoSugar.verifyNoMoreInteractions($obj))" case q"$_.calledAgain.apply($_.ignoringStubs)" => q"verification(_root_.org.mockito.MockitoSugar.verifyNoMoreInteractions(_root_.org.mockito.MockitoSugar.ignoreStubs($obj): _*))" } diff --git a/macro/src/main/scala/org/mockito/WhenMacro.scala b/macro/src/main/scala/org/mockito/WhenMacro.scala index 7ea5d98c..0c62268e 100644 --- a/macro/src/main/scala/org/mockito/WhenMacro.scala +++ b/macro/src/main/scala/org/mockito/WhenMacro.scala @@ -22,7 +22,7 @@ object WhenMacro { if (pf.isDefinedAt(invocation)) pf(invocation) else if (pf.isDefinedAt(invocation.children.last)) { - val vals = invocation.children.dropRight(1) + val vals = invocation.children.dropRight(1) val valsByName = vals.collect { case line @ q"$_ val $name:$_ = $value" => name.toString -> (value.asInstanceOf[c.Tree], line) }.toMap @@ -38,7 +38,7 @@ object WhenMacro { q"$obj.$method[..$targs](...$newArgs)" } - val call = show(inlinedArgsCall) + val call = show(inlinedArgsCall) val usedVals = valsByName.collect { case (name, (_, line)) if call.contains(name) => line } @@ -47,9 +47,9 @@ object WhenMacro { } else throw new Exception(s"Couldn't recognize invocation ${show(invocation)}") } - private val ShouldReturnOptions = Set("shouldReturn", "mustReturn", "returns") - private val FunctionalShouldReturnOptions = ShouldReturnOptions.map(_ + "F") - private val FunctionalShouldReturnOptions2 = ShouldReturnOptions.map(_ + "FG") + private val ShouldReturnOptions = Set("shouldReturn", "mustReturn", "returns") + private val FunctionalShouldReturnOptions = ShouldReturnOptions.map(_ + "F") + private val FunctionalShouldReturnOptions2 = ShouldReturnOptions.map(_ + "FG") def shouldReturn[T: c.WeakTypeTag](c: blackbox.Context): c.Tree = { import c.universe._ @@ -88,7 +88,7 @@ object WhenMacro { def willBe(called: Called.type): Called.type = called } - val ShouldCallOptions = Set("shouldCall", "mustCall", "calls") + val ShouldCallOptions = Set("shouldCall", "mustCall", "calls") def shouldCallRealMethod[T: c.WeakTypeTag](c: blackbox.Context)(crm: c.Expr[RealMethod.type]): c.Expr[ScalaOngoingStubbing[T]] = { import c.universe._ @@ -104,9 +104,9 @@ object WhenMacro { r } - private val ShouldThrowOptions = Set("shouldThrow", "mustThrow", "throws") - private val FunctionalShouldFailOptions = Set("shouldFailWith", "mustFailWith", "failsWith", "raises") - private val FunctionalShouldFailOptions2 = Set("shouldFailWithG", "mustFailWithG", "failsWithG", "raisesG") + private val ShouldThrowOptions = Set("shouldThrow", "mustThrow", "throws") + private val FunctionalShouldFailOptions = Set("shouldFailWith", "mustFailWith", "failsWith", "raises") + private val FunctionalShouldFailOptions2 = Set("shouldFailWithG", "mustFailWithG", "failsWithG", "raisesG") def shouldThrow[T: c.WeakTypeTag](c: blackbox.Context): c.Tree = { import c.universe._ @@ -450,9 +450,9 @@ object WhenMacro { // } } - private val ShouldAnswerOptions = Set("shouldAnswer", "mustAnswer", "answers") - private val FunctionalShouldAnswerOptions = ShouldAnswerOptions.map(_ + "F") - private val FunctionalShouldAnswerOptions2 = ShouldAnswerOptions.map(_ + "FG") + private val ShouldAnswerOptions = Set("shouldAnswer", "mustAnswer", "answers") + private val FunctionalShouldAnswerOptions = ShouldAnswerOptions.map(_ + "F") + private val FunctionalShouldAnswerOptions2 = ShouldAnswerOptions.map(_ + "FG") def shouldAnswer[T: c.WeakTypeTag](c: blackbox.Context): c.Tree = { import c.universe._ @@ -476,7 +476,7 @@ object WhenMacro { def apply(pf: PartialFunction[Any, T]): ScalaOngoingStubbing[T] = os thenAnswer pf } - private val ShouldAnswerPFOptions = Set("shouldAnswerPF", "mustAnswerPF", "answersPF") + private val ShouldAnswerPFOptions = Set("shouldAnswerPF", "mustAnswerPF", "answersPF") def shouldAnswerPF[T: c.WeakTypeTag](c: blackbox.Context): c.Tree = { import c.universe._ diff --git a/project/Dependencies.scala b/project/Dependencies.scala index c08bf81e..5d9348f4 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -28,8 +28,8 @@ object Dependencies { } ) - val cats = "org.typelevel" %% "cats-core" % "2.13.0" % "provided" - val scalaz = "org.scalaz" %% "scalaz-core" % "7.3.8" % "provided" + val cats = "org.typelevel" %% "cats-core" % "2.13.0" % "provided" + val scalaz = "org.scalaz" %% "scalaz-core" % "7.3.8" % "provided" val catsLaws = "org.typelevel" %% "cats-laws" % "2.13.0" diff --git a/scalatest/src/test/scala/user/org/mockito/Issue251.scala b/scalatest/src/test/scala/user/org/mockito/Issue251.scala index b4bde1de..0ee58f39 100644 --- a/scalatest/src/test/scala/user/org/mockito/Issue251.scala +++ b/scalatest/src/test/scala/user/org/mockito/Issue251.scala @@ -12,7 +12,7 @@ class Issue251 extends AnyFlatSpec with IdiomaticMockito with Matchers with Argu cars += (0 -> Car(0)) def getCar(id: Int): Option[Car] = cars.get(id) - def saveCar(car: Car) = { + def saveCar(car: Car) = { cars += car.id -> car; car } diff --git a/specs2/src/main/scala/org/mockito/specs2/MockitoSpecs2Support.scala b/specs2/src/main/scala/org/mockito/specs2/MockitoSpecs2Support.scala index 64615ede..20615571 100644 --- a/specs2/src/main/scala/org/mockito/specs2/MockitoSpecs2Support.scala +++ b/specs2/src/main/scala/org/mockito/specs2/MockitoSpecs2Support.scala @@ -21,8 +21,8 @@ trait FunctionArgumentsLowImplicits extends ArgThat with Expectations { argThat(partialMatcher) } - def partialFunctionCall[A, R](a: A, r: R): PartialFunction[A, R] = partialCallMatching(a, new BeEqualTo(r)) - implicit def toPartialFunctionCall[A, R](values: (A, R)): PartialFunction[A, R] = partialFunctionCall(values._1, values._2) + def partialFunctionCall[A, R](a: A, r: R): PartialFunction[A, R] = partialCallMatching(a, new BeEqualTo(r)) + implicit def toPartialFunctionCall[A, R](values: (A, R)): PartialFunction[A, R] = partialFunctionCall(values._1, values._2) implicit def matcherToPartialFunctionCall[A, R](values: (A, Matcher[R])): PartialFunction[A, R] = partialCallMatching(values._1, values._2) } @@ -30,12 +30,12 @@ trait FunctionArgumentsLowImplicits extends ArgThat with Expectations { trait FunctionArguments extends FunctionArgumentsLowImplicits { def callMatching[A, R](a: A, m: Matcher[R]): A => R = argThat(m ^^ { (f: A => R) => f(a) }) - def functionCall[A, R](a: A, r: R): A => R = callMatching(a, new BeEqualTo(r)) - implicit def toFunctionCall[A, R](values: (A, R)): A => R = functionCall(values._1, values._2) - implicit def matcherToFunctionCall[A, R](values: (A, Matcher[R])): A => R = callMatching(values._1, values._2) + def functionCall[A, R](a: A, r: R): A => R = callMatching(a, new BeEqualTo(r)) + implicit def toFunctionCall[A, R](values: (A, R)): A => R = functionCall(values._1, values._2) + implicit def matcherToFunctionCall[A, R](values: (A, Matcher[R])): A => R = callMatching(values._1, values._2) def callMatching2[T1, T2, R](t1: T1, t2: T2, m: Matcher[R]): Function2[T1, T2, R] = argThat(m ^^ { (f: Function2[T1, T2, R]) => f(t1, t2) }) - def functionCall2[T1, T2, R](t1: T1, t2: T2, r: R): Function2[T1, T2, R] = callMatching2(t1, t2, new BeEqualTo(r)) + def functionCall2[T1, T2, R](t1: T1, t2: T2, r: R): Function2[T1, T2, R] = callMatching2(t1, t2, new BeEqualTo(r)) implicit def toFunctionCall2[T1, T2, R](values: ((T1, T2), R)): Function2[T1, T2, R] = functionCall2(values._1._1, values._1._2, values._2) implicit def matcherToFunctionCall2[T1, T2, R](values: ((T1, T2), Matcher[R])): Function2[T1, T2, R] = @@ -43,7 +43,7 @@ trait FunctionArguments extends FunctionArgumentsLowImplicits { def callMatching3[T1, T2, T3, R](t1: T1, t2: T2, t3: T3, m: Matcher[R]): Function3[T1, T2, T3, R] = argThat(m ^^ { (f: Function3[T1, T2, T3, R]) => f(t1, t2, t3) }) - def functionCall3[T1, T2, T3, R](t1: T1, t2: T2, t3: T3, r: R): Function3[T1, T2, T3, R] = callMatching3(t1, t2, t3, new BeEqualTo(r)) + def functionCall3[T1, T2, T3, R](t1: T1, t2: T2, t3: T3, r: R): Function3[T1, T2, T3, R] = callMatching3(t1, t2, t3, new BeEqualTo(r)) implicit def toFunctionCall3[T1, T2, T3, R](values: ((T1, T2, T3), R)): Function3[T1, T2, T3, R] = functionCall3(values._1._1, values._1._2, values._1._3, values._2) implicit def matcherToFunctionCall3[T1, T2, T3, R](values: ((T1, T2, T3), Matcher[R])): Function3[T1, T2, T3, R] = diff --git a/specs2/src/test/scala/org/mockito/specs2/MockitoScalaNewSyntaxSpec.scala b/specs2/src/test/scala/org/mockito/specs2/MockitoScalaNewSyntaxSpec.scala index 82b05f61..e1219bfc 100644 --- a/specs2/src/test/scala/org/mockito/specs2/MockitoScalaNewSyntaxSpec.scala +++ b/specs2/src/test/scala/org/mockito/specs2/MockitoScalaNewSyntaxSpec.scala @@ -594,7 +594,7 @@ The Mockito trait is reusable in other contexts list1.get(0); list1.size; list1.get(0); list1.size implicit val order = inOrder(list1) - val result = got { + val result = got { list1.get(0) was called list1.size() was called list1.get(0) wasNever called diff --git a/specs2/src/test/scala/org/mockito/specs2/MockitoScalaSpec.scala b/specs2/src/test/scala/org/mockito/specs2/MockitoScalaSpec.scala index ce28ca17..6caccead 100644 --- a/specs2/src/test/scala/org/mockito/specs2/MockitoScalaSpec.scala +++ b/specs2/src/test/scala/org/mockito/specs2/MockitoScalaSpec.scala @@ -595,7 +595,7 @@ The Mockito trait is reusable in other contexts list1.get(0); list1.size; list1.get(0); list1.size implicit val order = inOrder(list1) - val result = there was one(list1).get(0) andThen + val result = there was one(list1).get(0) andThen one(list1).size() andThen no(list1).get(0) andThen one(list1).size() From ed63f8335348b3c275c35624f4a14f7f257d78e7 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 6 Jun 2025 00:30:19 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.9.7' to .git-blame-ignore-revs --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 3eb0fb64..faf7b87e 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -6,3 +6,6 @@ ff8ca52d610ca63ee0ab4fcfb5d79da13a1250b1 # Scala Steward: Reformat with scalafmt 3.8.6 c038644e07f224e668b7be8c53f9038cfd2275cf + +# Scala Steward: Reformat with scalafmt 3.9.7 +6140c78f063f429304c3195435068432de309492