Skip to content

Commit

Permalink
java workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
goshacodes committed Oct 17, 2023
1 parent b40375e commit 19dc384
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions jvm/src/test/scala/com.paulbutcher.test/mock/JavaMocksTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class JavaMocksTest extends IsolatedSpec {

m.simpleMethod("two") shouldBe 42
}
/*

it should "mock classes with bridged methods" in {
val m = mock[JavaClassWithBridgeMethod]
class JavaClassWithBridgeMethodExtended extends JavaClassWithBridgeMethod
val m = mock[JavaClassWithBridgeMethodExtended]

(m.compare _).expects(Integer.valueOf(5)).returning(1)
(m.compare _).expects(Integer.valueOf(6)).returning(2)
Expand All @@ -44,7 +45,7 @@ class JavaMocksTest extends IsolatedSpec {

assertResult(1) { m.compare(Integer.valueOf(5)) } // calls: int compare(Integer)
assertResult(2) { useBridgeMethod(m, Integer.valueOf(6)) } // calls: int compare(Object)
}*/
}

//! TODO - this is going to have to wait for macro types for a proper solution
// "cope with Java methods with repeated parameters" in {
Expand Down Expand Up @@ -75,44 +76,52 @@ class JavaMocksTest extends IsolatedSpec {
m.polymorphicMethod(arg) shouldBe "foo"
}

/*
it should "mock a Java class with an overloaded method (different param count)" in { // test for issue #34
val m = mock[JavaClassWithOverloadedMethod]
class JavaClassWithOverloadedMethodExtended extends JavaClassWithOverloadedMethod

val m = mock[JavaClassWithOverloadedMethodExtended]
(m.overloadedMethod(_: String)).expects("a").returning("first")
(m.overloadedMethod(_: String, _: String)).expects("a", "b").returning("second")

m.overloadedMethod("a") shouldBe "first"
m.overloadedMethod("a", "b") shouldBe "second"
}*/
/*
}

it should "mock a Java class with an overloaded method (the same param count)" in { // test for issue #73
val m = mock[JavaClassWithOverloadedMethod]
class JavaClassWithOverloadedMethodExtended extends JavaClassWithOverloadedMethod

val m = mock[JavaClassWithOverloadedMethodExtended]
(m.overloadedSameParamCount(_: String)).expects("one").returning("first")
(m.overloadedSameParamCount(_: Integer)).expects(Integer.valueOf(2)).returning(2)

m.overloadedSameParamCount("one") shouldBe "first"
m.overloadedSameParamCount(2) shouldBe 2
}*/
}


/*
it should "mock a Java class with an overloaded method (with primitive param)" in { // test for issue #73
val m = mock[JavaClassWithOverloadedMethod]
class JavaClassWithOverloadedMethodExtended extends JavaClassWithOverloadedMethod

val m = mock[JavaClassWithOverloadedMethodExtended]

(m.overloadedWithPrimitiveParam(_: String)).expects("one").returning("first")
(m.overloadedWithPrimitiveParam(_: Int)).expects(2).returning("second")

m.overloadedWithPrimitiveParam("one") shouldBe "first"
m.overloadedWithPrimitiveParam(2) shouldBe "second"
}*/
}


/*
it should "mock a Java class with an overloaded method (with type params)" in {
val m = mock[JavaClassWithOverloadedMethod]
class JavaClassWithOverloadedMethodExtended extends JavaClassWithOverloadedMethod

val m = mock[JavaClassWithOverloadedMethodExtended]
(m.overloadedGeneric(_: String)).expects("one").returning("first")
(m.overloadedGeneric(_: Int)).expects(2).returning("second")
(m.overloadedGeneric(_: Integer)).expects(Integer.valueOf(2)).returning("second")

m.overloadedGeneric("one") shouldBe "first"
m.overloadedGeneric(2) shouldBe "second"
}*/
}

override def newInstance = new JavaMocksTest
}

0 comments on commit 19dc384

Please sign in to comment.