Some additional fixes

This commit is contained in:
Alexander Nozik 2019-07-27 17:45:14 +03:00
parent efddfa8e91
commit 9f6d53f214
6 changed files with 11 additions and 9 deletions

View File

@ -7,7 +7,6 @@ import kotlinx.io.core.readBytes
/**
* A source of binary data
*/
interface Binary {
/**
* The size of binary in bytes

View File

@ -1,7 +1,9 @@
package hep.dataforge.io
import hep.dataforge.meta.Meta
import hep.dataforge.meta.buildMeta
import hep.dataforge.meta.get
import hep.dataforge.meta.seal
import kotlin.test.Test
import kotlin.test.assertEquals
@ -34,6 +36,8 @@ class MetaFormatTest {
val string = meta.toString(JsonMetaFormat)
val result = JsonMetaFormat.parse(string)
assertEquals<Meta>(meta, meta.seal())
meta.items.keys.forEach {
if (meta[it] != result[it]) error("${meta[it]} != ${result[it]}")
}

View File

@ -16,14 +16,10 @@ import hep.dataforge.values.boolean
*/
sealed class MetaItem<out M : Meta> {
data class ValueItem(val value: Value) : MetaItem<Nothing>(){
override fun toString(): String = value.string
override fun toString(): String = value.toString()
}
data class NodeItem<M : Meta>(val node: M) : MetaItem<M>(){
override fun toString(): String = node.toString()
override fun equals(other: Any?): Boolean {
return this.node == (other as? NodeItem<*>).node
}
}
}

View File

@ -188,7 +188,7 @@ class ListValue(override val list: List<Value>) : Value {
override val number: Number get() = list.first().number
override val string: String get() = list.first().string
override fun toString(): String = value.toString()
override fun toString(): String = list.joinToString (prefix = "[ ", postfix = " ]")
override fun equals(other: Any?): Boolean {
if (this === other) return true

View File

@ -27,8 +27,7 @@ class HtmlOutput<T : Any>(override val context: Context, private val consumer: T
} else {
val value = cache[obj::class]
if (value == null) {
val answer = context.top<HtmlBuilder<*>>().values
.filter { it.type.isInstance(obj) }.firstOrNull()
val answer = context.top<HtmlBuilder<*>>(HTML_CONVERTER_TYPE).values.firstOrNull { it.type.isInstance(obj) }
if (answer != null) {
cache[obj::class] = answer
answer

View File

@ -0,0 +1,4 @@
package hep.dataforge.scripting
internal object Placeholder {
}