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
}
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")

View File

@ -11,25 +11,27 @@ class MetaDelegateTest {
NO
}
class InnerSpec : Scheme() {
var innerValue by string()
companion object: SchemeSpec<InnerSpec>(::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>(::TestScheme)
}
@Test
fun delegateTest() {
class InnerSpec : Scheme() {
var innerValue by string()
}
val innerSpec = object : SchemeSpec<InnerSpec>(::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)