Add tests for secondary constructors

This commit is contained in:
Roman Artemev
2018-04-02 14:46:31 +03:00
parent 42d9c5b932
commit 3ce324fa9d
8 changed files with 284 additions and 133 deletions
@@ -0,0 +1,19 @@
// EXPECTED_REACHABLE_NODES: 1114
package foo
open class Base(val bb: String) {
open fun foo() = bb
}
class Test(val tt: String) : Base("fail") {
override fun foo() = tt
}
fun box(): String {
val t = Test("OK")
return t.foo()
}
@@ -0,0 +1,35 @@
// EXPECTED_REACHABLE_NODES: 1114
package foo
open class Base {
val i: Int
val i2: Int
val i3: Int
val bs: String
constructor(ii1: Int, ii2: Int) {
i = ii1
i2 = ii2
i3 = 30
}
constructor(ii: Int): this(ii, 25) {
}
open fun foo() = bs
init {
bs = "fail"
}
}
class Test(val tt: String) : Base(18) {
override fun foo() = tt
}
fun box(): String {
val t = Test("OK")
return t.foo()
}
@@ -0,0 +1,36 @@
// EXPECTED_REACHABLE_NODES: 1114
package foo
open class Base(val bs: String) {
val i: Int
val i2: Int
val i3: Int
fun foo() = bs
init {
i = 10
i2 = 20
i3 = 30
}
}
class Test : Base {
val t1: Int
val t2: Int
constructor(tt1: Int, tt2: Int): super("OK") {
t1 = tt1
t2 = tt2
}
}
fun box(): String {
val t = Test(1, 2)
return t.foo()
}
@@ -0,0 +1,35 @@
// EXPECTED_REACHABLE_NODES: 1114
package foo
open class Base {
val i: Int
val i2: Int
val i3: Int
val bs: String
constructor(s:String) {bs = s}
fun foo() = bs
init {
i = 10
i2 = 20
i3 = 30
}
}
class Test: Base {
val t1: Int
val t2: Int
constructor(tt1: Int, tt2:Int) : super("OK") {
t1 = tt1
t2 = tt2
}
}
fun box(): String {
val t = Test(1, 2)
return t.foo()
}
@@ -0,0 +1,26 @@
// EXPECTED_REACHABLE_NODES: 1114
package foo
class Test(val bs: String) {
var i: Int = 0
var i2: Int = 0
var i3: Int =0
constructor(ii1: Int, ii2: Int): this("OK") {
i = ii1
i2 = ii2
i3 = 30
}
constructor(ii: Int): this(ii, 18) {
}
fun foo() = bs
}
fun box(): String {
val t = Test(1)
return t.foo()
}