TEST: constructor body test

This commit is contained in:
Vasily Levchenko
2016-11-18 06:04:29 +03:00
committed by vvlevchenko
parent 4d24d735de
commit 81742556a6
4 changed files with 24 additions and 6 deletions
+4 -2
View File
@@ -227,9 +227,11 @@ task objectInitialization(type: UnitKonanTest) {
source = "codegen/object/initialization.kt"
}
/* task objectBasic(type: KonanTest) {
/* field initialization test
task objectBasic(type: UnitKonanTest) {
source = "$codegen/klass/basic.kt"
} */
}
*/
task check_type(type: UnitKonanTest) {
source = "codegen/basics/check_type.kt"
@@ -0,0 +1,6 @@
class A {
var field0:Int = 0;
constructor(arg0:Int) {
field0 = arg0
}
}
@@ -4,7 +4,7 @@ int
run_test() {
int (*foo)(int, int) = resolve_symbol("kfun:foo(Int;Int)");
if (foo(2, 3) != 2) return 1;
if (foo(2, 3) != 5) return 1;
return 0;
}
@@ -2,9 +2,19 @@ open class A(val a:Int, val b:Int)
open class B(val c:Int, d:Int):A(c, d)
//class C():B(42)
open class C(i:Int, j:Int):B(i + j, 42)
class D (i: Int, j:Int) : C(i, j){
constructor(i: Int, j:Int, k:Int) : this(i, j) {
foo(i)
}
constructor():this(1, 2)
}
fun foo(i:Int) : Unit {}
fun foo(i:Int, j:Int):Int {
val b = B(i, j)
return b.c
val c = D(i, j)
return c.c
}