Skip to content

Commit f83961e

Browse files
authored
Merge Feature/expand numeric statements (#9)
* expand number statements * bump minor version * remove unused version/dependencies
1 parent 8920cba commit f83961e

File tree

2 files changed

+47
-22
lines changed

2 files changed

+47
-22
lines changed

assertions/src/commonMain/kotlin/org/pointyware/kass/assertions/primitive/NumberStatements.kt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ object NumberStatements {
1414
override val failureMessage: String
1515
get() = "The subject is less than or equal to $value"
1616
}
17+
1718
fun <T:Number> isAtMost(value: T) = object: Statement<T> {
1819
override fun evaluate(subject: T): Boolean {
1920
return subject.toDouble() <= value.toDouble()
@@ -22,4 +23,49 @@ object NumberStatements {
2223
override val failureMessage: String
2324
get() = "The subject is greater than $value"
2425
}
26+
27+
fun <T:Number> isLessThan(other: T) = object: Statement<T> {
28+
override val failureMessage: String
29+
get() = "The subject is greater than or equal to $other."
30+
31+
override fun evaluate(subject: T): Boolean {
32+
return subject.toDouble() < other.toDouble()
33+
}
34+
}
35+
36+
fun <T:Number> isAtLeast(value: T) = object: Statement<T> {
37+
override fun evaluate(subject: T): Boolean {
38+
return subject.toDouble() >= value.toDouble()
39+
}
40+
41+
override val failureMessage: String
42+
get() = "The subject is less than $value"
43+
}
44+
45+
fun isEven() = object: Statement<Int> {
46+
override val failureMessage: String
47+
get() = "Subject is not even."
48+
49+
override fun evaluate(subject: Int): Boolean {
50+
return subject % 2 == 0
51+
}
52+
}
53+
54+
fun isOdd() = object: Statement<Int> {
55+
override val failureMessage: String
56+
get() = "Subject is not odd."
57+
58+
override fun evaluate(subject: Int): Boolean {
59+
return subject % 2 != 0
60+
}
61+
}
62+
63+
fun isDividedBy(divisor: Int) = object: Statement<Int> {
64+
override val failureMessage: String
65+
get() = "Subject is not evenly divided by $divisor."
66+
67+
override fun evaluate(subject: Int): Boolean {
68+
return subject % divisor == 0
69+
}
70+
}
2571
}

gradle/libs.versions.toml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,17 @@
11
[versions]
22
agp = "8.3.0"
3-
androidx-compose = "1.8.2"
4-
compose = "1.5.12"
53
dokka = "1.9.20"
6-
jupiter = "5.10.2"
7-
kass = "0.3.1"
8-
koin = "3.5.3"
9-
koin-bom = "3.5.3"
4+
kass = "0.4.0"
105
kotlin = "2.0.0"
116
kotlinx-datetime = "0.4.0"
127
kotlinx-coroutines = "1.8.0"
13-
mockk = "1.12.0"
14-
truth = "1.1.3"
158

169
[libraries]
17-
androidx-activityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidx-compose" }
18-
jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "jupiter" }
19-
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" }
20-
koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin-bom" }
21-
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
22-
koin-compose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koin" }
23-
koin-ktor = { module = "io.insert-koin:koin-ktor" }
24-
koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin" }
2510
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
2611
kotlinx-dateTime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
2712
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
28-
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
29-
truth = { module = "com.google.truth:truth", version.ref = "truth" }
3013

3114
[plugins]
32-
androidApplication = { id = "com.android.application", version.ref = "agp" }
3315
androidLibrary = { id = "com.android.library", version.ref = "agp" }
34-
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose" }
3516
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
36-
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
37-
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
3817
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }

0 commit comments

Comments
 (0)