Add ir interpreter tests

This commit is contained in:
Ivan Kylchik
2021-05-19 16:27:03 +03:00
committed by TeamCityServer
parent cc2d7340dc
commit e28ab45c51
115 changed files with 5104 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
package test
import kotlin.reflect.KFunction
import kotlin.collections.*
@CompileTimeCalculation
class A(val a: Int, val b: String) {
val String.propertyWithExtension: Int
get() = this.length * a
fun Int.funWithExtension(other: Int) = this + other
}
const val aSimpleName = <!EVALUATED: `A`!>A::class.simpleName!!<!>
const val aQualifiedName = <!EVALUATED: `test.A`!>A::class.qualifiedName!!<!>
//const val aMembers = A::class.members.joinToString() TODO -> `val test.A.a: kotlin.Int, val test.A.b: kotlin.String, val test.A.(kotlin.String.)propertyWithExtension: kotlin.Int, fun test.A.(kotlin.Int.)funWithExtension(kotlin.Int): kotlin.Int, fun test.A.equals(kotlin.Any?): kotlin.Boolean, fun test.A.hashCode(): kotlin.Int, fun test.A.toString(): kotlin.String`
const val aConstructors = A::class.constructors.<!EVALUATED: `fun <init>(kotlin.Int, kotlin.String): test.A`!>joinToString()<!>
const val aVisibility = A::class.visibility.<!EVALUATED: `PUBLIC`!>toString()<!>
const val aSupertypes = A::class.supertypes.<!EVALUATED: `kotlin.Any`!>joinToString()<!>
@CompileTimeCalculation
interface Base<T>
@CompileTimeCalculation
class B<T, E : T, D : Any>(val prop: T) : Base<T> {
fun get(): T = prop
fun getThis(): B<T, out E, in D> = this
fun <E : Number> withTypeParameter(num: E) = num.toString()
}
//const val bMembers = B::class.members.joinToString() TODO -> `val test.B<T, E, D>.prop: T, fun test.B<T, E, D>.get(): T, fun test.B<T, E, D>.getThis(): test.B<T, out E, in D>, fun test.B<T, E, D>.withTypeParameter(E): kotlin.String, fun test.B<T, E, D>.equals(kotlin.Any?): kotlin.Boolean, fun test.B<T, E, D>.hashCode(): kotlin.Int, fun test.B<T, E, D>.toString(): kotlin.String`
const val bTypeParameters = B::class.typeParameters.<!EVALUATED: `T, E, D`!>joinToString()<!>
const val bSupertypes = B::class.supertypes.<!EVALUATED: `test.Base<T>, kotlin.Any`!>joinToString()<!>
//const val bReturnType1 = B::class.members.toList()[1].returnType.toString() TODO -> `T`
//const val bReturnType2 = B::class.members.toList()[3].returnType.toString() TODO -> `kotlin.String`
const val arguments1 = (B<Number, Double, Int>(1)::getThis as KFunction<*>).returnType.arguments.<!EVALUATED: `T, out E, in D`!>joinToString()<!>
const val arguments2 = (arrayOf(1)::iterator as KFunction<*>).returnType.arguments.<!EVALUATED: `T`!>joinToString()<!>
@CompileTimeCalculation
class C {
val String.getLength
get() = this.length
}
//const val cMember = C::class.members.toList()[0].toString() TODO -> `val test.C.(kotlin.String.)getLength: kotlin.Int`
//const val cMemberReturnType = C::class.members.toList()[0].returnType.classifier.toString() TODO -> `class kotlin.Int`
+26
View File
@@ -0,0 +1,26 @@
const val byteMax = <!EVALUATED: `127`!>{ java.lang.Byte.MAX_VALUE }()<!>
const val byteMin = <!EVALUATED: `-128`!>{ java.lang.Byte.MIN_VALUE }()<!>
const val byteSize = <!EVALUATED: `8`!>{ java.lang.Byte.SIZE }()<!>
const val byteBytes = <!EVALUATED: `1`!>{ java.lang.Byte.BYTES }()<!>
const val intMax = <!EVALUATED: `2147483647`!>{ java.lang.Integer.MAX_VALUE }()<!>
const val intMin = <!EVALUATED: `-2147483648`!>{ java.lang.Integer.MIN_VALUE }()<!>
const val intSize = <!EVALUATED: `32`!>{ java.lang.Integer.SIZE }()<!>
const val intBytes = <!EVALUATED: `4`!>{ java.lang.Integer.BYTES }()<!>
const val floatMax = <!EVALUATED: `3.4028235E38`!>{ java.lang.Float.MAX_VALUE }()<!>
const val floatMin = <!EVALUATED: `1.4E-45`!>{ java.lang.Float.MIN_VALUE }()<!>
const val floatSize = <!EVALUATED: `32`!>{ java.lang.Float.SIZE }()<!>
const val floatBytes = <!EVALUATED: `4`!>{ java.lang.Float.BYTES }()<!>
const val floatMaxExponent = <!EVALUATED: `127`!>{ java.lang.Float.MAX_EXPONENT }()<!>
const val floatMinExponent = <!EVALUATED: `-126`!>{ java.lang.Float.MIN_EXPONENT }()<!>
const val floatNegInfinity = <!EVALUATED: `-Infinity`!>{ java.lang.Float.NEGATIVE_INFINITY }()<!>
const val floatPosInfinity = <!EVALUATED: `Infinity`!>{ java.lang.Float.POSITIVE_INFINITY }()<!>
const val booleanFalse = { java.lang.Boolean.FALSE }().<!EVALUATED: `false`!>toString()<!>
const val booleanTrue = { java.lang.Boolean.TRUE }().<!EVALUATED: `true`!>toString()<!>
const val charMax = { java.lang.Character.MAX_VALUE }().<!EVALUATED: `65535`!>toInt()<!>
const val charMin = { java.lang.Character.MIN_VALUE }().<!EVALUATED: `0`!>toInt()<!>
const val charSize = <!EVALUATED: `16`!>{ java.lang.Character.SIZE }()<!>
const val charBytes = <!EVALUATED: `2`!>{ java.lang.Character.BYTES }()<!>
+11
View File
@@ -0,0 +1,11 @@
package test
import kotlin.collections.*
@CompileTimeCalculation
class A(val a: Int) {
val String.size: Int
get() = this.length * a
}
//const val kproperty2Get = A::class.members.toList()[1].call(A(2), "123").toString() TODO -> `6`
@@ -0,0 +1,29 @@
package test
import kotlin.reflect.KFunction
import kotlin.collections.*
@CompileTimeCalculation
fun withParameters(a: Int, b: Double) = 0
@CompileTimeCalculation
fun String.withExtension(a: Int) = 0
@CompileTimeCalculation
class A {
fun String.get(a: Int) = this
}
const val parameters1 = (::withParameters as KFunction<*>).parameters.<!EVALUATED: `parameter #0 a of fun withParameters(kotlin.Int, kotlin.Double): kotlin.Int, parameter #1 b of fun withParameters(kotlin.Int, kotlin.Double): kotlin.Int`!>joinToString()<!>
const val parameters2 = (String::withExtension as KFunction<*>).parameters.<!EVALUATED: `extension receiver parameter of fun kotlin.String.withExtension(kotlin.Int): kotlin.Int, parameter #1 a of fun kotlin.String.withExtension(kotlin.Int): kotlin.Int`!>joinToString()<!>
//const val parameters3 = A::class.members.toList()[0].parameters.joinToString() TODO -> `instance parameter of fun test.A.(kotlin.String.)get(kotlin.Int): kotlin.String, extension receiver parameter of fun test.A.(kotlin.String.)get(kotlin.Int): kotlin.String, parameter #2 a of fun test.A.(kotlin.String.)get(kotlin.Int): kotlin.String`
// properties
@CompileTimeCalculation
class B(val b: Int) {
val String.size: Int
get() = this.length
}
const val property0Parameters = B(1)::b.parameters.<!EVALUATED: `[]`!>toString()<!>
const val property1Parameters = B::b.parameters.<!EVALUATED: `[instance parameter of val test.B.b: kotlin.Int]`!>toString()<!>
//const val property2Parameters = B::class.members.toList()[1].parameters.toString() TODO -> `[instance parameter of val test.B.(kotlin.String.)size: kotlin.Int, extension receiver parameter of val test.B.(kotlin.String.)size: kotlin.Int]`