From b45c7e2d1b55852c70e2bd075453ab154bb3ab48 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 7 Aug 2017 19:22:35 -0700 Subject: [PATCH] Fix toString errors failing unit tests. --- src/main/kotlin/org/nwapw/abacus/tree/FunctionNode.kt | 2 +- src/main/kotlin/org/nwapw/abacus/tree/UnaryNode.kt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/nwapw/abacus/tree/FunctionNode.kt b/src/main/kotlin/org/nwapw/abacus/tree/FunctionNode.kt index ab25aaf..198eee2 100644 --- a/src/main/kotlin/org/nwapw/abacus/tree/FunctionNode.kt +++ b/src/main/kotlin/org/nwapw/abacus/tree/FunctionNode.kt @@ -28,7 +28,7 @@ data class FunctionNode(val function: String) : TreeNode() { buffer.append(children[i].toString()) buffer.append(if (i == children.size - 1) ")" else ",") } - return super.toString() + return buffer.toString() } /** diff --git a/src/main/kotlin/org/nwapw/abacus/tree/UnaryNode.kt b/src/main/kotlin/org/nwapw/abacus/tree/UnaryNode.kt index 952c82f..65853ba 100644 --- a/src/main/kotlin/org/nwapw/abacus/tree/UnaryNode.kt +++ b/src/main/kotlin/org/nwapw/abacus/tree/UnaryNode.kt @@ -16,4 +16,8 @@ data class UnaryNode(val operation: String, val applyTo: TreeNode? = null) : Tre return reducer.reduceNode(this, reducedChild) } + override fun toString(): String { + return "(" + (applyTo?.toString() ?: "null") + ")" + operation + } + } \ No newline at end of file