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
This commit is contained in:
2026-06-06 13:03:00 +02:00
parent ea0b4fa95c
commit 6de95f7976
8 changed files with 21 additions and 38 deletions

View File

@@ -62,7 +62,6 @@ open class TreeNode<T>(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<T>): Boolean {
println(child.value)
val removed = child._parent?._children?.remove(child)
child._parent = null
return removed ?: false

View File

@@ -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)
}
}

View File

@@ -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")

View File

@@ -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())