diff --git a/build.gradle.kts b/build.gradle.kts index 2dcf5b24..c05ec51c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ -val dataforgeVersion by extra("0.1.3-dev-4") +val dataforgeVersion by extra("0.1.3-dev-5") allprojects { repositories { diff --git a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt index 39a5f569..71094888 100644 --- a/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt +++ b/dataforge-meta/src/commonMain/kotlin/hep/dataforge/meta/ConfigDelegates.kt @@ -14,7 +14,7 @@ fun Configurable.value(default: Any = Null, key: String? = null): MutableValueDe MutableValueDelegate(config, key, Value.of(default)) fun Configurable.value(default: T? = null, key: String? = null, transform: (Value?) -> T): ReadWriteDelegateWrapper = - 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 = MutableStringDelegate(config, key, default) diff --git a/dataforge-meta/src/commonTest/kotlin/hep/dataforge/descriptors/DescriptorTest.kt b/dataforge-meta/src/commonTest/kotlin/hep/dataforge/descriptors/DescriptorTest.kt new file mode 100644 index 00000000..79800ec5 --- /dev/null +++ b/dataforge-meta/src/commonTest/kotlin/hep/dataforge/descriptors/DescriptorTest.kt @@ -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()) + } +} \ No newline at end of file