backend/tests: Add blackbox tests from Kotlin JVM

Added tests from testData/codegen/box directory. There are blackbox tests
in other directories and they are to be added.
This commit is contained in:
Ilya Matveev
2017-01-12 19:43:20 +07:00
parent d5988297b1
commit 1b553ebfaf
2643 changed files with 66666 additions and 0 deletions
@@ -0,0 +1,9 @@
// See also KT-6299
public open class Outer private constructor() {
class Inner: Outer()
}
fun box(): String {
val outer = Outer.Inner()
return "OK"
}
@@ -0,0 +1,10 @@
public open class Outer private constructor(val s: String) {
companion object {
fun test () = { Outer("OK") }()
}
}
fun box(): String {
return Outer.test().s
}
@@ -0,0 +1,11 @@
// See also KT-6299
public open class Outer private constructor() {
companion object {
fun foo() = Outer()
}
}
fun box(): String {
val outer = Outer.foo()
return "OK"
}
@@ -0,0 +1,11 @@
// See also KT-6299
public open class Outer private constructor() {
companion object {
internal inline fun foo() = Outer()
}
}
fun box(): String {
val outer = Outer.foo()
return "OK"
}
@@ -0,0 +1,15 @@
// See also KT-6299
public open class Outer private constructor(val s: String) {
inner class Inner: Outer("O") {
fun foo(): String {
return this.s + this@Outer.s
}
}
class Nested: Outer("K")
fun bar() = Inner()
}
fun box(): String {
val inner = Outer.Nested().bar()
return inner.foo()
}
@@ -0,0 +1,12 @@
open class A private constructor() {
companion object : A() {
}
class B: A()
}
fun box(): String {
val a = A
val b = A.B()
return "OK"
}
@@ -0,0 +1,9 @@
// See also KT-6299
public open class Outer private constructor(val x: Int) {
constructor(): this(42)
}
fun box(): String {
val outer = Outer()
return "OK"
}
@@ -0,0 +1,31 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
// WITH_RUNTIME
// private constructors are transformed into synthetic
class PrivateConstructor private constructor() {
class Nested { val a = PrivateConstructor() }
}
fun check(klass: Class<*>) {
var hasSynthetic = false
var hasSimple = false
for (method in klass.getDeclaredConstructors()) {
if (method.isSynthetic()) {
hasSynthetic = true
}
else {
hasSimple = true
}
}
if (hasSynthetic && hasSimple) return
throw AssertionError("Class should have both synthetic and non-synthetic constructor: ($hasSynthetic, $hasSimple)")
}
fun box(): String {
check(PrivateConstructor::class.java)
// Also check that synthetic accessors really work
PrivateConstructor.Nested()
return "OK"
}
@@ -0,0 +1,13 @@
// See also KT-6299
public open class Outer private constructor(val s: String, val f: Boolean = true) {
class Inner: Outer("xyz")
class Other: Outer("abc", true)
class Another: Outer("", false)
}
fun box(): String {
val outer = Outer.Inner()
val other = Outer.Other()
val another = Outer.Another()
return "OK"
}
@@ -0,0 +1,11 @@
// See also KT-6299
public open class Outer private constructor(val x: Int = 0) {
class Inner: Outer()
class Other: Outer(42)
}
fun box(): String {
val outer = Outer.Inner()
val other = Outer.Other()
return "OK"
}
@@ -0,0 +1,12 @@
// See also KT-6299
public open class Outer private constructor(val p: Outer?) {
object First: Outer(null)
class Other(p: Outer = First): Outer(p)
}
fun box(): String {
val second = Outer.Other()
val third = Outer.Other(second)
val fourth = Outer.Other(third)
return "OK"
}
@@ -0,0 +1,13 @@
// See also KT-6299
public open class Outer private constructor(val p: Outer?) {
object Inner: Outer(null)
object Other: Outer(Inner)
object Another: Outer(Other)
}
fun box(): String {
val outer = Outer.Inner
val other = Outer.Other
val another = Outer.Another
return "OK"
}
@@ -0,0 +1,13 @@
// See also KT-6299
public open class Outer private constructor(val s: String, vararg i: Int) {
class Inner: Outer("xyz")
class Other: Outer("abc", 1, 2, 3)
class Another: Outer("", 42)
}
fun box(): String {
val outer = Outer.Inner()
val other = Outer.Other()
val another = Outer.Another()
return "OK"
}