From d1061a6669c97451f02e8b945d2c1537132590e4 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 10 Aug 2019 17:28:27 +0300 Subject: [PATCH] Fix for value equality in JS --- .../commonMain/kotlin/hep/dataforge/values/Value.kt | 12 ++++++------ .../kotlin/hep/dataforge/output/html/HtmlOutput.kt | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/values/Value.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/values/Value.kt index 5da65a10..cd68e040 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/values/Value.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/values/Value.kt @@ -133,12 +133,12 @@ class NumberValue(override val number: Number) : Value { override fun equals(other: Any?): Boolean { if (other !is Value) return false return when (number) { - is Short -> number == other.number.toShort() - is Long -> number == other.number.toLong() - is Byte -> number == other.number.toByte() - is Int -> number == other.number.toInt() - is Float -> number == other.number.toFloat() - is Double -> number == other.number.toDouble() + is Short -> number.toShort() == other.number.toShort() + is Long -> number.toLong() == other.number.toLong() + is Byte -> number.toByte() == other.number.toByte() + is Int -> number.toInt() == other.number.toInt() + is Float -> number.toFloat() == other.number.toFloat() + is Double -> number.toDouble() == other.number.toDouble() else -> number.toString() == other.number.toString() } } diff --git a/dataforge-output-html/src/commonMain/kotlin/hep/dataforge/output/html/HtmlOutput.kt b/dataforge-output-html/src/commonMain/kotlin/hep/dataforge/output/html/HtmlOutput.kt index c7aea610..b54b7eb7 100644 --- a/dataforge-output-html/src/commonMain/kotlin/hep/dataforge/output/html/HtmlOutput.kt +++ b/dataforge-output-html/src/commonMain/kotlin/hep/dataforge/output/html/HtmlOutput.kt @@ -27,7 +27,8 @@ class HtmlOutput(override val context: Context, private val consumer: T } else { val value = cache[obj::class] if (value == null) { - val answer = context.top>(HTML_CONVERTER_TYPE).values.firstOrNull { it.type.isInstance(obj) } + val answer = + context.top>(HTML_CONVERTER_TYPE).values.firstOrNull { it.type.isInstance(obj) } if (answer != null) { cache[obj::class] = answer answer @@ -39,6 +40,7 @@ class HtmlOutput(override val context: Context, private val consumer: T } } context.launch(Dispatchers.Output) { + @Suppress("UNCHECKED_CAST") (builder as HtmlBuilder).run { consumer.render(obj) } } }