From 9fe3deac336e161a12c6a85f7896ecc8f63018a3 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 2 Apr 2024 10:01:41 +0300 Subject: [PATCH] Fix scheme set method --- .../space/kscience/dataforge/meta/Scheme.kt | 2 +- .../kscience/dataforge/meta/SchemeTest.kt | 70 ------------------- 2 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 dataforge-meta/src/commonTest/kotlin/space/kscience/dataforge/meta/SchemeTest.kt diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Scheme.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Scheme.kt index 96b6df49..85b5087a 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Scheme.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/Scheme.kt @@ -122,7 +122,7 @@ public open class Scheme( override fun hashCode(): Int = Meta.hashCode(this) override fun set(name: Name, node: Meta?) { - target[name] = node + target[pathName + name] = node invalidate(name) } diff --git a/dataforge-meta/src/commonTest/kotlin/space/kscience/dataforge/meta/SchemeTest.kt b/dataforge-meta/src/commonTest/kotlin/space/kscience/dataforge/meta/SchemeTest.kt deleted file mode 100644 index eaa766d8..00000000 --- a/dataforge-meta/src/commonTest/kotlin/space/kscience/dataforge/meta/SchemeTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -package space.kscience.dataforge.meta - -import space.kscience.dataforge.misc.DFExperimental -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNotNull - - -private class SchemeWithInit: Scheme(){ - init { - set("initial", "initialValue") - } - - var initial by string() - companion object: SchemeSpec(::SchemeWithInit) -} - - - -class SchemeTest { - @Test - fun testSchemeWrappingBeforeEdit() { - val config = MutableMeta() - val scheme = TestScheme.write(config) - scheme.a = 29 - assertEquals(29, config["a"].int) - } - - @OptIn(DFExperimental::class) - @Test - fun testSchemeWrappingAfterEdit() { - val scheme = TestScheme.empty() - scheme.a = 29 - val config = MutableMeta() - scheme.retarget(config) - assertEquals(29, scheme.a) - } - - @Test - fun testSchemeSubscription() { - val scheme = TestScheme.empty() - var flag: Int? = null - scheme.useProperty(TestScheme::a) { a -> - flag = a - } - scheme.a = 2 - assertEquals(2, flag) - } - - @Test - fun testListSubscription(){ - val scheme = TestScheme.empty() - var value: Value? = null - scheme.v = ListValue(0.0,0.0,0.0) - scheme.useProperty(TestScheme::v){ - value = it - } - scheme.v = ListValue(1.0, 2.0, 3.0) - assertNotNull(value) - } - - - @Test - fun testSchemeWithInit(){ - val scheme = SchemeWithInit() - assertEquals("initialValue", scheme.initial) - scheme.initial = "none" - assertEquals("none", scheme.initial) - } -} \ No newline at end of file