tests: Update external tests (1.1.2-dev-393)

This commit is contained in:
Ilya Matveev
2017-03-13 12:38:08 +03:00
committed by ilmat192
parent ac56fccb15
commit bc074e6d39
3178 changed files with 22396 additions and 696 deletions
@@ -0,0 +1,61 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
// FILE: Test.java
import java.lang.annotation.Annotation;
class Test {
public static String test1() throws NoSuchMethodException {
Annotation[] test1s = A.class.getMethod("test1").getAnnotations();
for (Annotation test : test1s) {
String name = test.toString();
if (name.contains("testAnnotation")) {
return "OK";
}
}
return "fail";
}
public static String test2() throws NoSuchMethodException {
Annotation[] test2s = B.class.getMethod("test1").getAnnotations();
for (Annotation test : test2s) {
String name = test.toString();
if (name.contains("testAnnotation")) {
return "OK";
}
}
return "fail";
}
}
// FILE: test.kt
@Retention(AnnotationRetention.RUNTIME)
annotation class testAnnotation
class A {
companion object {
val b: String = "OK"
@JvmStatic @testAnnotation fun test1() = b
}
}
object B {
val b: String = "OK"
@JvmStatic @testAnnotation fun test1() = b
}
fun box(): String {
if (Test.test1() != "OK") return "fail 1"
if (Test.test2() != "OK") return "fail 2"
return "OK"
}
@@ -0,0 +1,51 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
object A {
val b: String = "OK"
@JvmStatic val c: String = "OK"
@JvmStatic fun test1() : String {
return {b}()
}
@JvmStatic fun test2() : String {
return {test1()}()
}
fun test3(): String {
return {"1".test5()}()
}
@JvmStatic fun test4(): String {
return {"1".test5()}()
}
@JvmStatic fun String.test5() : String {
return {this + b}()
}
fun test6(): String {
return {c}()
}
}
fun box(): String {
if (A.test1() != "OK") return "fail 1"
if (A.test2() != "OK") return "fail 2"
if (A.test3() != "1OK") return "fail 3"
if (A.test4() != "1OK") return "fail 4"
if (with(A) {"1".test5()} != "1OK") return "fail 5"
if (A.test6() != "OK") return "fail 6"
return "OK"
}
@@ -0,0 +1,54 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
// FILE: Test.java
class Test {
public static String test1() {
return A.test1();
}
public static String test2() {
return A.test2();
}
public static String test3() {
return A.test3("JAVA");
}
public static String test4() {
return A.getC();
}
}
// FILE: simpleCompanionObject.kt
class A {
companion object {
val b: String = "OK"
@JvmStatic val c: String = "OK"
@JvmStatic fun test1() = b
@JvmStatic fun test2() = b
@JvmStatic fun String.test3() = this + b
}
}
fun box(): String {
if (Test.test1() != "OK") return "fail 1"
if (Test.test2() != "OK") return "fail 2"
if (Test.test3() != "JAVAOK") return "fail 3"
if (Test.test4() != "OK") return "fail 4"
return "OK"
}
@@ -0,0 +1,36 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
class B(var s: Int = 0) {
}
object A {
fun test1(v: B) {
v += B(1000)
}
@JvmStatic operator fun B.plusAssign(b: B) {
this.s += b.s
}
}
fun box(): String {
val b1 = B(11)
with(A) {
b1 += B(1000)
}
if (b1.s != 1011) return "fail 1"
val b = B(11)
A.test1(b)
if (b.s != 1011) return "fail 2"
return "OK"
}
@@ -0,0 +1,18 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
object A {
@JvmStatic fun test(b: String = "OK") : String {
return b
}
}
fun box(): String {
if (A.test() != "OK") return "fail 1"
return "OK"
}
@@ -0,0 +1,46 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
// FILE: Test.java
class Test {
public static String foo() {
return A.foo;
}
public static String constBar() {
return A.constBar;
}
public static String getBar() {
return A.getBar();
}
public static String baz() {
return A.baz();
}
}
// FILE: enumCompanionObject.kt
enum class A {
;
companion object {
@JvmField val foo: String = "OK"
const val constBar: String = "OK"
@JvmStatic val bar: String = "OK"
@JvmStatic fun baz() = foo
}
}
fun box(): String {
if (Test.foo() != "OK") return "Fail foo"
if (Test.constBar() != "OK") return "Fail bar"
if (Test.getBar() != "OK") return "Fail getBar"
if (Test.baz() != "OK") return "Fail baz"
return "OK"
}
@@ -0,0 +1,37 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
object AX {
@JvmStatic val c: String = "OK"
@JvmStatic fun aStatic(): String {
return AX.b()
}
fun aNonStatic(): String {
return AX.b()
}
@JvmStatic fun b(): String {
return "OK"
}
fun getProperty(): String {
return AX.c
}
}
fun box() : String {
if (AX.aStatic() != "OK") return "fail 1"
if (AX.aNonStatic() != "OK") return "fail 2"
if (AX.getProperty() != "OK") return "fail 3"
return "OK"
}
@@ -0,0 +1,21 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
var holder = ""
fun getA(): A {
holder += "OK"
return A
}
object A {
@JvmStatic fun a(): String {
return holder
}
}
fun box(): String {
return getA().a()
}
@@ -0,0 +1,35 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
import O.p
import O.f
import C.Companion.p1
import C.Companion.f1
object O {
@JvmStatic
fun f(): Int = 3
@JvmStatic
val p: Int = 6
}
class C {
companion object {
@JvmStatic
fun f1(): Int = 3
@JvmStatic
val p1: Int = 6
}
}
fun box(): String {
if (p + f() != 9) return "fail"
if (p1 + f1() != 9) return "fail2"
return "OK"
}
@@ -0,0 +1,18 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
object A {
@JvmStatic inline fun test(b: String = "OK") : String {
return b
}
}
fun box(): String {
if (A.test() != "OK") return "fail 1"
return "OK"
}
@@ -0,0 +1,18 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
var result = "fail 1"
object Foo {
@JvmStatic
private val a = "OK"
fun foo() = run { result = a }
}
fun box(): String {
Foo.foo()
return result
}
@@ -0,0 +1,46 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
object Test {
var z = "0"
var l = 0L
fun changeObject(): String {
"1".someProperty += 1
return z
}
fun changeLong(): Long {
2L.someProperty -= 1
return l
}
@JvmStatic var String.someProperty: Int
get() {
return this.length
}
set(left) {
z += this + left
}
@JvmStatic var Long.someProperty: Long
get() {
return l
}
set(left) {
l += this + left
}
}
fun box(): String {
val changeObject = Test.changeObject()
if (changeObject != "012") return "fail 1: $changeObject"
val changeLong = Test.changeLong()
if (changeLong != 1L) return "fail 1: $changeLong"
return "OK"
}
@@ -0,0 +1,52 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
// FILE: Test.java
class Test {
public static String test1() {
return A.test1();
}
public static String test2() {
return A.test2();
}
public static String test3() {
return A.test3("JAVA");
}
public static String test4() {
return A.getC();
}
}
// FILE: simpleObject.kt
object A {
val b: String = "OK"
@JvmStatic val c: String = "OK"
@JvmStatic fun test1() = b
@JvmStatic fun test2() = b
@JvmStatic fun String.test3() = this + b
}
fun box(): String {
if (Test.test1() != "OK") return "fail 1"
if (Test.test2() != "OK") return "fail 2"
if (Test.test3() != "JAVAOK") return "fail 3"
if (Test.test4() != "OK") return "fail 4"
return "OK"
}
@@ -0,0 +1,50 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
object A {
@JvmStatic var a: Int = 1
var b: Int = 1
@JvmStatic get
var c: Int = 1
@JvmStatic set
}
var holder = ""
fun getA(): A {
holder += "getA()"
return A
}
fun box(): String {
var p = A.a++
if (p != 1 || A.a != 2) return "fail 1"
p = A.b++
if (p != 1 || A.b != 2) return "fail 2"
p = A.c++
if (p != 1 || A.c != 2) return "fail 3"
p = getA().a++
if (p != 2 || A.a != 3 || holder != "getA()") return "fail 4: $holder"
holder = ""
p = getA().b++
if (p != 2 || A.b != 3 || holder != "getA()") return "fail 5: $holder"
holder = ""
p = getA().c++
if (p != 2 || A.c != 3 || holder != "getA()") return "fail 6: $holder"
holder = ""
return "OK"
}
@@ -0,0 +1,50 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
object A {
@JvmStatic var a: Int = 1
var b: Int = 1
@JvmStatic get
var c: Int = 1
@JvmStatic set
}
var holder = ""
fun getA(): A {
holder += "getA()"
return A
}
fun box(): String {
var p = ++A.a
if (p != 2 || A.a != 2) return "fail 1"
p = ++A.b
if (p != 2 || A.b != 2) return "fail 2"
p = ++A.c
if (p != 2 || A.c != 2) return "fail 3"
p = ++getA().a
if (p != 3 || A.a != 3 || holder != "getA()") return "fail 4: $holder"
holder = ""
p = ++getA().b
if (p != 3 || A.b != 3 || holder != "getA()") return "fail 5: $holder"
holder = ""
p = ++getA().c
if (p != 3 || A.c != 3 || holder != "getA()") return "fail 6: $holder"
holder = ""
return "OK"
}
@@ -0,0 +1,19 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
object A {
private @JvmStatic fun a(): String {
return "OK"
}
object Z {
val p = a()
}
}
fun box(): String {
return A.Z.p
}
@@ -0,0 +1,27 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
// FILE: JavaClass.java
class JavaClass {
public static String test()
{
return TestApp.getValue();
}
}
// FILE: Kotlin.kt
open class TestApp {
companion object {
@JvmStatic
var value: String = "OK"
private set
}
}
fun box(): String {
return JavaClass.test()
}
@@ -0,0 +1,50 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
var holder = ""
fun getA(): A {
holder += "getA()"
return A
}
object A {
@JvmStatic var a: Int = 1
var b: Int = 1
@JvmStatic get
var c: Int = 1
@JvmStatic set
}
fun box(): String {
if (getA().a != 1 || holder != "getA()") return "fail 1: $holder"
holder = ""
if (getA().b != 1 || holder != "getA()") return "fail 2: $holder"
holder = ""
if (getA().c != 1 || holder != "getA()") return "fail 3: $holder"
holder = ""
getA().a = 2
if (getA().a != 2 || holder != "getA()getA()") return "fail 1: $holder"
holder = ""
getA().b = 2
if (getA().b != 2 || holder != "getA()getA()") return "fail 2: $holder"
holder = ""
getA().c = 2
if (getA().c != 2 || holder != "getA()getA()") return "fail 3: $holder"
holder = ""
return "OK"
}
@@ -0,0 +1,23 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
var result = "fail 2"
class Foo {
val b = { a }
val c = Runnable { result = a }
companion object {
@JvmStatic
private val a = "OK"
}
}
fun box(): String {
if (Foo().b() != "OK") return "fail 1"
Foo().c.run()
return result
}
@@ -0,0 +1,21 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
var result = "fail 2"
object Foo {
@JvmStatic
private val a = "OK"
val b = { a }
val c = Runnable { result = a }
}
fun box(): String {
if (Foo.b() != "OK") return "fail 1"
Foo.c.run()
return result
}
@@ -0,0 +1,14 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
object X {
@JvmStatic val x = "OK"
fun fn(value : String = x): String = value
}
fun box(): String {
return X.fn()
}
@@ -0,0 +1,12 @@
// WITH_RUNTIME
// TARGET_BACKEND: JVM
object ObjectThisTest {
val testValue: String
@JvmStatic get() = this.testValue2
val testValue2: String
get() = "OK"
}
fun box() = ObjectThisTest.testValue
@@ -0,0 +1,47 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
object A {
val b: String = "OK"
@JvmStatic val c: String = "OK"
@JvmStatic fun test1() : String {
return b
}
@JvmStatic fun test2() : String {
return test1()
}
fun test3(): String {
return "1".test5()
}
@JvmStatic fun test4(): String {
return "1".test5()
}
@JvmStatic fun String.test5() : String {
return this + b
}
}
fun box(): String {
if (A.test1() != "OK") return "fail 1"
if (A.test2() != "OK") return "fail 2"
if (A.test3() != "1OK") return "fail 3"
if (A.test4() != "1OK") return "fail 4"
if (with(A) {"1".test5()} != "1OK") return "fail 5"
if (A.c != "OK") return "fail 6"
return "OK"
}
@@ -0,0 +1,20 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_RUNTIME
class C {
companion object {
private @JvmStatic fun foo(): String {
return "OK"
}
}
fun bar(): String {
return foo()
}
}
fun box(): String {
return C().bar()
}