Tests:ObjectInheritingFromATrait test enhanced, ObjectInheritingFromClass test added.

This commit is contained in:
Pavel V. Talanov
2012-08-13 16:07:02 +04:00
parent 6febebc7b3
commit de3ebf9baa
3 changed files with 28 additions and 4 deletions
@@ -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"