-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11ad429
commit 726d9ec
Showing
3 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
scalatest/src/test/scala-2.13/user/org/mockito/Issue352_213.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package user.org.mockito | ||
|
||
import org.mockito.scalatest.MockitoSugar | ||
import org.scalatest.funspec.AnyFunSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
import scala.collection.immutable.ArraySeq | ||
|
||
class Issue352_213 extends AnyFunSpec with Matchers with MockitoSugar { | ||
|
||
trait IndexedSeqService { | ||
def testMethod(str: String, args: IndexedSeq[String]): IndexedSeq[String] | ||
} | ||
trait ArraySeqService { | ||
def testMethod(str: String, args: ArraySeq[String]): IndexedSeq[String] | ||
} | ||
|
||
describe("Mockito") { | ||
it("should allow ArraySeq as a last parameter") { | ||
val arraySeq = mock[ArraySeqService] | ||
when(arraySeq.testMethod(*, *)).thenAnswer[String, ArraySeq[String]] { (fst, rst) => | ||
fst +: rst | ||
} | ||
arraySeq.testMethod("a", ArraySeq("b", "c")).should(contain).allOf("a", "b", "c") | ||
} | ||
it("should allow ArraySeq as a last parameter to IndexedSeq method") { | ||
val indexedSeq = mock[IndexedSeqService] | ||
when(indexedSeq.testMethod(*, *)).thenAnswer[String, IndexedSeq[String]] { (fst, rst) => | ||
fst +: rst | ||
} | ||
indexedSeq.testMethod("a", ArraySeq("b", "c")).should(contain).allOf("a", "b", "c") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package user.org.mockito | ||
|
||
import org.mockito.scalatest.MockitoSugar | ||
import org.scalatest.funspec.AnyFunSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class Issue352 extends AnyFunSpec with Matchers with MockitoSugar { | ||
|
||
trait IndexedSeqService { | ||
def testMethod(str: String, args: IndexedSeq[String]): IndexedSeq[String] | ||
} | ||
trait VarArgsService { | ||
def testMethod(str: String, args: String*): IndexedSeq[String] | ||
} | ||
|
||
describe("Mockito") { | ||
it("should allow Vector as a last parameter to IndexedSeq method") { | ||
val indexedSeq = mock[IndexedSeqService] | ||
when(indexedSeq.testMethod(*, *)).thenAnswer[String, IndexedSeq[String]] { (fst, rst) => | ||
fst +: rst | ||
} | ||
indexedSeq.testMethod("a", Vector("b", "c")).should(contain).allOf("a", "b", "c") | ||
} | ||
it("should allow varargs as a last parameter to IndexedSeq method 2 varargs") { | ||
val varargSeq = mock[VarArgsService] | ||
when(varargSeq.testMethod(*, *)).thenAnswer[String, String, String] { (v0, v1, v2) => | ||
IndexedSeq(v0, v1, v2) | ||
} | ||
varargSeq.testMethod("a", "b", "c").should(contain).allOf("a", "b", "c") | ||
} | ||
it("should allow varargs as a last parameter to IndexedSeq method 1 vararg") { | ||
val varargSeq = mock[VarArgsService] | ||
when(varargSeq.testMethod(*, *)).thenAnswer[String, String] { (v0, v1) => | ||
IndexedSeq(v0, v1) | ||
} | ||
varargSeq.testMethod("a", "b").should(contain).allOf("a", "b") | ||
} | ||
it("should allow varargs as a last parameter to IndexedSeq method no vararg") { | ||
val varargSeq = mock[VarArgsService] | ||
when(varargSeq.testMethod(*, *)).thenAnswer[String] { v0 => | ||
IndexedSeq(v0) | ||
} | ||
varargSeq.testMethod("a").should(contain).only("a") | ||
} | ||
} | ||
} |