Added tests (WIP, failing)
This commit is contained in:
@@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.jetbrainsKotlinJvm)
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
alias(libs.plugins.androidApplication)
|
||||
alias(libs.plugins.jetbrainsCompose)
|
||||
@@ -20,6 +21,7 @@ kotlin {
|
||||
jvm("desktop")
|
||||
|
||||
sourceSets {
|
||||
val androidUnitTest by getting
|
||||
val desktopMain by getting
|
||||
val desktopTest by getting
|
||||
|
||||
@@ -39,7 +41,7 @@ kotlin {
|
||||
desktopMain.dependencies {
|
||||
implementation(compose.desktop.currentOs)
|
||||
}
|
||||
androidNativeTest.dependencies {
|
||||
androidUnitTest.dependencies {
|
||||
implementation(kotlin("test"))
|
||||
implementation(libs.atrium)
|
||||
}
|
||||
@@ -102,6 +104,12 @@ compose.desktop {
|
||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
||||
packageName = "ch.dissem.yaep"
|
||||
packageVersion = "1.0.0"
|
||||
|
||||
buildTypes.release.proguard {
|
||||
configurationFiles.from(project.file("proguard-rules.pro"))
|
||||
isEnabled.set(true)
|
||||
obfuscate.set(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
composeApp/proguard-rules.pro
vendored
Normal file
25
composeApp/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)
|
||||
|
||||
-keepclasseswithmembers public class MainKt {
|
||||
public static void main(java.lang.String[]);
|
||||
}
|
||||
|
||||
-dontwarn kotlinx.coroutines.debug.*
|
||||
-dontwarn kotlinx.datetime.**
|
||||
|
||||
-keep class kotlin.** { *; }
|
||||
-keep class kotlinx.coroutines.** { *; }
|
||||
-keep class org.jetbrains.skia.** { *; }
|
||||
-keep class org.jetbrains.skiko.** { *; }
|
||||
|
||||
-ignorewarnings
|
||||
|
||||
# Windows folders
|
||||
-keep class com.sun.jna.* { *; }
|
||||
-keepclassmembers class * extends com.sun.jna.* { public *; }
|
||||
|
||||
-assumenosideeffects public class androidx.compose.runtime.ComposerKt {
|
||||
void sourceInformation(androidx.compose.runtime.Composer,java.lang.String);
|
||||
void sourceInformationMarkerStart(androidx.compose.runtime.Composer,int,java.lang.String);
|
||||
void sourceInformationMarkerEnd(androidx.compose.runtime.Composer);
|
||||
}
|
||||
@@ -60,8 +60,10 @@ class TripletClue<C : ItemClass<C>>(val a: Item<C>, val b: Item<C>, val c: Item<
|
||||
return false
|
||||
}
|
||||
|
||||
if (ia == ib) {
|
||||
return true
|
||||
if (ia != -1 && ic != -1) {
|
||||
if (ia + 2 == ic || ia == ic + 2) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if (isNeighbourRuleViolated(ia, ib) || isNeighbourRuleViolated(ib, ic)) {
|
||||
|
||||
@@ -32,7 +32,13 @@ fun List<List<Item<ItemClass<*>>>>.toGrid() = Grid(
|
||||
GameRow(
|
||||
category = row.first().itemType.companion,
|
||||
options = row,
|
||||
cells = row.map { GameCell(selection = null, solution = it, options = row.toMutableList()) }
|
||||
cells = row.map {
|
||||
GameCell(
|
||||
selection = null,
|
||||
solution = it,
|
||||
options = row.toMutableList()
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -48,7 +54,7 @@ class GameCell<C : ItemClass<C>>(
|
||||
|
||||
class Item<C : ItemClass<C>>(
|
||||
val itemType: C,
|
||||
val symbol: String
|
||||
val symbol: String = itemType.symbols.random()
|
||||
) {
|
||||
constructor(itemType: C) : this(itemType, itemType.symbols.random())
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package domain
|
||||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.feature
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.size
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toBeLessThan
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toHaveSize
|
||||
import ch.tutteli.atrium.api.verbs.expect
|
||||
import kotlin.test.Test
|
||||
|
||||
@@ -13,6 +16,9 @@ class GameTest {
|
||||
expect(game) {
|
||||
feature(Game::areCategoriesValid).toEqual(true)
|
||||
feature(Game::areRulesViolated).toEqual(false)
|
||||
feature(Game::clues) {
|
||||
feature(List<Clue>::size).toBeLessThan(30)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
36
composeApp/src/commonTest/kotlin/domain/NeighbourClueTest.kt
Normal file
36
composeApp/src/commonTest/kotlin/domain/NeighbourClueTest.kt
Normal file
@@ -0,0 +1,36 @@
|
||||
package domain
|
||||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.feature
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.size
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toBeLessThan
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toEqual
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.toHaveSize
|
||||
import ch.tutteli.atrium.api.verbs.expect
|
||||
import domain.Item
|
||||
import kotlin.test.Test
|
||||
|
||||
class NeighbourClueTest {
|
||||
@Test
|
||||
fun `ensure actual neighbours are valid`() {
|
||||
val size = 5
|
||||
val grid = ItemClass.randomClasses(size)
|
||||
.map {
|
||||
it.randomItems(size).map { item -> Item(item) }
|
||||
}
|
||||
.map { row ->
|
||||
GameRow(
|
||||
category = row.first().itemType.companion,
|
||||
options = row,
|
||||
cells = row.map {
|
||||
GameCell(
|
||||
selection = it,
|
||||
solution = it,
|
||||
options = mutableListOf()
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
NeighbourClue(Item(Animals.ANT), Item(Profession.ASTRONAUT))
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
[versions]
|
||||
agp = "8.5.0"
|
||||
agp = "8.3.2"
|
||||
android-compileSdk = "34"
|
||||
android-minSdk = "24"
|
||||
android-targetSdk = "34"
|
||||
|
||||
13
proguard-rules.pro
vendored
13
proguard-rules.pro
vendored
@@ -1,13 +0,0 @@
|
||||
-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)
|
||||
|
||||
-keepclasseswithmembers public class MainKt {
|
||||
public static void main(java.lang.String[]);
|
||||
}
|
||||
|
||||
-dontwarn kotlinx.coroutines.debug.*
|
||||
|
||||
-keep class kotlin.** { *; }
|
||||
-keep class kotlinx.coroutines.** { *; }
|
||||
-keep class org.jetbrains.skia.** { *; }
|
||||
-keep class org.jetbrains.skiko.** { *; }
|
||||
-dontwarn kotlinx.datetime.**
|
||||
Reference in New Issue
Block a user