Skip to content

Commit 3cb1b96

Browse files
committed
Looks like the type inference is what causes issue
1 parent 023d2d8 commit 3cb1b96

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

core/src/test/scala/eu/monniot/scala3mock/mock/MockSuite.scala

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class MockSuite extends munit.FunSuite with MockFunctions {
8080

8181
// Polymorphic methods
8282
// Fail to compile with 3.3.0
83-
//when(m.polymorphic _).expects(List(2)).returns("a1")
84-
//assertEquals(m.polymorphic(List(2)), "a1")
83+
when[List[Int], String](m.polymorphic).expects(List(2)).returns("a1")
84+
assertEquals(m.polymorphic(List(2)), "a1")
8585

8686
val javaObject = Object()
8787
when(() => m.polymorphicUnary).expects().returns(javaObject)
@@ -91,8 +91,8 @@ class MockSuite extends munit.FunSuite with MockFunctions {
9191
assertEquals(m.polycurried("a")(2), "c" -> 6)
9292

9393
// Fail to compile with 3.3.0
94-
//when(m.polymorphicParam).expects((1, 2.0)).returns("ok")
95-
//assertEquals(m.polymorphicParam((1, 2.0)), "ok")
94+
when[(Int, Double), String](m.polymorphicParam).expects((1, 2.0)).returns("ok")
95+
assertEquals(m.polymorphicParam((1, 2.0)), "ok")
9696

9797

9898
// TODO Not supported yet
@@ -103,15 +103,13 @@ class MockSuite extends munit.FunSuite with MockFunctions {
103103
// Scala 3 to let us do that.
104104

105105
// type bound methods
106-
// Fail to compile with 3.3.0
107-
//when(m.upperBound _).expects(TestException()).returns(1)
108-
//assertEquals(m.upperBound(TestException()), 1)
106+
when[TestException, Int](m.upperBound _).expects(TestException()).returns(1)
107+
assertEquals(m.upperBound(TestException()), 1)
109108

110109
val animal = Animal()
111110
val dog = Dog()
112-
// Fail to compile with 3.3.0
113-
//when(m.lowerBound).expects(animal, List(dog)).returns("ok")
114-
//assertEquals(m.lowerBound(animal, List(dog)), "ok")
111+
when[Animal, List[Animal], String](m.lowerBound).expects(animal, List(dog)).returns("ok")
112+
assertEquals(m.lowerBound(animal, List(dog)), "ok")
115113

116114
// TODO with implementation methods
117115

scalatest/src/test/scala/eu/monniot/scala3mock/scalatest/ErrorReportingTest.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ class ErrorReportingTest
9797

9898
test("execute block of code") {
9999
val mockedTrait = mock[TestTrait]
100-
// Fail to compile with 3.3.0
101-
//when(mockedTrait.polymorphicMethod).expects(List(1)).returning("one")
100+
when[List[Int], String](mockedTrait.polymorphicMethod).expects(List(1)).returning("one")
102101

103102
suiteScopeMock.noParamMethod()
104103
mockedTrait.oneParamMethod(3)

0 commit comments

Comments
 (0)