Fixed value delegate nullability bug.

This commit is contained in:
Alexander Nozik 2019-06-12 21:12:54 +03:00
parent c6c4509d6c
commit 4ae1f71a05
3 changed files with 33 additions and 2 deletions

View File

@ -1,4 +1,4 @@
val dataforgeVersion by extra("0.1.3-dev-4")
val dataforgeVersion by extra("0.1.3-dev-5")
allprojects {
repositories {

View File

@ -14,7 +14,7 @@ fun Configurable.value(default: Any = Null, key: String? = null): MutableValueDe
MutableValueDelegate(config, key, Value.of(default))
fun <T> Configurable.value(default: T? = null, key: String? = null, transform: (Value?) -> T): ReadWriteDelegateWrapper<Value?, T> =
MutableValueDelegate(config, key, Value.of(default)).transform(reader = transform)
MutableValueDelegate(config, key, default?.let { Value.of(it)}).transform(reader = transform)
fun Configurable.string(default: String? = null, key: String? = null): MutableStringDelegate<Config> =
MutableStringDelegate(config, key, default)

View File

@ -0,0 +1,31 @@
package hep.dataforge.descriptors
import hep.dataforge.values.ValueType
import kotlin.test.Test
import kotlin.test.assertEquals
class DescriptorTest {
val descriptor = NodeDescriptor.build {
node("aNode") {
info = "A root demo node"
value("b") {
info = "b number value"
type(ValueType.NUMBER)
}
node("otherNode") {
value("otherValue") {
type(ValueType.BOOLEAN)
default(false)
info = "default value"
}
}
}
}
@Test
fun testAllowedValues() {
val allowed = descriptor.nodes["aNode"]?.values?.get("b")?.allowedValues
assertEquals(allowed, emptyList())
}
}