From 6de95f79762642082300a8520b97f0e5204d3205 Mon Sep 17 00:00:00 2001 From: Adrian Kuta Date: Sat, 6 Jun 2026 13:03:00 +0200 Subject: [PATCH] Release 3.1.5: remove debug println, drop worksheet leftover, modernize CI - Remove stray println(child.value) from TreeNode.removeChild() - Add regression test for removeChild() return value - Delete leftover ExampleUnitTest.kt template test - Remove Example.ws.kts worksheet and kotlin("script-runtime") from jvmMain - Bump actions/checkout v2 -> v4 in CI workflows - Update README install snippets to 3.1.5 - Bump version to 3.1.5 --- .github/workflows/publishRelease.yml | 2 +- .github/workflows/test.yml | 2 +- README.md | 6 +++--- build.gradle.kts | 4 ++-- .../datastructure/tree/TreeNode.kt | 1 - .../datastructure.tree/ExampleUnitTest.kt | 16 ---------------- .../datastructure.tree/TreeNodeTest.kt | 14 ++++++++++++++ src/jvmMain/kotlin/Example.ws.kts | 14 -------------- 8 files changed, 21 insertions(+), 38 deletions(-) delete mode 100644 src/commonTest/kotlin/com.github.adriankuta/datastructure.tree/ExampleUnitTest.kt delete mode 100644 src/jvmMain/kotlin/Example.ws.kts diff --git a/.github/workflows/publishRelease.yml b/.github/workflows/publishRelease.yml index ef24e83..1892647 100644 --- a/.github/workflows/publishRelease.yml +++ b/.github/workflows/publishRelease.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up JDK 21 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e9a79b0..6e07d12 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up JDK 21 uses: actions/setup-java@v4 with: diff --git a/README.md b/README.md index 38c2dfa..49c7bff 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,14 @@ Gradle (Kotlin DSL): ```kotlin // commonMain for KMP projects, or any sourceSet/module where you need it dependencies { - implementation("com.github.adriankuta:tree-structure:3.1.1") // see badge above for the latest version + implementation("com.github.adriankuta:tree-structure:3.1.5") // see badge above for the latest version } ``` Gradle (Groovy): ```groovy dependencies { - implementation "com.github.adriankuta:tree-structure:3.1.1" // see badge above for the latest + implementation "com.github.adriankuta:tree-structure:3.1.5" // see badge above for the latest } ``` @@ -32,7 +32,7 @@ Maven: com.github.adriankuta tree-structure - 3.1.1 + 3.1.5 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 48a6778..4eca99e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,7 +13,7 @@ plugins { val PUBLISH_GROUP_ID = "com.github.adriankuta" val PUBLISH_ARTIFACT_ID = "tree-structure" // base artifact; KMP will add -jvm, -ios*, etc. -val PUBLISH_VERSION = "3.1.4" +val PUBLISH_VERSION = "3.1.5" val snapshot: String? by project @@ -119,7 +119,7 @@ kotlin { sourceSets { val commonMain by getting val commonTest by getting { dependencies { implementation(kotlin("test")) } } - val jvmMain by getting { dependencies { implementation(kotlin("script-runtime")) } } + val jvmMain by getting val jvmTest by getting val jsMain by getting val jsTest by getting diff --git a/src/commonMain/kotlin/com.github.adriankuta/datastructure/tree/TreeNode.kt b/src/commonMain/kotlin/com.github.adriankuta/datastructure/tree/TreeNode.kt index 16fd262..22d6df8 100644 --- a/src/commonMain/kotlin/com.github.adriankuta/datastructure/tree/TreeNode.kt +++ b/src/commonMain/kotlin/com.github.adriankuta/datastructure/tree/TreeNode.kt @@ -62,7 +62,6 @@ open class TreeNode(val value: T, var treeIterator: TreeNodeIterators = PreOr * @return `true` if the node has been successfully removed; `false` if it was not present in the tree. */ fun removeChild(child: TreeNode): Boolean { - println(child.value) val removed = child._parent?._children?.remove(child) child._parent = null return removed ?: false diff --git a/src/commonTest/kotlin/com.github.adriankuta/datastructure.tree/ExampleUnitTest.kt b/src/commonTest/kotlin/com.github.adriankuta/datastructure.tree/ExampleUnitTest.kt deleted file mode 100644 index c372078..0000000 --- a/src/commonTest/kotlin/com.github.adriankuta/datastructure.tree/ExampleUnitTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.github.adriankuta.datastructure.tree - -import kotlin.test.Test -import kotlin.test.assertEquals - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} diff --git a/src/commonTest/kotlin/com.github.adriankuta/datastructure.tree/TreeNodeTest.kt b/src/commonTest/kotlin/com.github.adriankuta/datastructure.tree/TreeNodeTest.kt index 7ac21f6..e54ff11 100644 --- a/src/commonTest/kotlin/com.github.adriankuta/datastructure.tree/TreeNodeTest.kt +++ b/src/commonTest/kotlin/com.github.adriankuta/datastructure.tree/TreeNodeTest.kt @@ -4,7 +4,9 @@ import com.github.adriankuta.datastructure.tree.iterators.TreeNodeIterators import kotlin.test.Test import kotlin.test.assertContentEquals import kotlin.test.assertEquals +import kotlin.test.assertFalse import kotlin.test.assertNull +import kotlin.test.assertTrue class TreeNodeTest { @@ -62,6 +64,18 @@ class TreeNodeTest { ) } + @Test + fun removeChildReturnsTrueWhenPresentFalseOtherwise() { + val root = TreeNode("Root") + val child = TreeNode("Child") + root.addChild(child) + + assertTrue(root.removeChild(child), "Removing a present child returns true") + assertFalse(root.removeChild(child), "Removing an already-removed child returns false") + assertNull(child.parent, "Removed child is detached from its parent") + assertEquals(emptyList(), root.children) + } + @Test fun clearTest() { val root = TreeNode("Root") diff --git a/src/jvmMain/kotlin/Example.ws.kts b/src/jvmMain/kotlin/Example.ws.kts deleted file mode 100644 index 162936a..0000000 --- a/src/jvmMain/kotlin/Example.ws.kts +++ /dev/null @@ -1,14 +0,0 @@ -import com.github.adriankuta.datastructure.tree.tree - -val root = - tree("World") { - child("North America") { - child("USA") - } - child("Europe") { - child("Poland") - child("Germany") - } - } - -print(root.prettyString()) \ No newline at end of file