Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mockery #3

Merged
merged 13 commits into from
Feb 11, 2022
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ example-android-app/
# generated
**/src-gen/commonTest/kotlin/**/config/TestConfig.kt

# kotlin-js
kotlin-js-store/

# Editors
*.suo
*.ntvs*
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ allprojects {
addCustomRepositories()
mavenCentral()
google()
jcenter()
}

configurations.all {
Expand All @@ -48,6 +49,6 @@ allprojects {
}

tasks.named<Wrapper>("wrapper") {
gradleVersion = "7.3.3"
gradleVersion = "7.2"
distributionType = Wrapper.DistributionType.ALL
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object Version {
/**
* [AnitBytes GradlePlugins](https://github.com/bitPogo/gradle-plugins)
*/
const val antibytes = "c81afcd"
const val antibytes = "99eff34"

/**
* [Spotless](https://plugins.gradle.org/plugin/com.diffplug.gradle.spotless)
Expand All @@ -28,7 +28,8 @@ object Version {
}

val antibytes = Antibytes

object Antibytes {
val test = "f0f5eec"
val test = "7b11c9d-add-ios-SNAPSHOT"
}
}
88 changes: 87 additions & 1 deletion kmock/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,34 @@ antiBytesPublishing {
kotlin {
android()

js(IR) {
nodejs()
browser()
}

jvm()

ios()

linuxX64()

sourceSets {
val commonMain by getting {
dependencies {
implementation(Dependency.multiplatform.kotlin.common)
implementation(Dependency.multiplatform.stately.isolate)
implementation(Dependency.multiplatform.stately.concurrency)

implementation(LocalDependency.antibytes.test.core)
}
}
val commonTest by getting {
dependencies {
implementation(Dependency.multiplatform.test.common)
implementation(Dependency.multiplatform.test.annotations)
implementation(Dependency.multiplatform.coroutines.common)

implementation(LocalDependency.antibytes.test.annotations)
implementation(LocalDependency.antibytes.test.core)
implementation(LocalDependency.antibytes.test.coroutine)
implementation(LocalDependency.antibytes.test.fixture)
}
Expand All @@ -66,6 +79,21 @@ kotlin {
}
}

val jsMain by getting {
dependencies {
dependsOn(commonMain)
implementation(Dependency.multiplatform.kotlin.js)
implementation(Dependency.js.nodejs)
}
}
val jsTest by getting {
dependencies {
dependsOn(commonTest)

implementation(Dependency.multiplatform.test.js)
}
}

val jvmMain by getting {
dependencies {
dependsOn(commonMain)
Expand All @@ -80,5 +108,63 @@ kotlin {
implementation(Dependency.multiplatform.test.junit)
}
}

val nativeMain by creating {
dependencies {
dependsOn(commonMain)
}
}

val nativeTest by creating {
dependencies {
dependsOn(commonTest)
}
}

val darwinMain by creating {
dependencies {
dependsOn(nativeMain)
}
}
val darwinTest by creating {
dependencies {
dependsOn(nativeTest)
}
}

val otherMain by creating {
dependencies {
dependsOn(nativeMain)
}
}

val otherTest by creating {
dependencies {
dependsOn(nativeTest)
}
}

val linuxX64Main by getting {
dependencies {
dependsOn(otherMain)
}
}

val linuxX64Test by getting {
dependencies {
dependsOn(otherTest)
}
}

val iosMain by getting {
dependencies {
dependsOn(darwinMain)
}
}
val iosTest by getting {
dependencies {
dependsOn(darwinTest)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2022 Matthias Geisler (bitPogo) / All rights reserved.
*
* Use of this source code is governed by Apache v2.0
*/

package tech.antibytes.kmock

import tech.antibytes.kmock.KMockContract.GetOrSet

internal fun Array<out Any?>?.withArguments(vararg values: Any?): Boolean {
return when {
this == null -> values.isEmpty()
values.isEmpty() -> true
else -> values.all { value -> this.contains(value) }
}
}

internal fun Array<out Any?>?.withSameArguments(vararg values: Any?): Boolean {
return this?.contentDeepEquals(values) ?: values.isEmpty()
}

internal fun Array<out Any?>?.withoutArguments(vararg values: Any?): Boolean {
return if (this == null) {
values.isNotEmpty()
} else {
values.none { value -> this.contains(value) }
}
}

internal fun GetOrSet.wasGotten(): Boolean = this is GetOrSet.Get

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
}
}
Loading