From 8dfd56f02ec2b3cc4527d33af9753a08c6a27feb Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 17 Feb 2020 14:46:03 +0300 Subject: [PATCH] Initial API --- build.gradle.kts | 2 +- .../hep/dataforge/meta/MetaDelegateTest.kt | 28 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 14ccd3e9..82d402e2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { id("scientifik.publish") version toolsVersion apply false } -val dataforgeVersion by extra("0.1.5-dev-8") +val dataforgeVersion by extra("0.1.5-dev-9") val bintrayRepo by extra("dataforge") val githubProject by extra("dataforge-core") diff --git a/dataforge-meta/src/commonTest/kotlin/hep/dataforge/meta/MetaDelegateTest.kt b/dataforge-meta/src/commonTest/kotlin/hep/dataforge/meta/MetaDelegateTest.kt index 2461c363..4cf2002f 100644 --- a/dataforge-meta/src/commonTest/kotlin/hep/dataforge/meta/MetaDelegateTest.kt +++ b/dataforge-meta/src/commonTest/kotlin/hep/dataforge/meta/MetaDelegateTest.kt @@ -11,25 +11,27 @@ class MetaDelegateTest { NO } + class InnerSpec : Scheme() { + var innerValue by string() + companion object: SchemeSpec(::InnerSpec) + } + + class TestScheme : Scheme() { + var myValue by string() + var safeValue by double(2.2) + var enumValue by enum(TestEnum.YES) + var inner by spec(InnerSpec) + companion object: SchemeSpec(::TestScheme) + } + @Test fun delegateTest() { - class InnerSpec : Scheme() { - var innerValue by string() - } - - val innerSpec = object : SchemeSpec(::InnerSpec){} - - val testObject = object : Scheme(Config()) { - var myValue by string() - var safeValue by double(2.2) - var enumValue by enum(TestEnum.YES) - var inner by spec(innerSpec) - } + val testObject = TestScheme.empty() testObject.config["myValue"] = "theString" testObject.enumValue = TestEnum.NO - testObject.inner = innerSpec { innerValue = "ddd" } + testObject.inner = InnerSpec { innerValue = "ddd" } assertEquals("theString", testObject.myValue) assertEquals(TestEnum.NO, testObject.enumValue)