Initial API

This commit is contained in:
Alexander Nozik 2020-02-17 14:46:03 +03:00
parent dfea68b65c
commit 8dfd56f02e
2 changed files with 16 additions and 14 deletions

View File

@ -6,7 +6,7 @@ plugins {
id("scientifik.publish") version toolsVersion apply false 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 bintrayRepo by extra("dataforge")
val githubProject by extra("dataforge-core") val githubProject by extra("dataforge-core")

View File

@ -11,25 +11,27 @@ class MetaDelegateTest {
NO NO
} }
@Test
fun delegateTest() {
class InnerSpec : Scheme() { class InnerSpec : Scheme() {
var innerValue by string() var innerValue by string()
companion object: SchemeSpec<InnerSpec>(::InnerSpec)
} }
val innerSpec = object : SchemeSpec<InnerSpec>(::InnerSpec){} class TestScheme : Scheme() {
val testObject = object : Scheme(Config()) {
var myValue by string() var myValue by string()
var safeValue by double(2.2) var safeValue by double(2.2)
var enumValue by enum(TestEnum.YES) var enumValue by enum(TestEnum.YES)
var inner by spec(innerSpec) var inner by spec(InnerSpec)
companion object: SchemeSpec<TestScheme>(::TestScheme)
} }
@Test
fun delegateTest() {
val testObject = TestScheme.empty()
testObject.config["myValue"] = "theString" testObject.config["myValue"] = "theString"
testObject.enumValue = TestEnum.NO testObject.enumValue = TestEnum.NO
testObject.inner = innerSpec { innerValue = "ddd" } testObject.inner = InnerSpec { innerValue = "ddd" }
assertEquals("theString", testObject.myValue) assertEquals("theString", testObject.myValue)
assertEquals(TestEnum.NO, testObject.enumValue) assertEquals(TestEnum.NO, testObject.enumValue)