From 77d9be7b0f2f98cb90e3b32ba2857b7ff034705d Mon Sep 17 00:00:00 2001 From: Matthias Geisler Date: Sun, 27 Feb 2022 11:10:48 +0100 Subject: [PATCH 1/3] Add new Matchers --- .../kmock/example/SampleControllerSpec.kt | 8 +- .../tech/antibytes/kmock/ArgumentMatcher.kt | 2 + .../tech/antibytes/kmock/MockeryAssertion.kt | 10 +- .../kotlin/tech/antibytes/kmock/Operators.kt | 4 +- .../kmock/VerificationHandleFactory.kt | 2 + .../antibytes/kmock/ArgumentMatcherSpec.kt | 128 +++++++++++------- .../antibytes/kmock/MockeryAssertionSpec.kt | 20 +-- .../tech/antibytes/kmock/OperationSpec.kt | 8 +- .../kmock/VerificationHandleFactorySpec.kt | 102 +++++++++----- 9 files changed, 175 insertions(+), 109 deletions(-) diff --git a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerSpec.kt b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerSpec.kt index 390323d3..bf7efdc6 100644 --- a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerSpec.kt +++ b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerSpec.kt @@ -16,7 +16,7 @@ import tech.antibytes.kmock.KMockContract.Collector import tech.antibytes.kmock.PropertyMockery import tech.antibytes.kmock.SyncFunMockery import tech.antibytes.kmock.Verifier -import tech.antibytes.kmock.assertHadBeenCalledStrictlyWith +import tech.antibytes.kmock.assertHasBeenCalledStrictlyWith import tech.antibytes.kmock.example.contract.ExampleContract import tech.antibytes.kmock.example.contract.ExampleContract.SampleDomainObject import tech.antibytes.kmock.example.contract.ExampleContract.SampleLocalRepository @@ -143,9 +143,9 @@ class SampleControllerSpec { delay(20) - local.contains.assertHadBeenCalledStrictlyWith(1, idOrg) - local.fetch.assertHadBeenCalledStrictlyWith(1, id) - remote.find.assertHadBeenCalledStrictlyWith(1, idOrg) + local.contains.assertHasBeenCalledStrictlyWith(1, idOrg) + local.fetch.assertHasBeenCalledStrictlyWith(1, id) + remote.find.assertHasBeenCalledStrictlyWith(1, idOrg) verifier.verifyStrictOrder { local.contains.hasBeenStrictlyCalledWith(idOrg) diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/ArgumentMatcher.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/ArgumentMatcher.kt index 7b7b3bd8..ba152fab 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/ArgumentMatcher.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/ArgumentMatcher.kt @@ -8,6 +8,8 @@ package tech.antibytes.kmock import tech.antibytes.kmock.KMockContract.GetOrSet +internal fun Array?.hasBeenCalledWithVoid(): Boolean = this == null + internal fun Array?.hasBeenCalledWith(vararg values: Any?): Boolean { return when { this == null -> values.isEmpty() diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/MockeryAssertion.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/MockeryAssertion.kt index e8128ff4..bbb9ebe8 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/MockeryAssertion.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/MockeryAssertion.kt @@ -8,7 +8,7 @@ package tech.antibytes.kmock import tech.antibytes.kmock.KMockContract.FunMockery -fun FunMockery<*, *>.assertHadBeenCalled( +fun FunMockery<*, *>.assertHasBeenCalled( exactly: Int, ) { verify(exactly = exactly) { @@ -16,7 +16,7 @@ fun FunMockery<*, *>.assertHadBeenCalled( } } -fun FunMockery<*, *>.assertHadBeenCalledWith( +fun FunMockery<*, *>.assertHasBeenCalledWith( exactly: Int, vararg arguments: Any? ) { @@ -25,7 +25,7 @@ fun FunMockery<*, *>.assertHadBeenCalledWith( } } -fun FunMockery<*, *>.assertHadBeenCalledStrictlyWith( +fun FunMockery<*, *>.assertHasBeenCalledStrictlyWith( exactly: Int, vararg arguments: Any? ) { @@ -34,13 +34,13 @@ fun FunMockery<*, *>.assertHadBeenCalledStrictlyWith( } } -fun FunMockery<*, *>.assertHadNotBeenCalled() { +fun FunMockery<*, *>.assertHasNotBeenCalled() { verify(exactly = 0) { this.hasBeenCalledWith() } } -fun FunMockery<*, *>.assertHadNotBeenCalledWith(vararg illegal: Any?) { +fun FunMockery<*, *>.assertHasNotBeenCalledWith(vararg illegal: Any?) { verify(exactly = 0) { this.hasBeenCalledWith(*illegal) } diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/Operators.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/Operators.kt index 5864ba09..ba0e531a 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/Operators.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/Operators.kt @@ -18,7 +18,7 @@ infix fun KMockContract.VerificationHandle.union( ) } -infix fun KMockContract.VerificationHandle.and( +infix fun KMockContract.VerificationHandle.or( other: KMockContract.VerificationHandle ): KMockContract.VerificationHandle = this.union(other) @@ -35,7 +35,7 @@ infix fun KMockContract.VerificationHandle.intersect( ) } -infix fun KMockContract.VerificationHandle.or( +infix fun KMockContract.VerificationHandle.and( other: KMockContract.VerificationHandle ): KMockContract.VerificationHandle = this.intersect(other) diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationHandleFactory.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationHandleFactory.kt index d0f6c919..06b69d80 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationHandleFactory.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationHandleFactory.kt @@ -37,6 +37,8 @@ private fun shareHandle( } } +fun FunMockery<*, *>.hasBeenCalled(): VerificationHandle = traverseMockAndShare(this) { hasBeenCalledWith() } + fun FunMockery<*, *>.hasBeenCalledWith( vararg values: Any? ): VerificationHandle = traverseMockAndShare(this) { hasBeenCalledWith(*values) } diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/ArgumentMatcherSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/ArgumentMatcherSpec.kt index 11dfdecc..b06ababf 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/ArgumentMatcherSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/ArgumentMatcherSpec.kt @@ -15,10 +15,36 @@ import kotlin.test.Test class ArgumentMatcherSpec { private val fixture = kotlinFixture() - + @Test @JsName("fn0") - fun `Given hadBeenCalledWith is called with an Argument it returns false if the Array contains not the given Argument`() { + fun `Given hasBeenCalledWithVoid is called it returns true if the Array is null`() { + // Given + val array: Array? = null + + // When + val actual = array.hasBeenCalledWithVoid() + + // Then + actual mustBe true + } + + @Test + @JsName("fn1") + fun `Given hasBeenCalledWithVoid is called it returns false if the contains values`() { + // Given + val array = fixture.listFixture().toTypedArray() + + // When + val actual = array.hasBeenCalledWithVoid() + + // Then + actual mustBe false + } + + @Test + @JsName("fn3") + fun `Given hasBeenCalledWith is called with an Argument it returns false if the Array contains not the given Argument`() { // Given val array = fixture.listFixture().toTypedArray() @@ -30,8 +56,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn1") - fun `Given hadBeenCalledWith is called with an Argument it returns false if the Array contains the given Argument`() { + @JsName("fn4") + fun `Given hasBeenCalledWith is called with an Argument it returns true if the Array contains the given Argument`() { // Given val array = fixture.listFixture().toTypedArray() @@ -43,8 +69,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn2") - fun `Given hadBeenCalledWith is called without Arguments void it returns true if the Array contains Arguments`() { + @JsName("fn5") + fun `Given hasBeenCalledWith is called without Arguments void it returns true if the Array contains Arguments`() { // Given val array = fixture.listFixture().toTypedArray() @@ -56,8 +82,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn3") - fun `Given hadBeenCalledWith is called without Arguments void it returns true if the Array is null`() { + @JsName("fn6") + fun `Given hasBeenCalledWith is called without Arguments void it returns true if the Array is null`() { // Given val array = null @@ -69,8 +95,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn4") - fun `Given hadBeenCalledWith is called with Arguments it returns false if the Array is null`() { + @JsName("fn7") + fun `Given hasBeenCalledWith is called with Arguments it returns false if the Array is null`() { // Given val array = null @@ -82,8 +108,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn5") - fun `Given hadBeenCalledWith is called with Arguments it returns false if the Array contains not all of given Arguments`() { + @JsName("fn8") + fun `Given hasBeenCalledWith is called with Arguments it returns false if the Array contains not all of given Arguments`() { // Given val array = fixture.listFixture(size = 8).toTypedArray() @@ -95,8 +121,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn6") - fun `Given hadBeenCalledWith is called with Arguments it returns true if the Array contains all of given Arguments`() { + @JsName("fn9") + fun `Given hasBeenCalledWith is called with Arguments it returns true if the Array contains all of given Arguments`() { // Given val array = fixture.listFixture(size = 8).toTypedArray() @@ -108,8 +134,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn7") - fun `Given hadBeenStrictlyCalledWith is called with an Argument it returns false if the Array matches not the given Argument`() { + @JsName("fn10") + fun `Given hasBeenStrictlyCalledWith is called with an Argument it returns false if the Array matches not the given Argument`() { // Given val array = fixture.listFixture().toTypedArray() @@ -121,8 +147,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn8") - fun `Given hadBeenStrictlyCalledWith is called with an Argument it returns true if the Array matches the given Argument`() { + @JsName("fn11") + fun `Given hasBeenStrictlyCalledWith is called with an Argument it returns true if the Array matches the given Argument`() { // Given val array = fixture.listFixture(size = 1).toTypedArray() @@ -134,8 +160,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn9") - fun `Given hadBeenStrictlyCalledWith is called without Arguments void it returns false if the Array has Arguments`() { + @JsName("fn12") + fun `Given hasBeenStrictlyCalledWith is called without Arguments void it returns false if the Array has Arguments`() { // Given val array = fixture.listFixture(size = 1).toTypedArray() @@ -147,8 +173,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn10") - fun `Given hadBeenStrictlyCalledWith is called witg Arguments void it returns false if the Array is null`() { + @JsName("fn13") + fun `Given hasBeenStrictlyCalledWith is called witg Arguments void it returns false if the Array is null`() { // Given val array = null @@ -160,8 +186,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn11") - fun `Given hadBeenStrictlyCalledWith is called without Arguments void it returns false if the Array is null`() { + @JsName("fn14") + fun `Given hasBeenStrictlyCalledWith is called without Arguments void it returns false if the Array is null`() { // Given val array = null @@ -173,8 +199,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn12") - fun `Given hadBeenStrictlyCalledWith is called with Arguments it returns false if the Array matches not exactly the given Arguments`() { + @JsName("fn15") + fun `Given hasBeenStrictlyCalledWith is called with Arguments it returns false if the Array matches not exactly the given Arguments`() { // Given val array = fixture.listFixture(size = 8).toTypedArray() @@ -186,8 +212,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn13") - fun `Given hadBeenStrictlyCalledWith is called with Arguments it returns true if the Array matches exactly the given Arguments`() { + @JsName("fn16") + fun `Given hasBeenStrictlyCalledWith is called with Arguments it returns true if the Array matches exactly the given Arguments`() { // Given val array = fixture.listFixture(size = 8).toTypedArray() @@ -199,8 +225,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn14") - fun `Given hadBeenCalledWithout is called with an Argument it returns false if the Array contains no Argument`() { + @JsName("fn17") + fun `Given hasBeenCalledWithout is called with an Argument it returns false if the Array contains no Argument`() { // Given val array = null @@ -212,8 +238,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn15") - fun `Given hadBeenCalledWithout is called with an Argument it returns true if the Array contains Arguments`() { + @JsName("fn18") + fun `Given hasBeenCalledWithout is called with an Argument it returns true if the Array contains Arguments`() { // Given val array = null @@ -225,8 +251,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn16") - fun `Given hadBeenCalledWithout is called with an Argument it returns true if the Array contains not the given Argument`() { + @JsName("fn19") + fun `Given hasBeenCalledWithout is called with an Argument it returns true if the Array contains not the given Argument`() { // Given val array = fixture.listFixture().toTypedArray() @@ -238,8 +264,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn17") - fun `Given hadBeenCalledWithout is called with an Argument it returns false if the Array contains the given Argument`() { + @JsName("fn20") + fun `Given hasBeenCalledWithout is called with an Argument it returns false if the Array contains the given Argument`() { // Given val array = fixture.listFixture().toTypedArray() @@ -251,8 +277,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn18") - fun `Given hadBeenCalledWithout is called without Argument it returns true if the Array contains Argument`() { + @JsName("fn21") + fun `Given hasBeenCalledWithout is called without Argument it returns true if the Array contains Argument`() { // Given val array = fixture.listFixture().toTypedArray() @@ -264,8 +290,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn19") - fun `Given hadBeenCalledWithout is called with Arguments it returns false if the Array is null`() { + @JsName("fn22") + fun `Given hasBeenCalledWithout is called with Arguments it returns false if the Array is null`() { // Given val array = fixture.listFixture().toTypedArray() @@ -277,8 +303,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn20") - fun `Given hadBeenCalledWithout is called with Arguments it returns true if the Array none of given Arguments matches`() { + @JsName("fn23") + fun `Given hasBeenCalledWithout is called with Arguments it returns true if the Array none of given Arguments matches`() { // Given val array = fixture.listFixture(size = 8).toTypedArray() @@ -291,8 +317,8 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn21") - fun `Given hadBeenCalledWithout is called with Arguments it returns false if the Array matches at least one of given Arguments`() { + @JsName("fn24") + fun `Given hasBeenCalledWithout is called with Arguments it returns false if the Array matches at least one of given Arguments`() { // Given val array = fixture.listFixture(size = 8).toTypedArray() @@ -309,43 +335,43 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn22") + @JsName("fn25") fun `Given wasGotten is called it returns false if it is attacht to Set`() { KMockContract.GetOrSet.Set(null).wasGotten() mustBe false } @Test - @JsName("fn23") + @JsName("fn26") fun `Given wasGotten is called it returns true if it is attacht to Get`() { KMockContract.GetOrSet.Get.wasGotten() mustBe true } @Test - @JsName("fn24") + @JsName("fn27") fun `Given wasSet is called it returns false if it is attacht to Get`() { KMockContract.GetOrSet.Get.wasSet() mustBe false } @Test - @JsName("fn25") + @JsName("fn28") fun `Given wasGotten is called it returns true if it is attacht to Set`() { KMockContract.GetOrSet.Set(null).wasSet() mustBe true } @Test - @JsName("fn26") + @JsName("fn29") fun `Given wasSetTo is called it returns false if it is attacht to Get`() { KMockContract.GetOrSet.Get.wasSetTo(null) mustBe false } @Test - @JsName("fn27") + @JsName("fn30") fun `Given wasSetTo is called it returns false if the values do not match`() { KMockContract.GetOrSet.Set(fixture.fixture()).wasSetTo(fixture.fixture()) mustBe false } @Test - @JsName("fn28") + @JsName("fn31") fun `Given wasSetTo is called it returns true if the values do math`() { val value: Any = fixture.fixture() KMockContract.GetOrSet.Set(value).wasSetTo(value) mustBe true diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/MockeryAssertionSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/MockeryAssertionSpec.kt index 79f33e86..30a9ac0f 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/MockeryAssertionSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/MockeryAssertionSpec.kt @@ -30,7 +30,7 @@ class MockeryAssertionSpec { // Then assertFailsWith { // When - mockery.assertHadBeenCalled(exactly = 1) + mockery.assertHasBeenCalled(exactly = 1) } } @@ -44,7 +44,7 @@ class MockeryAssertionSpec { mockery.getArgumentsForCall = { values } // When - mockery.assertHadBeenCalled(exactly = 1) + mockery.assertHasBeenCalled(exactly = 1) } @Test @@ -59,7 +59,7 @@ class MockeryAssertionSpec { // Then assertFailsWith { // When - mockery.assertHadBeenCalledWith( + mockery.assertHasBeenCalledWith( exactly = 1, arguments = fixture.listFixture().toTypedArray() ) @@ -75,7 +75,7 @@ class MockeryAssertionSpec { mockery.getArgumentsForCall = { values } // When - mockery.assertHadBeenCalledWith( + mockery.assertHasBeenCalledWith( exactly = 1, values[0] ) @@ -93,7 +93,7 @@ class MockeryAssertionSpec { // Then assertFailsWith { // When - mockery.assertHadBeenCalledStrictlyWith( + mockery.assertHasBeenCalledStrictlyWith( exactly = 1, values[0] ) @@ -110,7 +110,7 @@ class MockeryAssertionSpec { mockery.getArgumentsForCall = { values } // When - mockery.assertHadBeenCalledStrictlyWith( + mockery.assertHasBeenCalledStrictlyWith( exactly = 1, arguments = values ) @@ -128,7 +128,7 @@ class MockeryAssertionSpec { // Then assertFailsWith { // When - mockery.assertHadNotBeenCalled() + mockery.assertHasNotBeenCalled() } } @@ -142,7 +142,7 @@ class MockeryAssertionSpec { mockery.getArgumentsForCall = { values } // When - mockery.assertHadNotBeenCalled() + mockery.assertHasNotBeenCalled() } @Test @@ -157,7 +157,7 @@ class MockeryAssertionSpec { // Then assertFailsWith { // When - mockery.assertHadNotBeenCalledWith(values[0]) + mockery.assertHasNotBeenCalledWith(values[0]) } } @@ -171,7 +171,7 @@ class MockeryAssertionSpec { mockery.getArgumentsForCall = { values } // When - mockery.assertHadNotBeenCalledWith(fixture.fixture()) + mockery.assertHasNotBeenCalledWith(fixture.fixture()) } @Test diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/OperationSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/OperationSpec.kt index 3aa74f49..9ab52f76 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/OperationSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/OperationSpec.kt @@ -29,7 +29,7 @@ class OperationSpec { // When val actualUnion = handle1 union handle2 - val actualAnd = handle1 and handle2 + val actualOr = handle1 or handle2 // Then val expected = values1.toMutableList() @@ -38,7 +38,7 @@ class OperationSpec { .toList() .sorted() - actualAnd mustBe actualUnion + actualOr mustBe actualUnion actualUnion.id mustBe handle1.id actualUnion.callIndices.forEachIndexed { idx, value -> @@ -66,12 +66,12 @@ class OperationSpec { // When val actualIntersect = handle1 intersect handle2 - val actualOr = handle1 or handle2 + val actualAnd = handle1 and handle2 // Then val expected = base.sorted() - actualOr mustBe actualIntersect + actualAnd mustBe actualIntersect actualIntersect.id mustBe handle1.id actualIntersect.callIndices.forEachIndexed { idx, value -> diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationHandleFactorySpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationHandleFactorySpec.kt index af54c725..35f81ef9 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationHandleFactorySpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationHandleFactorySpec.kt @@ -22,13 +22,13 @@ class VerificationHandleFactorySpec { @Test @JsName("fn0") - fun `Given wasCalledWithArguments is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches`() { + fun `Given hasBeenCalledWith is called with a FunMockery it returns a VerficationHandle which contains no matches if there were no calls`() { // Given val name: String = fixture.fixture() val mock = FunMockeryStub(name, 0) // When - val actual = mock.hasBeenCalledWith() + val actual = mock.hasBeenCalled() // Then actual mustBe VerificationHandle(name, emptyList()) @@ -36,7 +36,43 @@ class VerificationHandleFactorySpec { @Test @JsName("fn1") - fun `Given wasCalledWithArguments is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches while delegating the captured values`() { + fun `Given hasBeenCalledWith is called with a FunMockery it returns a VerficationHandle which contains no matches if there were calls`() { + // Given + val name: String = fixture.fixture() + val mock = FunMockeryStub(name, 1) + + var capturedIndex: Int? = null + mock.getArgumentsForCall = { givenIndex -> + capturedIndex = givenIndex + + fixture.listFixture().toTypedArray() + } + + // When + val actual = mock.hasBeenCalled() + + // Then + actual mustBe VerificationHandle(name, listOf(0)) + capturedIndex mustBe 0 + } + + @Test + @JsName("fn2") + fun `Given hasBeenCalledWith is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches`() { + // Given + val name: String = fixture.fixture() + val mock = FunMockeryStub(name, 0) + + // When + val actual = mock.hasBeenCalledWith() + + // Then + actual mustBe VerificationHandle(name, emptyList()) + } + + @Test + @JsName("fn3") + fun `Given hasBeenCalledWith is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches while delegating the captured values`() { // Given val name: String = fixture.fixture() val mock = FunMockeryStub(name, 1) @@ -57,8 +93,8 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn2") - fun `Given wasCalledWithArguments is called with a FunMockery it returns a VerficationHandle which contains matches if something matches while delegating the captured values`() { + @JsName("fn4") + fun `Given hasBeenCalledWith is called with a FunMockery it returns a VerficationHandle which contains matches if something matches while delegating the captured values`() { // Given val name: String = fixture.fixture() val mock = FunMockeryStub(name, 1) @@ -80,8 +116,8 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn3") - fun `Given wasCalledWithArguments is called with a FunMockery it propagtes its handle`() { + @JsName("fn5") + fun `Given hasBeenCalledWith is called with a FunMockery it propagtes its handle`() { // Given val name: String = fixture.fixture() val captured: MutableList = mutableListOf() @@ -107,8 +143,8 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn4") - fun `Given wasCalledWithArgumentsStrict is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches`() { + @JsName("fn6") + fun `Given hasBeenStrictlyCalledWith is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches`() { // Given val name: String = fixture.fixture() val mock = FunMockeryStub(name, 0) @@ -121,8 +157,8 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn5") - fun `Given wasCalledWithArgumentsStrict is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches while delegating the captured values`() { + @JsName("fn7") + fun `Given hasBeenStrictlyCalledWith is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches while delegating the captured values`() { // Given val name: String = fixture.fixture() val mock = FunMockeryStub(name, 1) @@ -143,8 +179,8 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn6") - fun `Given wasCalledWithArgumentsStrict is called with a FunMockery it returns a VerficationHandle which contains matches if something matches while delegating the captured values`() { + @JsName("fn8") + fun `Given hasBeenStrictlyCalledWith is called with a FunMockery it returns a VerficationHandle which contains matches if something matches while delegating the captured values`() { // Given val name: String = fixture.fixture() val mock = FunMockeryStub(name, 1) @@ -166,8 +202,8 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn7") - fun `Given wasCalledWithArgumentsStrict is called with a FunMockery it propagates its Handle`() { + @JsName("fn9") + fun `Given hasBeenStrictlyCalledWith is called with a FunMockery it propagates its Handle`() { // Given val name: String = fixture.fixture() val captured: MutableList = mutableListOf() @@ -194,8 +230,8 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn8") - fun `Given wasCalledWithoutArguments is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches`() { + @JsName("fn10") + fun `Given hasBeenCalledWithout is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches`() { // Given val name: String = fixture.fixture() val mock = FunMockeryStub(name, 0) @@ -208,8 +244,8 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn9") - fun `Given wasCalledWithoutArguments is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches while delegating the captured values`() { + @JsName("fn11") + fun `Given hasBeenCalledWithout is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches while delegating the captured values`() { // Given val name: String = fixture.fixture() val mock = FunMockeryStub(name, 1) @@ -231,8 +267,8 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn10") - fun `Given wasCalledWithoutArguments is called with a FunMockery it returns a VerficationHandle which contains matches if something matches while delegating the captured values`() { + @JsName("fn12") + fun `Given hasBeenCalledWithout is called with a FunMockery it returns a VerficationHandle which contains matches if something matches while delegating the captured values`() { // Given val name: String = fixture.fixture() val mock = FunMockeryStub(name, 1) @@ -253,8 +289,8 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn11") - fun `Given wasCalledWithoutArguments is called with a FunMockery it propagates its Handle`() { + @JsName("fn13") + fun `Given hasBeenCalledWithout is called with a FunMockery it propagates its Handle`() { // Given val name: String = fixture.fixture() val captured: MutableList = mutableListOf() @@ -279,7 +315,7 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn12") + @JsName("fn14") fun `Given wasGotten is called with a PropMockery it returns a VerficationHandle while filtering mismatches`() { // Given val name: String = fixture.fixture() @@ -301,7 +337,7 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn13") + @JsName("fn15") fun `Given wasGotten is called with a PropMockery it returns a VerficationHandle which contains matches`() { // Given val name: String = fixture.fixture() @@ -323,7 +359,7 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn14") + @JsName("fn16") fun `Given wasGotten is called with a PropMockery it it propagates its Handle`() { // Given val name: String = fixture.fixture() @@ -349,7 +385,7 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn15") + @JsName("fn17") fun `Given wasSet is called with a PropMockery it returns a VerficationHandle while filtering mismatches`() { // Given val name: String = fixture.fixture() @@ -371,7 +407,7 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn16") + @JsName("fn18") fun `Given wasSet is called with a PropMockery it returns a VerficationHandle which contains matches`() { // Given val name: String = fixture.fixture() @@ -393,7 +429,7 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn17") + @JsName("fn19") fun `Given wasSet is called with a PropMockery it propagates its Handle`() { // Given val name: String = fixture.fixture() @@ -419,7 +455,7 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn18") + @JsName("fn20") fun `Given wasSetTo is called with a PropMockery it returns a VerficationHandle while filtering mismatches`() { // Given val name: String = fixture.fixture() @@ -441,7 +477,7 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn19") + @JsName("fn21") fun `Given wasSetTo is called with a PropMockery it returns a VerficationHandle while filtering mismatching Values`() { // Given val name: String = fixture.fixture() @@ -463,7 +499,7 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn20") + @JsName("fn22") fun `Given wasSetTo is called with a PropMockery it returns a VerficationHandle which contains matches`() { // Given val name: String = fixture.fixture() @@ -486,7 +522,7 @@ class VerificationHandleFactorySpec { } @Test - @JsName("fn21") + @JsName("fn23") fun `Given wasSetTo is called with a PropMockery it propagates its Handle`() { // Given val name: String = fixture.fixture() From 547fb7fcf41a4e102691d85a1c92f2d111f02bbd Mon Sep 17 00:00:00 2001 From: Matthias Geisler Date: Sun, 27 Feb 2022 12:39:09 +0100 Subject: [PATCH 2/3] Add matchers --- .../SampleControllerAutoSpyFactorySpec.kt | 22 +++--- .../SampleControllerAutoStubFactorySpec.kt | 20 +++--- .../SampleControllerAutoStubRelaxedSpec.kt | 20 +++--- .../example/SampleControllerAutoStubSpec.kt | 20 +++--- .../kmock/example/SampleControllerSpec.kt | 28 ++++---- .../kmock/processor/ProcessorContract.kt | 8 +-- .../AsyncFunctionCommonExpected.kt | 8 +-- .../AsyncFunctionPlatformExpected.kt | 8 +-- .../generatorTest/FunctionOverloadExpected.kt | 8 +-- .../generatorTest/GenericsExpected.kt | 8 +-- .../generatorTest/PropertyCommonExpected.kt | 8 +-- .../generatorTest/PropertyPlatformExpected.kt | 8 +-- .../generatorTest/RelaxedExpected.kt | 8 +-- .../SyncFunctionCommonExpected.kt | 8 +-- .../SyncFunctionPlatformExpected.kt | 8 +-- .../tech/antibytes/kmock/KMockContract.kt | 20 +++--- .../kmock/{ => mock}/AsyncFunMockery.kt | 3 +- .../antibytes/kmock/{ => mock}/FunMockery.kt | 3 +- .../kmock/{ => mock}/PropertyMockery.kt | 3 +- .../kmock/{ => mock}/SyncFunMockery.kt | 3 +- .../kmock/{ => mock}/UnitFunRelaxer.kt | 2 +- .../{ => verification}/ArgumentMatcher.kt | 2 +- .../{ => verification}/MockeryAssertion.kt | 3 +- .../{ => verification}/NonfreezingVerifier.kt | 3 +- .../kmock/{ => verification}/Operators.kt | 4 +- .../kmock/{ => verification}/Verification.kt | 2 +- .../VerificationChainBuilder.kt | 3 +- .../{ => verification}/VerificationHandle.kt | 4 +- .../VerificationHandleFactory.kt | 2 +- .../kmock/{ => verification}/Verifier.kt | 3 +- .../kmock/verification/contraints/any.kt | 24 +++++++ .../kmock/verification/contraints/eq.kt | 18 +++++ .../kmock/verification/contraints/isNot.kt | 18 +++++ .../verification/contraints/isNotSame.kt | 17 +++++ .../kmock/verification/contraints/isSame.kt | 17 +++++ .../AsyncFunMockeryInvocationsSpec.kt | 2 +- .../kmock/{ => mock}/AsyncFunMockerySpec.kt | 3 +- .../AsyncFunMockeryUnfrozenInvocationsSpec.kt | 2 +- .../{ => mock}/AsyncFunMockeryUnfrozenSpec.kt | 3 +- .../kmock/{ => mock}/PropertyMockerySpec.kt | 3 +- .../{ => mock}/PropertyMockeryUnfrozenSpec.kt | 3 +- .../SyncFunMockeryInvocationsSpec.kt | 2 +- .../kmock/{ => mock}/SyncFunMockerySpec.kt | 3 +- .../SyncFunMockeryUnfrozenInvocationsSpec.kt | 2 +- .../{ => mock}/SyncFunMockeryUnfrozenSpec.kt | 3 +- .../kmock/{ => mock}/UnitFunRelaxerSpec.kt | 2 +- .../{ => verification}/ArgumentMatcherSpec.kt | 5 +- .../MockeryAssertionSpec.kt | 3 +- .../NonFreezingVerifierSpec.kt | 3 +- .../kmock/{ => verification}/OperationSpec.kt | 2 +- .../VerificationChainBuilderSpec.kt | 3 +- .../VerificationHandleFactorySpec.kt | 5 +- .../{ => verification}/VerificationSpec.kt | 2 +- .../kmock/{ => verification}/VerifierSpec.kt | 3 +- .../kmock/verification/contraints/AnySpec.kt | 71 +++++++++++++++++++ .../verification/contraints/EqualSpec.kt | 51 +++++++++++++ .../verification/contraints/IsNotSameSpec.kt | 51 +++++++++++++ .../verification/contraints/IsNotSpec.kt | 51 +++++++++++++ .../verification/contraints/IsSameSpec.kt | 51 +++++++++++++ 59 files changed, 535 insertions(+), 138 deletions(-) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => mock}/AsyncFunMockery.kt (99%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => mock}/FunMockery.kt (98%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => mock}/PropertyMockery.kt (98%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => mock}/SyncFunMockery.kt (99%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => mock}/UnitFunRelaxer.kt (89%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => verification}/ArgumentMatcher.kt (96%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => verification}/MockeryAssertion.kt (95%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => verification}/NonfreezingVerifier.kt (89%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => verification}/Operators.kt (94%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => verification}/Verification.kt (99%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => verification}/VerificationChainBuilder.kt (93%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => verification}/VerificationHandle.kt (76%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => verification}/VerificationHandleFactory.kt (97%) rename kmock/src/commonMain/kotlin/tech/antibytes/kmock/{ => verification}/Verifier.kt (90%) create mode 100644 kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/any.kt create mode 100644 kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/eq.kt create mode 100644 kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNot.kt create mode 100644 kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNotSame.kt create mode 100644 kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isSame.kt rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/AsyncFunMockeryInvocationsSpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/AsyncFunMockerySpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/AsyncFunMockeryUnfrozenInvocationsSpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/AsyncFunMockeryUnfrozenSpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/PropertyMockerySpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/PropertyMockeryUnfrozenSpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/SyncFunMockeryInvocationsSpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/SyncFunMockerySpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/SyncFunMockeryUnfrozenInvocationsSpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/SyncFunMockeryUnfrozenSpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => mock}/UnitFunRelaxerSpec.kt (94%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => verification}/ArgumentMatcherSpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => verification}/MockeryAssertionSpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => verification}/NonFreezingVerifierSpec.kt (95%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => verification}/OperationSpec.kt (98%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => verification}/VerificationChainBuilderSpec.kt (97%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => verification}/VerificationHandleFactorySpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => verification}/VerificationSpec.kt (99%) rename kmock/src/commonTest/kotlin/tech/antibytes/kmock/{ => verification}/VerifierSpec.kt (96%) create mode 100644 kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/AnySpec.kt create mode 100644 kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/EqualSpec.kt create mode 100644 kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsNotSameSpec.kt create mode 100644 kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsNotSpec.kt create mode 100644 kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsSameSpec.kt diff --git a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoSpyFactorySpec.kt b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoSpyFactorySpec.kt index 239b28ae..70234592 100644 --- a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoSpyFactorySpec.kt +++ b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoSpyFactorySpec.kt @@ -15,8 +15,6 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import tech.antibytes.kmock.MockCommon -import tech.antibytes.kmock.NonfreezingVerifier -import tech.antibytes.kmock.Verifier import tech.antibytes.kmock.example.contract.ExampleContract import tech.antibytes.kmock.example.contract.ExampleContract.SampleDomainObject import tech.antibytes.kmock.example.contract.ExampleContract.SampleLocalRepository @@ -24,15 +22,17 @@ import tech.antibytes.kmock.example.contract.ExampleContract.SampleRemoteReposit import tech.antibytes.kmock.example.contract.SampleDomainObjectMock import tech.antibytes.kmock.example.contract.SampleLocalRepositoryMock import tech.antibytes.kmock.example.contract.SampleRemoteRepositoryMock -import tech.antibytes.kmock.hasBeenCalledWith -import tech.antibytes.kmock.hasBeenCalledWithout -import tech.antibytes.kmock.hasBeenStrictlyCalledWith -import tech.antibytes.kmock.verify -import tech.antibytes.kmock.verifyOrder -import tech.antibytes.kmock.verifyStrictOrder -import tech.antibytes.kmock.wasGotten -import tech.antibytes.kmock.wasSet -import tech.antibytes.kmock.wasSetTo +import tech.antibytes.kmock.verification.NonfreezingVerifier +import tech.antibytes.kmock.verification.Verifier +import tech.antibytes.kmock.verification.hasBeenCalledWith +import tech.antibytes.kmock.verification.hasBeenCalledWithout +import tech.antibytes.kmock.verification.hasBeenStrictlyCalledWith +import tech.antibytes.kmock.verification.verify +import tech.antibytes.kmock.verification.verifyOrder +import tech.antibytes.kmock.verification.verifyStrictOrder +import tech.antibytes.kmock.verification.wasGotten +import tech.antibytes.kmock.verification.wasSet +import tech.antibytes.kmock.verification.wasSetTo import tech.antibytes.util.test.coroutine.AsyncTestReturnValue import tech.antibytes.util.test.coroutine.clearBlockingTest import tech.antibytes.util.test.coroutine.defaultTestContext diff --git a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubFactorySpec.kt b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubFactorySpec.kt index a2a60b07..041e5b36 100644 --- a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubFactorySpec.kt +++ b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubFactorySpec.kt @@ -12,7 +12,6 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import tech.antibytes.kmock.MockCommon -import tech.antibytes.kmock.Verifier import tech.antibytes.kmock.example.contract.ExampleContract import tech.antibytes.kmock.example.contract.ExampleContract.SampleDomainObject import tech.antibytes.kmock.example.contract.ExampleContract.SampleLocalRepository @@ -20,15 +19,16 @@ import tech.antibytes.kmock.example.contract.ExampleContract.SampleRemoteReposit import tech.antibytes.kmock.example.contract.SampleDomainObjectMock import tech.antibytes.kmock.example.contract.SampleLocalRepositoryMock import tech.antibytes.kmock.example.contract.SampleRemoteRepositoryMock -import tech.antibytes.kmock.hasBeenCalledWith -import tech.antibytes.kmock.hasBeenCalledWithout -import tech.antibytes.kmock.hasBeenStrictlyCalledWith -import tech.antibytes.kmock.verify -import tech.antibytes.kmock.verifyOrder -import tech.antibytes.kmock.verifyStrictOrder -import tech.antibytes.kmock.wasGotten -import tech.antibytes.kmock.wasSet -import tech.antibytes.kmock.wasSetTo +import tech.antibytes.kmock.verification.Verifier +import tech.antibytes.kmock.verification.hasBeenCalledWith +import tech.antibytes.kmock.verification.hasBeenCalledWithout +import tech.antibytes.kmock.verification.hasBeenStrictlyCalledWith +import tech.antibytes.kmock.verification.verify +import tech.antibytes.kmock.verification.verifyOrder +import tech.antibytes.kmock.verification.verifyStrictOrder +import tech.antibytes.kmock.verification.wasGotten +import tech.antibytes.kmock.verification.wasSet +import tech.antibytes.kmock.verification.wasSetTo import tech.antibytes.util.test.coroutine.AsyncTestReturnValue import tech.antibytes.util.test.coroutine.clearBlockingTest import tech.antibytes.util.test.coroutine.defaultTestContext diff --git a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubRelaxedSpec.kt b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubRelaxedSpec.kt index 4432227f..bb21d4f0 100644 --- a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubRelaxedSpec.kt +++ b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubRelaxedSpec.kt @@ -13,7 +13,6 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import tech.antibytes.kmock.MockCommon import tech.antibytes.kmock.Relaxer -import tech.antibytes.kmock.Verifier import tech.antibytes.kmock.example.contract.ExampleContract import tech.antibytes.kmock.example.contract.ExampleContract.SampleDomainObject import tech.antibytes.kmock.example.contract.ExampleContract.SampleLocalRepository @@ -21,15 +20,16 @@ import tech.antibytes.kmock.example.contract.ExampleContract.SampleRemoteReposit import tech.antibytes.kmock.example.contract.SampleDomainObjectMock import tech.antibytes.kmock.example.contract.SampleLocalRepositoryMock import tech.antibytes.kmock.example.contract.SampleRemoteRepositoryMock -import tech.antibytes.kmock.hasBeenCalledWith -import tech.antibytes.kmock.hasBeenCalledWithout -import tech.antibytes.kmock.hasBeenStrictlyCalledWith -import tech.antibytes.kmock.verify -import tech.antibytes.kmock.verifyOrder -import tech.antibytes.kmock.verifyStrictOrder -import tech.antibytes.kmock.wasGotten -import tech.antibytes.kmock.wasSet -import tech.antibytes.kmock.wasSetTo +import tech.antibytes.kmock.verification.Verifier +import tech.antibytes.kmock.verification.hasBeenCalledWith +import tech.antibytes.kmock.verification.hasBeenCalledWithout +import tech.antibytes.kmock.verification.hasBeenStrictlyCalledWith +import tech.antibytes.kmock.verification.verify +import tech.antibytes.kmock.verification.verifyOrder +import tech.antibytes.kmock.verification.verifyStrictOrder +import tech.antibytes.kmock.verification.wasGotten +import tech.antibytes.kmock.verification.wasSet +import tech.antibytes.kmock.verification.wasSetTo import tech.antibytes.util.test.coroutine.AsyncTestReturnValue import tech.antibytes.util.test.coroutine.clearBlockingTest import tech.antibytes.util.test.coroutine.defaultTestContext diff --git a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubSpec.kt b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubSpec.kt index 6bd9499d..99038fc7 100644 --- a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubSpec.kt +++ b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerAutoStubSpec.kt @@ -12,7 +12,6 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import tech.antibytes.kmock.MockCommon -import tech.antibytes.kmock.Verifier import tech.antibytes.kmock.example.contract.ExampleContract import tech.antibytes.kmock.example.contract.ExampleContract.SampleDomainObject import tech.antibytes.kmock.example.contract.ExampleContract.SampleLocalRepository @@ -20,15 +19,16 @@ import tech.antibytes.kmock.example.contract.ExampleContract.SampleRemoteReposit import tech.antibytes.kmock.example.contract.SampleDomainObjectMock import tech.antibytes.kmock.example.contract.SampleLocalRepositoryMock import tech.antibytes.kmock.example.contract.SampleRemoteRepositoryMock -import tech.antibytes.kmock.hasBeenCalledWith -import tech.antibytes.kmock.hasBeenCalledWithout -import tech.antibytes.kmock.hasBeenStrictlyCalledWith -import tech.antibytes.kmock.verify -import tech.antibytes.kmock.verifyOrder -import tech.antibytes.kmock.verifyStrictOrder -import tech.antibytes.kmock.wasGotten -import tech.antibytes.kmock.wasSet -import tech.antibytes.kmock.wasSetTo +import tech.antibytes.kmock.verification.Verifier +import tech.antibytes.kmock.verification.hasBeenCalledWith +import tech.antibytes.kmock.verification.hasBeenCalledWithout +import tech.antibytes.kmock.verification.hasBeenStrictlyCalledWith +import tech.antibytes.kmock.verification.verify +import tech.antibytes.kmock.verification.verifyOrder +import tech.antibytes.kmock.verification.verifyStrictOrder +import tech.antibytes.kmock.verification.wasGotten +import tech.antibytes.kmock.verification.wasSet +import tech.antibytes.kmock.verification.wasSetTo import tech.antibytes.util.test.coroutine.AsyncTestReturnValue import tech.antibytes.util.test.coroutine.clearBlockingTest import tech.antibytes.util.test.coroutine.defaultTestContext diff --git a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerSpec.kt b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerSpec.kt index bf7efdc6..4b391512 100644 --- a/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerSpec.kt +++ b/examples/src/commonTest/kotlin/tech/antibytes/kmock/example/SampleControllerSpec.kt @@ -11,25 +11,25 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract.Collector -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery -import tech.antibytes.kmock.Verifier -import tech.antibytes.kmock.assertHasBeenCalledStrictlyWith import tech.antibytes.kmock.example.contract.ExampleContract import tech.antibytes.kmock.example.contract.ExampleContract.SampleDomainObject import tech.antibytes.kmock.example.contract.ExampleContract.SampleLocalRepository import tech.antibytes.kmock.example.contract.ExampleContract.SampleRemoteRepository -import tech.antibytes.kmock.hasBeenCalledWith -import tech.antibytes.kmock.hasBeenCalledWithout -import tech.antibytes.kmock.hasBeenStrictlyCalledWith -import tech.antibytes.kmock.verify -import tech.antibytes.kmock.verifyOrder -import tech.antibytes.kmock.verifyStrictOrder -import tech.antibytes.kmock.wasGotten -import tech.antibytes.kmock.wasSet -import tech.antibytes.kmock.wasSetTo +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery +import tech.antibytes.kmock.verification.Verifier +import tech.antibytes.kmock.verification.assertHasBeenCalledStrictlyWith +import tech.antibytes.kmock.verification.hasBeenCalledWith +import tech.antibytes.kmock.verification.hasBeenCalledWithout +import tech.antibytes.kmock.verification.hasBeenStrictlyCalledWith +import tech.antibytes.kmock.verification.verify +import tech.antibytes.kmock.verification.verifyOrder +import tech.antibytes.kmock.verification.verifyStrictOrder +import tech.antibytes.kmock.verification.wasGotten +import tech.antibytes.kmock.verification.wasSet +import tech.antibytes.kmock.verification.wasSetTo import tech.antibytes.util.test.coroutine.AsyncTestReturnValue import tech.antibytes.util.test.coroutine.clearBlockingTest import tech.antibytes.util.test.coroutine.defaultTestContext diff --git a/kmock-processor/src/main/kotlin/tech/antibytes/kmock/processor/ProcessorContract.kt b/kmock-processor/src/main/kotlin/tech/antibytes/kmock/processor/ProcessorContract.kt index 302b447e..8187208c 100644 --- a/kmock-processor/src/main/kotlin/tech/antibytes/kmock/processor/ProcessorContract.kt +++ b/kmock-processor/src/main/kotlin/tech/antibytes/kmock/processor/ProcessorContract.kt @@ -10,13 +10,13 @@ import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSClassDeclaration import com.google.devtools.ksp.symbol.KSFile import com.squareup.kotlinpoet.ClassName -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector import tech.antibytes.kmock.Mock import tech.antibytes.kmock.MockCommon -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery internal interface ProcessorContract { data class Relaxer( @@ -81,7 +81,7 @@ internal interface ProcessorContract { ) val UNIT_RELAXER = ClassName( - KMockContract::class.java.packageName, + SyncFunMockery::class.java.packageName, "relaxVoidFunction" ) diff --git a/kmock-processor/src/test/resources/generatorTest/AsyncFunctionCommonExpected.kt b/kmock-processor/src/test/resources/generatorTest/AsyncFunctionCommonExpected.kt index 85a5591a..dd5973c2 100644 --- a/kmock-processor/src/test/resources/generatorTest/AsyncFunctionCommonExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/AsyncFunctionCommonExpected.kt @@ -5,12 +5,12 @@ import kotlin.Any import kotlin.Boolean import kotlin.Int import kotlin.Unit -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery -import tech.antibytes.kmock.relaxVoidFunction +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery +import tech.antibytes.kmock.mock.relaxVoidFunction internal class AsyncFunctionCommonMock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, diff --git a/kmock-processor/src/test/resources/generatorTest/AsyncFunctionPlatformExpected.kt b/kmock-processor/src/test/resources/generatorTest/AsyncFunctionPlatformExpected.kt index 26eaf21a..3fc199ec 100644 --- a/kmock-processor/src/test/resources/generatorTest/AsyncFunctionPlatformExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/AsyncFunctionPlatformExpected.kt @@ -4,12 +4,12 @@ import kotlin.Any import kotlin.Boolean import kotlin.Int import kotlin.Unit -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery -import tech.antibytes.kmock.relaxVoidFunction +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery +import tech.antibytes.kmock.mock.relaxVoidFunction internal class AsyncFunctionPlatformMock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, diff --git a/kmock-processor/src/test/resources/generatorTest/FunctionOverloadExpected.kt b/kmock-processor/src/test/resources/generatorTest/FunctionOverloadExpected.kt index e0fa612e..0cb15748 100644 --- a/kmock-processor/src/test/resources/generatorTest/FunctionOverloadExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/FunctionOverloadExpected.kt @@ -6,12 +6,12 @@ import kotlin.Function1 import kotlin.Int import kotlin.String import kotlin.Unit -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery -import tech.antibytes.kmock.relaxVoidFunction +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery +import tech.antibytes.kmock.mock.relaxVoidFunction internal class SyncFunctionOverloadMock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, diff --git a/kmock-processor/src/test/resources/generatorTest/GenericsExpected.kt b/kmock-processor/src/test/resources/generatorTest/GenericsExpected.kt index 6f40bd80..639fc4e1 100644 --- a/kmock-processor/src/test/resources/generatorTest/GenericsExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/GenericsExpected.kt @@ -2,12 +2,12 @@ package generatorTest import kotlin.Boolean import kotlin.Unit -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery -import tech.antibytes.kmock.relaxVoidFunction +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery +import tech.antibytes.kmock.mock.relaxVoidFunction internal class GenericsMock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, diff --git a/kmock-processor/src/test/resources/generatorTest/PropertyCommonExpected.kt b/kmock-processor/src/test/resources/generatorTest/PropertyCommonExpected.kt index 97cb7e3b..d92556c6 100644 --- a/kmock-processor/src/test/resources/generatorTest/PropertyCommonExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/PropertyCommonExpected.kt @@ -5,12 +5,12 @@ import kotlin.Any import kotlin.Boolean import kotlin.String import kotlin.Unit -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery -import tech.antibytes.kmock.relaxVoidFunction +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery +import tech.antibytes.kmock.mock.relaxVoidFunction internal class PropertyCommonMock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, diff --git a/kmock-processor/src/test/resources/generatorTest/PropertyPlatformExpected.kt b/kmock-processor/src/test/resources/generatorTest/PropertyPlatformExpected.kt index a69e3b27..25128ed8 100644 --- a/kmock-processor/src/test/resources/generatorTest/PropertyPlatformExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/PropertyPlatformExpected.kt @@ -4,12 +4,12 @@ import kotlin.Any import kotlin.Boolean import kotlin.String import kotlin.Unit -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery -import tech.antibytes.kmock.relaxVoidFunction +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery +import tech.antibytes.kmock.mock.relaxVoidFunction internal class PropertyPlatformMock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, diff --git a/kmock-processor/src/test/resources/generatorTest/RelaxedExpected.kt b/kmock-processor/src/test/resources/generatorTest/RelaxedExpected.kt index 1d07fc56..78b3fff1 100644 --- a/kmock-processor/src/test/resources/generatorTest/RelaxedExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/RelaxedExpected.kt @@ -5,12 +5,12 @@ import kotlin.Any import kotlin.Boolean import kotlin.String import kotlin.Unit -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery -import tech.antibytes.kmock.relaxVoidFunction +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery +import tech.antibytes.kmock.mock.relaxVoidFunction internal class RelaxedMock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, diff --git a/kmock-processor/src/test/resources/generatorTest/SyncFunctionCommonExpected.kt b/kmock-processor/src/test/resources/generatorTest/SyncFunctionCommonExpected.kt index 6ecfef80..d5ccbcb0 100644 --- a/kmock-processor/src/test/resources/generatorTest/SyncFunctionCommonExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/SyncFunctionCommonExpected.kt @@ -5,12 +5,12 @@ import kotlin.Any import kotlin.Boolean import kotlin.Int import kotlin.Unit -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery -import tech.antibytes.kmock.relaxVoidFunction +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery +import tech.antibytes.kmock.mock.relaxVoidFunction internal class SyncFunctionCommonMock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, diff --git a/kmock-processor/src/test/resources/generatorTest/SyncFunctionPlatformExpected.kt b/kmock-processor/src/test/resources/generatorTest/SyncFunctionPlatformExpected.kt index ab5a007f..8034a9f5 100644 --- a/kmock-processor/src/test/resources/generatorTest/SyncFunctionPlatformExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/SyncFunctionPlatformExpected.kt @@ -4,12 +4,12 @@ import kotlin.Any import kotlin.Boolean import kotlin.Int import kotlin.Unit -import tech.antibytes.kmock.AsyncFunMockery import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector -import tech.antibytes.kmock.PropertyMockery -import tech.antibytes.kmock.SyncFunMockery -import tech.antibytes.kmock.relaxVoidFunction +import tech.antibytes.kmock.mock.AsyncFunMockery +import tech.antibytes.kmock.mock.PropertyMockery +import tech.antibytes.kmock.mock.SyncFunMockery +import tech.antibytes.kmock.mock.relaxVoidFunction internal class SyncFunctionPlatformMock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/KMockContract.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/KMockContract.kt index 1f9f0d2f..ba62ebdb 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/KMockContract.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/KMockContract.kt @@ -16,6 +16,10 @@ interface KMockContract { fun clear() } + fun interface Relaxer { + fun relax(id: String): T + } + interface FunMockery> : Mockery?> { var returnValue: ReturnValue var returnValues: List @@ -303,20 +307,24 @@ interface KMockContract { fun onSet(value: Value) } + fun interface Collector { + fun addReference(referredMock: Mockery<*, *>, referredCall: Int) + } + interface VerificationHandle { val id: String val callIndices: List } + fun interface MatcherConstraint { + fun matches(value: Any?): Boolean + } + data class Reference( val mockery: Mockery<*, *>, val callIndex: Int ) - fun interface Collector { - fun addReference(referredMock: Mockery<*, *>, referredCall: Int) - } - interface VerificationReferenceBuilder { fun ensureVerificationOf(vararg mocks: Mockery<*, *>) } @@ -336,10 +344,6 @@ interface KMockContract { fun clear() } - fun interface Relaxer { - fun relax(id: String): T - } - companion object { const val NOT_CALLED = "Call not found." const val TOO_LESS_CALLS = "Expected at least \$1 calls, but found only \$2." diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/AsyncFunMockery.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/AsyncFunMockery.kt similarity index 99% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/AsyncFunMockery.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/AsyncFunMockery.kt index de158494..473b48d9 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/AsyncFunMockery.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/AsyncFunMockery.kt @@ -4,8 +4,9 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector import tech.antibytes.kmock.KMockContract.Relaxer diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/FunMockery.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/FunMockery.kt similarity index 98% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/FunMockery.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/FunMockery.kt index 35c678c0..a0848a0d 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/FunMockery.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/FunMockery.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.collections.IsoMutableList import co.touchlab.stately.collections.sharedMutableListOf @@ -12,6 +12,7 @@ import kotlinx.atomicfu.AtomicInt import kotlinx.atomicfu.AtomicRef import kotlinx.atomicfu.atomic import kotlinx.atomicfu.update +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector import tech.antibytes.kmock.KMockContract.Relaxer import tech.antibytes.util.test.MockError diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/PropertyMockery.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/PropertyMockery.kt similarity index 98% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/PropertyMockery.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/PropertyMockery.kt index 33c66292..aad450d9 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/PropertyMockery.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/PropertyMockery.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.collections.IsoMutableList import co.touchlab.stately.collections.sharedMutableListOf @@ -12,6 +12,7 @@ import kotlinx.atomicfu.AtomicInt import kotlinx.atomicfu.AtomicRef import kotlinx.atomicfu.atomic import kotlinx.atomicfu.update +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector import tech.antibytes.kmock.KMockContract.GetOrSet import tech.antibytes.kmock.KMockContract.Relaxer diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/SyncFunMockery.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/SyncFunMockery.kt similarity index 99% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/SyncFunMockery.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/SyncFunMockery.kt index bf9a8bb5..534581df 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/SyncFunMockery.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/SyncFunMockery.kt @@ -4,8 +4,9 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector import tech.antibytes.kmock.KMockContract.Relaxer diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/UnitFunRelaxer.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/UnitFunRelaxer.kt similarity index 89% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/UnitFunRelaxer.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/UnitFunRelaxer.kt index 5b2cba59..2cd6a008 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/UnitFunRelaxer.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/mock/UnitFunRelaxer.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock inline fun relaxVoidFunction(): T? { return if (T::class == Unit::class) { diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/ArgumentMatcher.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/ArgumentMatcher.kt similarity index 96% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/ArgumentMatcher.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/ArgumentMatcher.kt index ba152fab..624b3f35 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/ArgumentMatcher.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/ArgumentMatcher.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification import tech.antibytes.kmock.KMockContract.GetOrSet diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/MockeryAssertion.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/MockeryAssertion.kt similarity index 95% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/MockeryAssertion.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/MockeryAssertion.kt index bbb9ebe8..ed913427 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/MockeryAssertion.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/MockeryAssertion.kt @@ -4,8 +4,9 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.FunMockery fun FunMockery<*, *>.assertHasBeenCalled( diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/NonfreezingVerifier.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/NonfreezingVerifier.kt similarity index 89% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/NonfreezingVerifier.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/NonfreezingVerifier.kt index ca859814..56bedd21 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/NonfreezingVerifier.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/NonfreezingVerifier.kt @@ -4,8 +4,9 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Mockery import tech.antibytes.kmock.KMockContract.Reference diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/Operators.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/Operators.kt similarity index 94% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/Operators.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/Operators.kt index ba0e531a..550c8c2a 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/Operators.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/Operators.kt @@ -4,7 +4,9 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification + +import tech.antibytes.kmock.KMockContract infix fun KMockContract.VerificationHandle.union( other: KMockContract.VerificationHandle diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/Verification.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/Verification.kt similarity index 99% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/Verification.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/Verification.kt index 3fc64837..2771b16c 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/Verification.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/Verification.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification import tech.antibytes.kmock.KMockContract.Companion.CALL_NOT_FOUND import tech.antibytes.kmock.KMockContract.Companion.MISMATCHING_CALL_IDX diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationChainBuilder.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/VerificationChainBuilder.kt similarity index 93% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationChainBuilder.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/VerificationChainBuilder.kt index 9a1e43df..7fd3b383 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationChainBuilder.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/VerificationChainBuilder.kt @@ -4,9 +4,10 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification import co.touchlab.stately.collections.IsoMutableList +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.VerificationHandle internal class VerificationChainBuilder : diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationHandle.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/VerificationHandle.kt similarity index 76% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationHandle.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/VerificationHandle.kt index d0bca2e0..e64beeec 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationHandle.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/VerificationHandle.kt @@ -4,7 +4,9 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification + +import tech.antibytes.kmock.KMockContract data class VerificationHandle( override val id: String, diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationHandleFactory.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/VerificationHandleFactory.kt similarity index 97% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationHandleFactory.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/VerificationHandleFactory.kt index 06b69d80..4cc71c79 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/VerificationHandleFactory.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/VerificationHandleFactory.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification import tech.antibytes.kmock.KMockContract.FunMockery import tech.antibytes.kmock.KMockContract.Mockery diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/Verifier.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/Verifier.kt similarity index 90% rename from kmock/src/commonMain/kotlin/tech/antibytes/kmock/Verifier.kt rename to kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/Verifier.kt index 21b434df..67ee1910 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/Verifier.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/Verifier.kt @@ -4,10 +4,11 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification import co.touchlab.stately.collections.IsoMutableList import co.touchlab.stately.collections.sharedMutableListOf +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Mockery import tech.antibytes.kmock.KMockContract.Reference diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/any.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/any.kt new file mode 100644 index 00000000..e0810262 --- /dev/null +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/any.kt @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. + * + * Use of this source code is governed by Apache v2.0 + */ + +@file:Suppress("ClassName") + +package tech.antibytes.kmock.verification.contraints + +import tech.antibytes.kmock.KMockContract +import kotlin.reflect.KClass + +class any( + private val expected: KClass<*>? = null +) : KMockContract.MatcherConstraint { + override fun matches(value: Any?): Boolean { + return when { + expected == null -> true + value == null -> false + else -> value::class == expected + } + } +} diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/eq.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/eq.kt new file mode 100644 index 00000000..c6245a87 --- /dev/null +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/eq.kt @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. + * + * Use of this source code is governed by Apache v2.0 + */ + +@file:Suppress("ClassName") + +package tech.antibytes.kmock.verification.contraints + +import tech.antibytes.kmock.KMockContract +import kotlin.reflect.KClass + +class eq( + private val expected: Any? +) : KMockContract.MatcherConstraint { + override fun matches(value: Any?): Boolean = expected == value +} diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNot.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNot.kt new file mode 100644 index 00000000..181e93e8 --- /dev/null +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNot.kt @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. + * + * Use of this source code is governed by Apache v2.0 + */ + +@file:Suppress("ClassName") + +package tech.antibytes.kmock.verification.contraints + +import tech.antibytes.kmock.KMockContract +import kotlin.reflect.KClass + +class isNot( + private val illegal: Any? = null +) : KMockContract.MatcherConstraint { + override fun matches(value: Any?): Boolean = illegal != value +} diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNotSame.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNotSame.kt new file mode 100644 index 00000000..3eca053a --- /dev/null +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNotSame.kt @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. + * + * Use of this source code is governed by Apache v2.0 + */ + +@file:Suppress("ClassName") + +package tech.antibytes.kmock.verification.contraints + +import tech.antibytes.kmock.KMockContract + +class isNotSame( + private val illegal: Any? +) : KMockContract.MatcherConstraint { + override fun matches(value: Any?): Boolean = illegal !== value +} diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isSame.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isSame.kt new file mode 100644 index 00000000..97e5bde8 --- /dev/null +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isSame.kt @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. + * + * Use of this source code is governed by Apache v2.0 + */ + +@file:Suppress("ClassName") + +package tech.antibytes.kmock.verification.contraints + +import tech.antibytes.kmock.KMockContract + +class isSame( + private val expected: Any? +) : KMockContract.MatcherConstraint { + override fun matches(value: Any?): Boolean = expected === value +} diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockeryInvocationsSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockeryInvocationsSpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockeryInvocationsSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockeryInvocationsSpec.kt index bfbbe0ec..45dd2a6a 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockeryInvocationsSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockeryInvocationsSpec.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.concurrency.AtomicReference import kotlinx.atomicfu.AtomicRef diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockerySpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockerySpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockerySpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockerySpec.kt index 8e861209..bd5fa5ec 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockerySpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockerySpec.kt @@ -4,10 +4,11 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.concurrency.AtomicReference import co.touchlab.stately.concurrency.value +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector import tech.antibytes.util.test.MockError import tech.antibytes.util.test.annotations.IgnoreJs diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockeryUnfrozenInvocationsSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockeryUnfrozenInvocationsSpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockeryUnfrozenInvocationsSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockeryUnfrozenInvocationsSpec.kt index c400f7a9..f77f3e54 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockeryUnfrozenInvocationsSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockeryUnfrozenInvocationsSpec.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.concurrency.AtomicReference import kotlinx.atomicfu.AtomicRef diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockeryUnfrozenSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockeryUnfrozenSpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockeryUnfrozenSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockeryUnfrozenSpec.kt index 9ca4271d..77330d74 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/AsyncFunMockeryUnfrozenSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/AsyncFunMockeryUnfrozenSpec.kt @@ -4,10 +4,11 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.concurrency.AtomicReference import co.touchlab.stately.concurrency.value +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector import tech.antibytes.util.test.MockError import tech.antibytes.util.test.annotations.IgnoreJs diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/PropertyMockerySpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/PropertyMockerySpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/PropertyMockerySpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/PropertyMockerySpec.kt index 8790b5c2..cd45df0e 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/PropertyMockerySpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/PropertyMockerySpec.kt @@ -4,12 +4,13 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.concurrency.AtomicReference import co.touchlab.stately.concurrency.value import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.launch +import tech.antibytes.kmock.KMockContract import tech.antibytes.util.test.MockError import tech.antibytes.util.test.annotations.IgnoreJs import tech.antibytes.util.test.annotations.JsOnly diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/PropertyMockeryUnfrozenSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/PropertyMockeryUnfrozenSpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/PropertyMockeryUnfrozenSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/PropertyMockeryUnfrozenSpec.kt index 957a9066..f4357435 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/PropertyMockeryUnfrozenSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/PropertyMockeryUnfrozenSpec.kt @@ -4,10 +4,11 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.concurrency.AtomicReference import co.touchlab.stately.concurrency.value +import tech.antibytes.kmock.KMockContract import tech.antibytes.util.test.MockError import tech.antibytes.util.test.annotations.IgnoreJs import tech.antibytes.util.test.annotations.JsOnly diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockeryInvocationsSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockeryInvocationsSpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockeryInvocationsSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockeryInvocationsSpec.kt index 67bdb2c8..64026a7c 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockeryInvocationsSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockeryInvocationsSpec.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.concurrency.AtomicReference import kotlinx.atomicfu.AtomicRef diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockerySpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockerySpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockerySpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockerySpec.kt index 8047e95c..b8f0c235 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockerySpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockerySpec.kt @@ -4,12 +4,13 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.concurrency.AtomicReference import co.touchlab.stately.concurrency.value import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.launch +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector import tech.antibytes.util.test.MockError import tech.antibytes.util.test.annotations.IgnoreJs diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockeryUnfrozenInvocationsSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockeryUnfrozenInvocationsSpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockeryUnfrozenInvocationsSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockeryUnfrozenInvocationsSpec.kt index d88056d1..6f8fed49 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockeryUnfrozenInvocationsSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockeryUnfrozenInvocationsSpec.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.concurrency.AtomicReference import kotlinx.atomicfu.AtomicRef diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockeryUnfrozenSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockeryUnfrozenSpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockeryUnfrozenSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockeryUnfrozenSpec.kt index 426e7a84..5553e7ab 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/SyncFunMockeryUnfrozenSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/SyncFunMockeryUnfrozenSpec.kt @@ -4,10 +4,11 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import co.touchlab.stately.concurrency.AtomicReference import co.touchlab.stately.concurrency.value +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector import tech.antibytes.util.test.MockError import tech.antibytes.util.test.annotations.IgnoreJs diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/UnitFunRelaxerSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/UnitFunRelaxerSpec.kt similarity index 94% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/UnitFunRelaxerSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/UnitFunRelaxerSpec.kt index 9a189c7a..9395ff3f 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/UnitFunRelaxerSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/mock/UnitFunRelaxerSpec.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.mock import tech.antibytes.util.test.mustBe import kotlin.js.JsName diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/ArgumentMatcherSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/ArgumentMatcherSpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/ArgumentMatcherSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/ArgumentMatcherSpec.kt index b06ababf..3d5394ee 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/ArgumentMatcherSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/ArgumentMatcherSpec.kt @@ -4,8 +4,9 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification +import tech.antibytes.kmock.KMockContract import tech.antibytes.util.test.fixture.fixture import tech.antibytes.util.test.fixture.kotlinFixture import tech.antibytes.util.test.fixture.listFixture @@ -15,7 +16,7 @@ import kotlin.test.Test class ArgumentMatcherSpec { private val fixture = kotlinFixture() - + @Test @JsName("fn0") fun `Given hasBeenCalledWithVoid is called it returns true if the Array is null`() { diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/MockeryAssertionSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/MockeryAssertionSpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/MockeryAssertionSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/MockeryAssertionSpec.kt index 30a9ac0f..790c66a1 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/MockeryAssertionSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/MockeryAssertionSpec.kt @@ -4,8 +4,9 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification +import tech.antibytes.kmock.KMockContract import tech.antibytes.mock.FunMockeryStub import tech.antibytes.mock.PropertyMockeryStub import tech.antibytes.util.test.fixture.fixture diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/NonFreezingVerifierSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/NonFreezingVerifierSpec.kt similarity index 95% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/NonFreezingVerifierSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/NonFreezingVerifierSpec.kt index c0b790a1..5877c168 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/NonFreezingVerifierSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/NonFreezingVerifierSpec.kt @@ -4,8 +4,9 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification +import tech.antibytes.kmock.KMockContract import tech.antibytes.mock.FunMockeryStub import tech.antibytes.util.test.fixture.fixture import tech.antibytes.util.test.fixture.kotlinFixture diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/OperationSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/OperationSpec.kt similarity index 98% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/OperationSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/OperationSpec.kt index 9ab52f76..d9006f7a 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/OperationSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/OperationSpec.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification import tech.antibytes.util.test.fixture.fixture import tech.antibytes.util.test.fixture.kotlinFixture diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationChainBuilderSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationChainBuilderSpec.kt similarity index 97% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationChainBuilderSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationChainBuilderSpec.kt index 503effc5..4c202e18 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationChainBuilderSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationChainBuilderSpec.kt @@ -4,9 +4,10 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification import VerificationChainBuilderStub +import tech.antibytes.kmock.KMockContract import tech.antibytes.mock.FunMockeryStub import tech.antibytes.util.test.fixture.PublicApi import tech.antibytes.util.test.fixture.fixture diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationHandleFactorySpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationHandleFactorySpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationHandleFactorySpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationHandleFactorySpec.kt index 35f81ef9..1b6ef19c 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationHandleFactorySpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationHandleFactorySpec.kt @@ -4,9 +4,10 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification import VerificationChainBuilderStub +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.VerificationHandle import tech.antibytes.mock.FunMockeryStub import tech.antibytes.mock.PropertyMockeryStub @@ -55,7 +56,7 @@ class VerificationHandleFactorySpec { actual mustBe VerificationHandle(name, listOf(0)) capturedIndex mustBe 0 } - + @Test @JsName("fn2") fun `Given hasBeenCalledWith is called with a FunMockery it returns a VerficationHandle which contains no matches if nothing matches`() { diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationSpec.kt similarity index 99% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationSpec.kt index 424b6e2a..72b77974 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerificationSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationSpec.kt @@ -4,7 +4,7 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification import tech.antibytes.kmock.KMockContract.Reference import tech.antibytes.mock.FunMockeryStub diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerifierSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerifierSpec.kt similarity index 96% rename from kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerifierSpec.kt rename to kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerifierSpec.kt index 5a0f26e8..b9b42576 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/VerifierSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerifierSpec.kt @@ -4,8 +4,9 @@ * Use of this source code is governed by Apache v2.0 */ -package tech.antibytes.kmock +package tech.antibytes.kmock.verification +import tech.antibytes.kmock.KMockContract import tech.antibytes.mock.FunMockeryStub import tech.antibytes.util.test.coroutine.AsyncTestReturnValue import tech.antibytes.util.test.coroutine.TestScopeDispatcher diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/AnySpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/AnySpec.kt new file mode 100644 index 00000000..89caf3b9 --- /dev/null +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/AnySpec.kt @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. + * + * Use of this source code is governed by Apache v2.0 + */ + +package tech.antibytes.kmock.verification.contraints + +import tech.antibytes.kmock.KMockContract +import tech.antibytes.util.test.fixture.fixture +import tech.antibytes.util.test.fixture.kotlinFixture +import tech.antibytes.util.test.fulfils +import tech.antibytes.util.test.mustBe +import kotlin.js.JsName +import kotlin.test.Test + +class AnySpec { + private val fixture = kotlinFixture() + + @Test + @JsName("fn0") + fun `any fulfils MatcherConstraint`() { + any() fulfils KMockContract.MatcherConstraint::class + } + + @Test + @JsName("fn1") + fun `Given any is called it returns true regardless of the value`() { + // When + val actual = any().matches(fixture.fixture()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn2") + fun `Given any is called it returns false if the given KClass and the call KClass are not matching`() { + // Given + val value = true + + // When + val actual = any(Any::class).matches(value) + + // Then + actual mustBe false + } + + @Test + @JsName("fn2") + fun `Given any is called it returns false if the given KClass and the call was null`() { + // When + val actual = any(Any::class).matches(null) + + // Then + actual mustBe false + } + + @Test + @JsName("fn3") + fun `Given any is called it returns true if the given KClass and the call KClass are matching`() { + // Given + val value = true + + // When + val actual = any(Boolean::class).matches(value) + + // Then + actual mustBe true + } +} diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/EqualSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/EqualSpec.kt new file mode 100644 index 00000000..7bd24b28 --- /dev/null +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/EqualSpec.kt @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. + * + * Use of this source code is governed by Apache v2.0 + */ + +package tech.antibytes.kmock.verification.contraints + +import tech.antibytes.kmock.KMockContract +import tech.antibytes.util.test.fixture.fixture +import tech.antibytes.util.test.fixture.kotlinFixture +import tech.antibytes.util.test.fulfils +import tech.antibytes.util.test.mustBe +import kotlin.js.JsName +import kotlin.test.Test + +class EqualSpec { + private val fixture = kotlinFixture() + + @Test + @JsName("fn0") + fun `eq fulfils MatcherConstraint`() { + eq(fixture.fixture()) fulfils KMockContract.MatcherConstraint::class + } + + @Test + @JsName("fn1") + fun `Given eq is called it returns false if the given Value and the call Value are not the matching`() { + // Given + val value: Int = fixture.fixture() + + // When + val actual = eq(value).matches(fixture.fixture()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn2") + fun `Given eq is called it returns true if the given Value and the call Value are the same`() { + // Given + val value: Int = fixture.fixture() + + // When + val actual = eq(value).matches(value) + + // Then + actual mustBe true + } +} diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsNotSameSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsNotSameSpec.kt new file mode 100644 index 00000000..8a0c333a --- /dev/null +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsNotSameSpec.kt @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. + * + * Use of this source code is governed by Apache v2.0 + */ + +package tech.antibytes.kmock.verification.contraints + +import tech.antibytes.kmock.KMockContract +import tech.antibytes.util.test.fixture.fixture +import tech.antibytes.util.test.fixture.kotlinFixture +import tech.antibytes.util.test.fulfils +import tech.antibytes.util.test.mustBe +import kotlin.js.JsName +import kotlin.test.Test + +class IsNotSameSpec { + private val fixture = kotlinFixture() + + @Test + @JsName("fn0") + fun `isNotSame fulfils MatcherConstraint`() { + isNotSame(fixture.fixture()) fulfils KMockContract.MatcherConstraint::class + } + + @Test + @JsName("fn1") + fun `Given isNotSame is called it returns false if the given Value and the call Value are not the same`() { + // Given + val value: Any = fixture.fixture() + + // When + val actual = isNotSame(value).matches(fixture.fixture()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn2") + fun `Given isNotSame is called it returns true if the given Value and the call Value are the same`() { + // Given + val value: Any? = fixture.fixture() + + // When + val actual = isNotSame(value).matches(value) + + // Then + actual mustBe false + } +} diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsNotSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsNotSpec.kt new file mode 100644 index 00000000..d599079d --- /dev/null +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsNotSpec.kt @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. + * + * Use of this source code is governed by Apache v2.0 + */ + +package tech.antibytes.kmock.verification.contraints + +import tech.antibytes.kmock.KMockContract +import tech.antibytes.util.test.fixture.fixture +import tech.antibytes.util.test.fixture.kotlinFixture +import tech.antibytes.util.test.fulfils +import tech.antibytes.util.test.mustBe +import kotlin.js.JsName +import kotlin.test.Test + +class IsNotSpec { + private val fixture = kotlinFixture() + + @Test + @JsName("fn0") + fun `isNot fulfils MatcherConstraint`() { + isNot(fixture.fixture()) fulfils KMockContract.MatcherConstraint::class + } + + @Test + @JsName("fn1") + fun `Given isNot is called it returns false if the given Value and the call Value are not the matching`() { + // Given + val value: Int = fixture.fixture() + + // When + val actual = isNot(value).matches(fixture.fixture()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn2") + fun `Given isNot is called it returns true if the given Value and the call Value are the same`() { + // Given + val value: Int = fixture.fixture() + + // When + val actual = isNot(value).matches(value) + + // Then + actual mustBe false + } +} diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsSameSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsSameSpec.kt new file mode 100644 index 00000000..f07302b6 --- /dev/null +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/IsSameSpec.kt @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved. + * + * Use of this source code is governed by Apache v2.0 + */ + +package tech.antibytes.kmock.verification.contraints + +import tech.antibytes.kmock.KMockContract +import tech.antibytes.util.test.fixture.fixture +import tech.antibytes.util.test.fixture.kotlinFixture +import tech.antibytes.util.test.fulfils +import tech.antibytes.util.test.mustBe +import kotlin.js.JsName +import kotlin.test.Test + +class IsSameSpec { + private val fixture = kotlinFixture() + + @Test + @JsName("fn0") + fun `isSame fulfils MatcherConstraint`() { + isSame(fixture.fixture()) fulfils KMockContract.MatcherConstraint::class + } + + @Test + @JsName("fn1") + fun `Given isSame is called it returns false if the given Value and the call Value are not the same`() { + // Given + val value: Any = fixture.fixture() + + // When + val actual = isSame(value).matches(fixture.fixture()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn2") + fun `Given isSame is called it returns true if the given Value and the call Value are the same`() { + // Given + val value: Any? = fixture.fixture() + + // When + val actual = isSame(value).matches(value) + + // Then + actual mustBe true + } +} From ee3b487016336070d5dfa14ad0254c507843b21e Mon Sep 17 00:00:00 2001 From: Matthias Geisler Date: Sun, 27 Feb 2022 14:54:06 +0100 Subject: [PATCH 3/3] Wire Contraints into ArgumentMatchers --- kmock/build.gradle.kts | 7 + .../tech/antibytes/kmock/KMockContract.kt | 2 +- .../kmock/verification/ArgumentMatcher.kt | 76 +++- .../kmock/verification/contraints/any.kt | 6 +- .../kmock/verification/contraints/eq.kt | 23 +- .../kmock/verification/contraints/isNot.kt | 3 +- .../verification/contraints/isNotSame.kt | 2 +- .../kmock/verification/contraints/isSame.kt | 2 +- .../kmock/verification/ArgumentMatcherSpec.kt | 167 ++++++--- .../VerificationHandleFactorySpec.kt | 8 +- .../kmock/verification/contraints/AnySpec.kt | 4 +- .../verification/contraints/EqualSpec.kt | 349 +++++++++++++++++- 12 files changed, 574 insertions(+), 75 deletions(-) diff --git a/kmock/build.gradle.kts b/kmock/build.gradle.kts index 242a34e2..4deb4c35 100644 --- a/kmock/build.gradle.kts +++ b/kmock/build.gradle.kts @@ -53,6 +53,13 @@ kotlin { ).contains(sourceSet.name) } + all { + languageSettings.apply { + optIn("kotlin.ExperimentalUnsignedTypes") + optIn("kotlin.RequiresOptIn") + } + } + val commonMain by getting { dependencies { implementation(Dependency.multiplatform.kotlin.common) diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/KMockContract.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/KMockContract.kt index ba62ebdb..d5b248bf 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/KMockContract.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/KMockContract.kt @@ -317,7 +317,7 @@ interface KMockContract { } fun interface MatcherConstraint { - fun matches(value: Any?): Boolean + fun matches(actual: Any?): Boolean } data class Reference( diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/ArgumentMatcher.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/ArgumentMatcher.kt index 624b3f35..70032a09 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/ArgumentMatcher.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/ArgumentMatcher.kt @@ -6,27 +6,92 @@ package tech.antibytes.kmock.verification +import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.GetOrSet +import tech.antibytes.kmock.verification.contraints.eq internal fun Array?.hasBeenCalledWithVoid(): Boolean = this == null +private fun wrapValue(value: Any?): KMockContract.MatcherConstraint { + return if (value is KMockContract.MatcherConstraint) { + value + } else { + eq(value) + } +} + internal fun Array?.hasBeenCalledWith(vararg values: Any?): Boolean { return when { this == null -> values.isEmpty() values.isEmpty() -> true - else -> values.all { value -> this.contains(value) } + else -> { + var lastMatch = 0 + + for (value in values) { + var matched = false + val expected = wrapValue(value) + + for (idx in lastMatch until this.size) { + val actual = this[idx] + + if (expected.matches(actual)) { + matched = true + lastMatch = idx + break + } + } + + if (!matched) { + return false + } + } + + return true + } } } internal fun Array?.hasBeenStrictlyCalledWith(vararg values: Any?): Boolean { - return this?.contentDeepEquals(values) ?: values.isEmpty() + return when { + this == null && values.isEmpty() -> true + this == null -> false + values.size != this.size -> false + else -> { + + for (idx in values.indices) { + val expected = wrapValue(values[idx]) + + if (!expected.matches(this[idx])) { + return false + } + } + + return true + } + } } internal fun Array?.hasBeenCalledWithout(vararg values: Any?): Boolean { return if (this == null) { values.isNotEmpty() } else { - values.none { value -> this.contains(value) } + for (value in values) { + var matched = false + val expected = wrapValue(value) + + for (actual in this) { + if (expected.matches(actual)) { + matched = true + break + } + } + + if (matched) { + return false + } + } + + return true } } @@ -37,6 +102,9 @@ internal fun GetOrSet.wasSet(): Boolean = this is GetOrSet.Set internal fun GetOrSet.wasSetTo(value: Any?): Boolean { return when (this) { !is GetOrSet.Set -> false - else -> this.value == value + else -> { + val expected = wrapValue(value) + return expected.matches(this.value) + } } } diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/any.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/any.kt index e0810262..32b07c58 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/any.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/any.kt @@ -14,11 +14,11 @@ import kotlin.reflect.KClass class any( private val expected: KClass<*>? = null ) : KMockContract.MatcherConstraint { - override fun matches(value: Any?): Boolean { + override fun matches(actual: Any?): Boolean { return when { expected == null -> true - value == null -> false - else -> value::class == expected + actual == null -> false + else -> actual::class == expected } } } diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/eq.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/eq.kt index c6245a87..ccc2f524 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/eq.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/eq.kt @@ -9,10 +9,29 @@ package tech.antibytes.kmock.verification.contraints import tech.antibytes.kmock.KMockContract -import kotlin.reflect.KClass +@OptIn(ExperimentalUnsignedTypes::class) class eq( private val expected: Any? ) : KMockContract.MatcherConstraint { - override fun matches(value: Any?): Boolean = expected == value + override fun matches(actual: Any?): Boolean { + return when { + expected is Array<*> && actual is Array<*> -> expected.contentDeepEquals(actual) + expected is ByteArray && actual is ByteArray -> expected.contentEquals(actual) + expected is ShortArray && actual is ShortArray -> expected.contentEquals(actual) + expected is IntArray && actual is IntArray -> expected.contentEquals(actual) + expected is LongArray && actual is LongArray -> expected.contentEquals(actual) + expected is FloatArray && actual is FloatArray -> expected.contentEquals(actual) + expected is DoubleArray && actual is DoubleArray -> expected.contentEquals(actual) + expected is CharArray && actual is CharArray -> expected.contentEquals(actual) + expected is BooleanArray && actual is BooleanArray -> expected.contentEquals(actual) + + expected is UByteArray && actual is UByteArray -> expected.contentEquals(actual) + expected is UShortArray && actual is UShortArray -> expected.contentEquals(actual) + expected is UIntArray && actual is UIntArray -> expected.contentEquals(actual) + expected is ULongArray && actual is ULongArray -> expected.contentEquals(actual) + + else -> expected == actual + } + } } diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNot.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNot.kt index 181e93e8..8886672c 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNot.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNot.kt @@ -9,10 +9,9 @@ package tech.antibytes.kmock.verification.contraints import tech.antibytes.kmock.KMockContract -import kotlin.reflect.KClass class isNot( private val illegal: Any? = null ) : KMockContract.MatcherConstraint { - override fun matches(value: Any?): Boolean = illegal != value + override fun matches(actual: Any?): Boolean = illegal != actual } diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNotSame.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNotSame.kt index 3eca053a..9a5a4310 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNotSame.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isNotSame.kt @@ -13,5 +13,5 @@ import tech.antibytes.kmock.KMockContract class isNotSame( private val illegal: Any? ) : KMockContract.MatcherConstraint { - override fun matches(value: Any?): Boolean = illegal !== value + override fun matches(actual: Any?): Boolean = illegal !== actual } diff --git a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isSame.kt b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isSame.kt index 97e5bde8..dce25b72 100644 --- a/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isSame.kt +++ b/kmock/src/commonMain/kotlin/tech/antibytes/kmock/verification/contraints/isSame.kt @@ -13,5 +13,5 @@ import tech.antibytes.kmock.KMockContract class isSame( private val expected: Any? ) : KMockContract.MatcherConstraint { - override fun matches(value: Any?): Boolean = expected === value + override fun matches(actual: Any?): Boolean = expected === actual } diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/ArgumentMatcherSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/ArgumentMatcherSpec.kt index 3d5394ee..c70b9ff0 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/ArgumentMatcherSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/ArgumentMatcherSpec.kt @@ -7,6 +7,10 @@ package tech.antibytes.kmock.verification import tech.antibytes.kmock.KMockContract +import tech.antibytes.kmock.verification.contraints.eq +import tech.antibytes.kmock.verification.contraints.isNot +import tech.antibytes.kmock.verification.contraints.isNotSame +import tech.antibytes.kmock.verification.contraints.isSame import tech.antibytes.util.test.fixture.fixture import tech.antibytes.util.test.fixture.kotlinFixture import tech.antibytes.util.test.fixture.listFixture @@ -43,6 +47,19 @@ class ArgumentMatcherSpec { actual mustBe false } + @Test + @JsName("fn2") + fun `Given hasBeenCalledWith is called with an Argument it returns true if the Array is null and the Arguments are empty`() { + // Given + val array = null + + // When + val actual = array.hasBeenCalledWith() + + // Then + actual mustBe true + } + @Test @JsName("fn3") fun `Given hasBeenCalledWith is called with an Argument it returns false if the Array contains not the given Argument`() { @@ -60,10 +77,10 @@ class ArgumentMatcherSpec { @JsName("fn4") fun `Given hasBeenCalledWith is called with an Argument it returns true if the Array contains the given Argument`() { // Given - val array = fixture.listFixture().toTypedArray() + val array = fixture.listFixture(size = 5).toTypedArray() // When - val actual = array.hasBeenCalledWith(array.first()) + val actual = array.hasBeenCalledWith(array.first(), array[2]) // Then actual mustBe true @@ -71,6 +88,19 @@ class ArgumentMatcherSpec { @Test @JsName("fn5") + fun `Given hasBeenCalledWith is called with an Argument it returns true if the Array contains the given Argument while respecting the order`() { + // Given + val array = fixture.listFixture(size = 5).toTypedArray() + + // When + val actual = array.hasBeenCalledWith(array[2], array.first()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn6") fun `Given hasBeenCalledWith is called without Arguments void it returns true if the Array contains Arguments`() { // Given val array = fixture.listFixture().toTypedArray() @@ -83,7 +113,7 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn6") + @JsName("fn7") fun `Given hasBeenCalledWith is called without Arguments void it returns true if the Array is null`() { // Given val array = null @@ -96,7 +126,7 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn7") + @JsName("fn8") fun `Given hasBeenCalledWith is called with Arguments it returns false if the Array is null`() { // Given val array = null @@ -109,7 +139,7 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn8") + @JsName("fn9") fun `Given hasBeenCalledWith is called with Arguments it returns false if the Array contains not all of given Arguments`() { // Given val array = fixture.listFixture(size = 8).toTypedArray() @@ -122,39 +152,28 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn9") + @JsName("fn10") fun `Given hasBeenCalledWith is called with Arguments it returns true if the Array contains all of given Arguments`() { // Given val array = fixture.listFixture(size = 8).toTypedArray() // When - val actual = array.hasBeenCalledWith(array[0], array[1], array[2], array[3]) + val actual = array.hasBeenCalledWith(*array) // Then actual mustBe true } - @Test - @JsName("fn10") - fun `Given hasBeenStrictlyCalledWith is called with an Argument it returns false if the Array matches not the given Argument`() { - // Given - val array = fixture.listFixture().toTypedArray() - - // When - val actual = array.hasBeenStrictlyCalledWith(fixture.fixture()) - - // Then - actual mustBe false - } - @Test @JsName("fn11") - fun `Given hasBeenStrictlyCalledWith is called with an Argument it returns true if the Array matches the given Argument`() { + fun `Given hasBeenCalledWith is called with Arguments it returns true while using Constraints`() { // Given - val array = fixture.listFixture(size = 1).toTypedArray() + val array = fixture.listFixture(size = 8).toTypedArray() // When - val actual = array.hasBeenStrictlyCalledWith(array.first()) + val actual = array.hasBeenCalledWith( + *(array.map { value -> isSame(value) }.toTypedArray()) + ) // Then actual mustBe true @@ -162,25 +181,25 @@ class ArgumentMatcherSpec { @Test @JsName("fn12") - fun `Given hasBeenStrictlyCalledWith is called without Arguments void it returns false if the Array has Arguments`() { + fun `Given hasBeenStrictlyCalledWith is called with an Argument it returns true if the Array is null and no values were given`() { // Given - val array = fixture.listFixture(size = 1).toTypedArray() + val array = null // When val actual = array.hasBeenStrictlyCalledWith() // Then - actual mustBe false + actual mustBe true } @Test @JsName("fn13") - fun `Given hasBeenStrictlyCalledWith is called witg Arguments void it returns false if the Array is null`() { + fun `Given hasBeenStrictlyCalledWith is called with an Argument it returns false if the Array is null and values were given`() { // Given val array = null // When - val actual = array.hasBeenStrictlyCalledWith(fixture.fixture()) + val actual = array.hasBeenStrictlyCalledWith(fixture.fixture()) // Then actual mustBe false @@ -188,25 +207,25 @@ class ArgumentMatcherSpec { @Test @JsName("fn14") - fun `Given hasBeenStrictlyCalledWith is called without Arguments void it returns false if the Array is null`() { + fun `Given hasBeenStrictlyCalledWith is called with an Argument it returns false if the Array and Value size does not match`() { // Given - val array = null + val array = fixture.listFixture(size = 5).toTypedArray() // When - val actual = array.hasBeenStrictlyCalledWith() + val actual = array.hasBeenStrictlyCalledWith(fixture.fixture()) // Then - actual mustBe true + actual mustBe false } @Test @JsName("fn15") - fun `Given hasBeenStrictlyCalledWith is called with Arguments it returns false if the Array matches not exactly the given Arguments`() { + fun `Given hasBeenStrictlyCalledWith is called with an Argument it returns false if the Array and Value do not match`() { // Given - val array = fixture.listFixture(size = 8).toTypedArray() + val array = fixture.listFixture(size = 5).toTypedArray() // When - val actual = array.hasBeenStrictlyCalledWith(array[0], array[1], array[2], array[3]) + val actual = array.hasBeenStrictlyCalledWith(fixture.listFixture(size = 5).toTypedArray()) // Then actual mustBe false @@ -214,19 +233,34 @@ class ArgumentMatcherSpec { @Test @JsName("fn16") - fun `Given hasBeenStrictlyCalledWith is called with Arguments it returns true if the Array matches exactly the given Arguments`() { + fun `Given hasBeenStrictlyCalledWith is called with an Argument it returns true if the Array and Value do match`() { // Given - val array = fixture.listFixture(size = 8).toTypedArray() + val array = fixture.listFixture(size = 5) // When - val actual = array.hasBeenStrictlyCalledWith(*array) + val actual = array.toTypedArray().hasBeenStrictlyCalledWith(array.toTypedArray()) // Then - actual mustBe true + actual mustBe false } @Test @JsName("fn17") + fun `Given hasBeenStrictlyCalledWith is called with Arguments it returns true while using Constraints`() { + // Given + val array = fixture.listFixture(size = 5).toTypedArray() + + // When + val actual = array.hasBeenStrictlyCalledWith( + *(array.map { value -> isNotSame(value) }.toTypedArray()) + ) + + // Then + actual mustBe false + } + + @Test + @JsName("fn18") fun `Given hasBeenCalledWithout is called with an Argument it returns false if the Array contains no Argument`() { // Given val array = null @@ -239,7 +273,7 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn18") + @JsName("fn19") fun `Given hasBeenCalledWithout is called with an Argument it returns true if the Array contains Arguments`() { // Given val array = null @@ -252,7 +286,7 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn19") + @JsName("fn20") fun `Given hasBeenCalledWithout is called with an Argument it returns true if the Array contains not the given Argument`() { // Given val array = fixture.listFixture().toTypedArray() @@ -265,7 +299,7 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn20") + @JsName("fn21") fun `Given hasBeenCalledWithout is called with an Argument it returns false if the Array contains the given Argument`() { // Given val array = fixture.listFixture().toTypedArray() @@ -278,7 +312,7 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn21") + @JsName("fn22") fun `Given hasBeenCalledWithout is called without Argument it returns true if the Array contains Argument`() { // Given val array = fixture.listFixture().toTypedArray() @@ -291,7 +325,7 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn22") + @JsName("fn23") fun `Given hasBeenCalledWithout is called with Arguments it returns false if the Array is null`() { // Given val array = fixture.listFixture().toTypedArray() @@ -304,7 +338,7 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn23") + @JsName("fn24") fun `Given hasBeenCalledWithout is called with Arguments it returns true if the Array none of given Arguments matches`() { // Given val array = fixture.listFixture(size = 8).toTypedArray() @@ -318,7 +352,7 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn24") + @JsName("fn25") fun `Given hasBeenCalledWithout is called with Arguments it returns false if the Array matches at least one of given Arguments`() { // Given val array = fixture.listFixture(size = 8).toTypedArray() @@ -336,45 +370,70 @@ class ArgumentMatcherSpec { } @Test - @JsName("fn25") + @JsName("fn26") + fun `Given hasBeenCalledWithout is called with Arguments it returns false while using Constraints`() { + // Given + val array = fixture.listFixture(size = 8).toTypedArray() + + // When + val actual = array.hasBeenCalledWithout( + isNot(fixture.fixture()), + isNot(fixture.fixture()), + isNot(fixture.fixture()), + eq(array[0]), + ) + + // Then + actual mustBe false + } + + @Test + @JsName("fn27") fun `Given wasGotten is called it returns false if it is attacht to Set`() { KMockContract.GetOrSet.Set(null).wasGotten() mustBe false } @Test - @JsName("fn26") + @JsName("fn28") fun `Given wasGotten is called it returns true if it is attacht to Get`() { KMockContract.GetOrSet.Get.wasGotten() mustBe true } @Test - @JsName("fn27") + @JsName("fn29") fun `Given wasSet is called it returns false if it is attacht to Get`() { KMockContract.GetOrSet.Get.wasSet() mustBe false } @Test - @JsName("fn28") + @JsName("fn30") fun `Given wasGotten is called it returns true if it is attacht to Set`() { KMockContract.GetOrSet.Set(null).wasSet() mustBe true } @Test - @JsName("fn29") + @JsName("fn31") fun `Given wasSetTo is called it returns false if it is attacht to Get`() { KMockContract.GetOrSet.Get.wasSetTo(null) mustBe false } @Test - @JsName("fn30") + @JsName("fn32") fun `Given wasSetTo is called it returns false if the values do not match`() { KMockContract.GetOrSet.Set(fixture.fixture()).wasSetTo(fixture.fixture()) mustBe false } @Test - @JsName("fn31") - fun `Given wasSetTo is called it returns true if the values do math`() { + @JsName("fn33") + fun `Given wasSetTo is called it returns true if the values do match`() { val value: Any = fixture.fixture() KMockContract.GetOrSet.Set(value).wasSetTo(value) mustBe true } + + @Test + @JsName("fn34") + fun `Given wasSetTo is called it returns false if the values do match while using Constraints`() { + val value: Any = fixture.fixture() + KMockContract.GetOrSet.Set(value).wasSetTo(isNotSame(value)) mustBe false + } } diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationHandleFactorySpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationHandleFactorySpec.kt index 1b6ef19c..78e115ce 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationHandleFactorySpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/VerificationHandleFactorySpec.kt @@ -99,7 +99,7 @@ class VerificationHandleFactorySpec { // Given val name: String = fixture.fixture() val mock = FunMockeryStub(name, 1) - val values = fixture.listFixture().toTypedArray() + val values = fixture.listFixture().toTypedArray().sortedArray() var capturedIndex: Int? = null mock.getArgumentsForCall = { givenIndex -> @@ -109,7 +109,7 @@ class VerificationHandleFactorySpec { } // When - val actual = mock.hasBeenCalledWith(*(values.sorted()).toTypedArray()) + val actual = mock.hasBeenCalledWith(*values) // Then actual mustBe VerificationHandle(name, listOf(0)) @@ -122,7 +122,7 @@ class VerificationHandleFactorySpec { // Given val name: String = fixture.fixture() val captured: MutableList = mutableListOf() - val values = fixture.listFixture().toTypedArray() + val values = fixture.listFixture().toTypedArray().sortedArray() val builder = VerificationChainBuilderStub(captured) val mock = FunMockeryStub(name, 1, verificationBuilderReference = builder) @@ -135,7 +135,7 @@ class VerificationHandleFactorySpec { } // When - mock.hasBeenCalledWith(*(values.sorted()).toTypedArray()) + mock.hasBeenCalledWith(*values) val actual = captured.first() // Then diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/AnySpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/AnySpec.kt index 89caf3b9..cd46a1bb 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/AnySpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/AnySpec.kt @@ -47,7 +47,7 @@ class AnySpec { } @Test - @JsName("fn2") + @JsName("fn3") fun `Given any is called it returns false if the given KClass and the call was null`() { // When val actual = any(Any::class).matches(null) @@ -57,7 +57,7 @@ class AnySpec { } @Test - @JsName("fn3") + @JsName("fn4") fun `Given any is called it returns true if the given KClass and the call KClass are matching`() { // Given val value = true diff --git a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/EqualSpec.kt b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/EqualSpec.kt index 7bd24b28..817cd741 100644 --- a/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/EqualSpec.kt +++ b/kmock/src/commonTest/kotlin/tech/antibytes/kmock/verification/contraints/EqualSpec.kt @@ -9,6 +9,7 @@ package tech.antibytes.kmock.verification.contraints import tech.antibytes.kmock.KMockContract import tech.antibytes.util.test.fixture.fixture import tech.antibytes.util.test.fixture.kotlinFixture +import tech.antibytes.util.test.fixture.listFixture import tech.antibytes.util.test.fulfils import tech.antibytes.util.test.mustBe import kotlin.js.JsName @@ -38,7 +39,7 @@ class EqualSpec { @Test @JsName("fn2") - fun `Given eq is called it returns true if the given Value and the call Value are the same`() { + fun `Given eq is called it returns true if the given Value and the call Value are matching`() { // Given val value: Int = fixture.fixture() @@ -48,4 +49,350 @@ class EqualSpec { // Then actual mustBe true } + + @Test + @JsName("fn3") + fun `Given eq is called it returns false if the given Value is an Array and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn4") + fun `Given eq is called it returns true if the given Value is an Array and the call Value are matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray()).matches(value.toTypedArray()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn5") + fun `Given eq is called it returns false if the given Value is an ByteArray and the call Value are not matching`() { + // Given + val value = fixture.fixture().encodeToByteArray() + + // When + val actual = eq(value).matches(fixture.fixture().encodeToByteArray()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn6") + fun `Given eq is called it returns true if the given Value is an ByteArray and the call Value are not matching`() { + // Given + val value = fixture.fixture() + + // When + val actual = eq(value.encodeToByteArray()).matches(value.encodeToByteArray()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn7") + fun `Given eq is called it returns false if the given Value is an ShortArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray().toShortArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray().toShortArray()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn8") + fun `Given eq is called it returns true if the given Value is an ShortArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray().toShortArray()).matches(value.toTypedArray().toShortArray()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn9") + fun `Given eq is called it returns false if the given Value is an IntArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray().toIntArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray().toIntArray()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn10") + fun `Given eq is called it returns true if the given Value is an IntArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray().toIntArray()).matches(value.toTypedArray().toIntArray()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn11") + fun `Given eq is called it returns false if the given Value is an LongArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray().toLongArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray().toLongArray()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn12") + fun `Given eq is called it returns true if the given Value is an LongArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray().toLongArray()).matches(value.toTypedArray().toLongArray()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn13") + fun `Given eq is called it returns false if the given Value is an FloatArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray().toFloatArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray().toFloatArray()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn14") + fun `Given eq is called it returns true if the given Value is an FloatArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray().toFloatArray()).matches(value.toTypedArray().toFloatArray()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn15") + fun `Given eq is called it returns false if the given Value is an DoubleArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray().toDoubleArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray().toDoubleArray()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn16") + fun `Given eq is called it returns true if the given Value is an DoubleArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray().toDoubleArray()).matches(value.toTypedArray().toDoubleArray()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn17") + fun `Given eq is called it returns false if the given Value is an CharArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray().toCharArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray().toCharArray()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn18") + fun `Given eq is called it returns true if the given Value is an CharArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray().toCharArray()).matches(value.toTypedArray().toCharArray()) + + // Then + actual mustBe true + } + + @Test + @JsName("fn19") + fun `Given eq is called it returns false if the given Value is an BooleanArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray().toBooleanArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray().toBooleanArray()) + + // Then + actual mustBe false + } + + @Test + @JsName("fn20") + fun `Given eq is called it returns true if the given Value is an BooleanArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray().toBooleanArray()).matches(value.toTypedArray().toBooleanArray()) + + // Then + actual mustBe true + } + + @OptIn(ExperimentalUnsignedTypes::class) + @Test + @JsName("fn21") + fun `Given eq is called it returns false if the given Value is an UByteArray and the call Value are not matching`() { + // Given + val value = fixture.fixture() + + // When + val actual = eq(value).matches(fixture.fixture()) + + // Then + actual mustBe false + } + + @OptIn(ExperimentalUnsignedTypes::class) + @Test + @JsName("fn22") + fun `Given eq is called it returns true if the given Value is an UByteArray and the call Value are not matching`() { + // Given + val value = fixture.fixture() + + // When + val actual = eq(value).matches(value) + + // Then + actual mustBe true + } + + @OptIn(ExperimentalUnsignedTypes::class) + @Test + @JsName("fn23") + fun `Given eq is called it returns false if the given Value is an UShortArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray().toUShortArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray().toUShortArray()) + + // Then + actual mustBe false + } + + @OptIn(ExperimentalUnsignedTypes::class) + @Test + @JsName("fn24") + fun `Given eq is called it returns true if the given Value is an UShortArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray().toUShortArray()).matches(value.toTypedArray().toUShortArray()) + + // Then + actual mustBe true + } + + @OptIn(ExperimentalUnsignedTypes::class) + @Test + @JsName("fn25") + fun `Given eq is called it returns false if the given Value is an UIntArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray().toUIntArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray().toUIntArray()) + + // Then + actual mustBe false + } + + @OptIn(ExperimentalUnsignedTypes::class) + @Test + @JsName("fn26") + fun `Given eq is called it returns true if the given Value is an UIntArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray().toUIntArray()).matches(value.toTypedArray().toUIntArray()) + + // Then + actual mustBe true + } + + @OptIn(ExperimentalUnsignedTypes::class) + @Test + @JsName("fn27") + fun `Given eq is called it returns false if the given Value is an ULongArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture().toTypedArray().toULongArray() + + // When + val actual = eq(value).matches(fixture.listFixture().toTypedArray().toULongArray()) + + // Then + actual mustBe false + } + + @OptIn(ExperimentalUnsignedTypes::class) + @Test + @JsName("fn28") + fun `Given eq is called it returns true if the given Value is an ULongArray and the call Value are not matching`() { + // Given + val value = fixture.listFixture() + + // When + val actual = eq(value.toTypedArray().toULongArray()).matches(value.toTypedArray().toULongArray()) + + // Then + actual mustBe true + } }