Tests:ObjectInheritingFromATrait test enhanced, ObjectInheritingFromClass test added.
This commit is contained in:
@@ -53,4 +53,7 @@ public final class ObjectTest extends SingleFileTranslationTest {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testObjectInheritingFromClass() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
package foo
|
||||
|
||||
trait Foo {
|
||||
fun f() : Boolean
|
||||
fun execute(handler: ()->Unit) {
|
||||
execute(false, handler)
|
||||
}
|
||||
|
||||
fun execute(onlyIfAttached: Boolean, handler: ()->Unit)
|
||||
}
|
||||
|
||||
object foo : Foo {
|
||||
override fun f() = true
|
||||
override fun execute(onlyIfAttached: Boolean, handler: ()->Unit) {
|
||||
handler()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : Boolean {
|
||||
return foo.f()
|
||||
private var result = false
|
||||
|
||||
fun box(): Boolean {
|
||||
foo.execute() {
|
||||
result = true
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package foo
|
||||
|
||||
abstract class A(val s:String) {
|
||||
}
|
||||
|
||||
object B : A("test") {
|
||||
}
|
||||
|
||||
fun box() = B.s == "test"
|
||||
Reference in New Issue
Block a user