Move everything under kotlin-native folder
I was forced to manually do update the following files, because otherwise they would be ignored according .gitignore settings. Probably they should be deleted from repo. Interop/.idea/compiler.xml Interop/.idea/gradle.xml Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml Interop/.idea/modules.xml Interop/.idea/modules/Indexer/Indexer.iml Interop/.idea/modules/Runtime/Runtime.iml Interop/.idea/modules/StubGenerator/StubGenerator.iml backend.native/backend.native.iml backend.native/bc.frontend/bc.frontend.iml backend.native/cli.bc/cli.bc.iml backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt backend.native/tests/link/lib/foo.kt backend.native/tests/link/lib/foo2.kt backend.native/tests/teamcity-test.property
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.companionObject
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Game {
|
||||
ROCK,
|
||||
PAPER,
|
||||
SCISSORS;
|
||||
|
||||
companion object {
|
||||
fun foo() = ROCK
|
||||
val bar = PAPER
|
||||
val values2 = values()
|
||||
val scissors = valueOf("SCISSORS")
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Game.foo() != Game.ROCK) return "Fail 1"
|
||||
if (Game.bar != Game.PAPER) return "Fail 2: ${Game.bar}"
|
||||
if (Game.values().size != 3) return "Fail 3"
|
||||
if (Game.valueOf("SCISSORS") != Game.SCISSORS) return "Fail 4"
|
||||
if (Game.values2.size != 3) return "Fail 5"
|
||||
if (Game.scissors != Game.SCISSORS) return "Fail 6"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@Test fun runTest() = println(box())
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.interfaceCallNoEntryClass
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface A {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
enum class Zzz(val zzz: String, val x: Int) : A {
|
||||
Z1("z1", 1),
|
||||
Z2("z2", 2),
|
||||
Z3("z3", 3);
|
||||
|
||||
override fun foo(): String{
|
||||
return "('$zzz', $x)"
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z3.foo())
|
||||
val a: A = Zzz.Z3
|
||||
println(a.foo())
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.interfaceCallWithEntryClass
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface A {
|
||||
fun f(): String
|
||||
}
|
||||
|
||||
enum class Zzz: A {
|
||||
Z1 {
|
||||
override fun f() = "z1"
|
||||
},
|
||||
|
||||
Z2 {
|
||||
override fun f() = "z2"
|
||||
};
|
||||
|
||||
override fun f() = ""
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z1.f() + Zzz.Z2.f())
|
||||
val a1: A = Zzz.Z1
|
||||
val a2: A = Zzz.Z2
|
||||
println(a1.f() + a2.f())
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.isFrozen
|
||||
|
||||
import kotlin.test.*
|
||||
import kotlin.native.concurrent.*
|
||||
|
||||
enum class Zzz(val zzz: String) {
|
||||
Z1("z1"),
|
||||
Z2("z2")
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z1.isFrozen)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.lambdaInDefault
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Zzz(val value: String.() -> Int = {
|
||||
length
|
||||
}) {
|
||||
Q()
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Q)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package a
|
||||
|
||||
enum class A(val x: Int) {
|
||||
Z1(42),
|
||||
Z2(117),
|
||||
Z3(-1)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import a.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
println(A.Z1.x)
|
||||
println(A.valueOf("Z2").x)
|
||||
println(A.values()[2].x)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.loop
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Zzz {
|
||||
Z {
|
||||
init {
|
||||
println(Z.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.nested
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Foo {
|
||||
A;
|
||||
enum class Bar { C }
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Foo.A)
|
||||
println(Foo.Bar.C)
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.reorderedArguments
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// Regression test for https://github.com/JetBrains/kotlin-native/issues/1779
|
||||
enum class Foo(val a: Int, val b: Int, val c: Int = 0) {
|
||||
A(a = 1, b = 0),
|
||||
B(b = 1, a = 0),
|
||||
C(c = 1, b = 0, a = 0),
|
||||
D(0, 0),
|
||||
E(1, 1, 1)
|
||||
}
|
||||
|
||||
interface Base<T> {
|
||||
val value: T
|
||||
}
|
||||
|
||||
enum class Bar(override val value: Foo) : Base<Foo> {
|
||||
A(Foo.A),
|
||||
B(Foo.B),
|
||||
C(Foo.C),
|
||||
D(Foo.D),
|
||||
E(Foo.E)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
|
||||
assertEquals(Foo.A.a, 1)
|
||||
assertEquals(Foo.A.b, 0)
|
||||
assertEquals(Foo.A.c, 0)
|
||||
|
||||
assertEquals(Foo.B.a, 0)
|
||||
assertEquals(Foo.B.b, 1)
|
||||
assertEquals(Foo.B.c, 0)
|
||||
|
||||
assertEquals(Foo.C.a, 0)
|
||||
assertEquals(Foo.C.b, 0)
|
||||
assertEquals(Foo.C.c, 1)
|
||||
|
||||
assertEquals(Foo.D.a, 0)
|
||||
assertEquals(Foo.D.b, 0)
|
||||
assertEquals(Foo.D.c, 0)
|
||||
|
||||
assertEquals(Foo.E.a, 1)
|
||||
assertEquals(Foo.E.b, 1)
|
||||
assertEquals(Foo.E.c, 1)
|
||||
|
||||
assertEquals(Bar.A.value.a, 1)
|
||||
assertEquals(Bar.A.value.b, 0)
|
||||
assertEquals(Bar.A.value.c, 0)
|
||||
|
||||
assertEquals(Bar.B.value.a, 0)
|
||||
assertEquals(Bar.B.value.b, 1)
|
||||
assertEquals(Bar.B.value.c, 0)
|
||||
|
||||
assertEquals(Bar.C.value.a, 0)
|
||||
assertEquals(Bar.C.value.b, 0)
|
||||
assertEquals(Bar.C.value.c, 1)
|
||||
|
||||
assertEquals(Bar.D.value.a, 0)
|
||||
assertEquals(Bar.D.value.b, 0)
|
||||
assertEquals(Bar.D.value.c, 0)
|
||||
|
||||
assertEquals(Bar.E.value.a, 1)
|
||||
assertEquals(Bar.E.value.b, 1)
|
||||
assertEquals(Bar.E.value.c, 1)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.switchLowering
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class EnumA {
|
||||
A, B, C
|
||||
}
|
||||
|
||||
enum class EnumB {
|
||||
A, B
|
||||
}
|
||||
|
||||
enum class E {
|
||||
ONE, TWO, THREE
|
||||
}
|
||||
|
||||
fun produceEntry() = EnumA.A
|
||||
|
||||
// Check that we fail on comparison of different enum types.
|
||||
fun differentEnums() {
|
||||
println(when (produceEntry()) {
|
||||
EnumB.A -> "EnumB.A"
|
||||
EnumA.A -> "EnumA.A"
|
||||
EnumA.B -> "EnumA.B"
|
||||
else -> "nah"
|
||||
})
|
||||
}
|
||||
|
||||
// Nullable subject shouldn't be lowered.
|
||||
fun nullable() {
|
||||
val x: EnumA? = null
|
||||
when(x) {
|
||||
EnumA.A -> println("fail")
|
||||
else -> println("ok")
|
||||
}
|
||||
}
|
||||
|
||||
// Operator overloading won't trick us!
|
||||
fun operatorOverloading() {
|
||||
operator fun E.contains(other: E): Boolean = false
|
||||
|
||||
val y = E.ONE
|
||||
when(y) {
|
||||
in E.ONE -> println("Should not reach here")
|
||||
else -> println("ok")
|
||||
}
|
||||
}
|
||||
|
||||
fun smoke1() {
|
||||
when (produceEntry()) {
|
||||
EnumA.B -> println("error")
|
||||
EnumA.A -> println("ok")
|
||||
EnumA.C -> println("error")
|
||||
}
|
||||
}
|
||||
|
||||
fun smoke2() {
|
||||
when (produceEntry()) {
|
||||
EnumA.B -> println("error")
|
||||
else -> println("ok")
|
||||
}
|
||||
}
|
||||
|
||||
fun eA() = EnumA.A
|
||||
|
||||
fun eB() = EnumA.B
|
||||
|
||||
|
||||
fun nestedWhen() {
|
||||
println(when (eA()) {
|
||||
EnumA.A, EnumA.C -> when (eB()) {
|
||||
EnumA.B -> "ok"
|
||||
else -> "nope"
|
||||
}
|
||||
else -> "nope"
|
||||
})
|
||||
}
|
||||
|
||||
fun main() {
|
||||
differentEnums()
|
||||
nullable()
|
||||
operatorOverloading()
|
||||
smoke1()
|
||||
smoke2()
|
||||
nestedWhen()
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.test0
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val TOP_LEVEL = 5
|
||||
|
||||
enum class MyEnum(value: Int) {
|
||||
VALUE(TOP_LEVEL)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(MyEnum.VALUE.toString())
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.test1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Zzz(val zzz: String, val x: Int) {
|
||||
Z1("z1", 1),
|
||||
Z2("z2", 2)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z1.zzz + Zzz.Z2.x)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.vCallNoEntryClass
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Zzz(val zzz: String, val x: Int) {
|
||||
Z1("z1", 1),
|
||||
Z2("z2", 2),
|
||||
Z3("z3", 3);
|
||||
|
||||
override fun toString(): String{
|
||||
return "('$zzz', $x)"
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z3.toString())
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.vCallWithEntryClass
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Zzz {
|
||||
Z1 {
|
||||
override fun f() = "z1"
|
||||
},
|
||||
|
||||
Z2 {
|
||||
override fun f() = "z2"
|
||||
};
|
||||
|
||||
open fun f() = ""
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Zzz.Z1.f() + Zzz.Z2.f())
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.valueOf
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class E {
|
||||
E3,
|
||||
E1,
|
||||
E2
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(E.valueOf("E1").toString())
|
||||
println(E.valueOf("E2").toString())
|
||||
println(E.valueOf("E3").toString())
|
||||
println(enumValueOf<E>("E1").toString())
|
||||
println(enumValueOf<E>("E2").toString())
|
||||
println(enumValueOf<E>("E3").toString())
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.values
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class E {
|
||||
E3,
|
||||
E1,
|
||||
E2
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(E.values()[0].toString())
|
||||
println(E.values()[1].toString())
|
||||
println(E.values()[2].toString())
|
||||
println(enumValues<E>()[0].toString())
|
||||
println(enumValues<E>()[1].toString())
|
||||
println(enumValues<E>()[2].toString())
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.enum.varargParam
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class Piece(vararg val states: Int) {
|
||||
I(3, 4, 5)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Piece.I.states[0])
|
||||
}
|
||||
Reference in New Issue
Block a user