[Tests] Add bytecodeListing tests
This commit is contained in:
committed by
TeamCityServer
parent
f05ca5be33
commit
6cd50bc438
@@ -0,0 +1,19 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
|
||||||
|
class Outer {
|
||||||
|
val x: Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Outer)
|
||||||
|
class Inner(arg: Any) {
|
||||||
|
fun bar() = x
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f(outer: Outer) {
|
||||||
|
with(outer) {
|
||||||
|
Inner(3)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class ClassKt {
|
||||||
|
// source: 'class.kt'
|
||||||
|
public final static method f(@org.jetbrains.annotations.NotNull p0: Outer): void
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class Inner {
|
||||||
|
// source: 'class.kt'
|
||||||
|
private synthetic final field contextReceiverField0: Outer
|
||||||
|
public method <init>(@org.jetbrains.annotations.NotNull p0: Outer, @org.jetbrains.annotations.NotNull p1: java.lang.Object): void
|
||||||
|
public final method bar(): int
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class Outer {
|
||||||
|
// source: 'class.kt'
|
||||||
|
private final field x: int
|
||||||
|
public method <init>(): void
|
||||||
|
public final method getX(): int
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
|
||||||
|
interface Canvas {
|
||||||
|
val suffix: String
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Shape {
|
||||||
|
context(Canvas)
|
||||||
|
fun draw(): String
|
||||||
|
}
|
||||||
|
|
||||||
|
class Circle : Shape {
|
||||||
|
context(Canvas)
|
||||||
|
override fun draw() = "OK" + suffix
|
||||||
|
}
|
||||||
|
|
||||||
|
object MyCanvas : Canvas {
|
||||||
|
override val suffix = ""
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public interface Canvas {
|
||||||
|
// source: 'canvas.kt'
|
||||||
|
public abstract @org.jetbrains.annotations.NotNull method getSuffix(): java.lang.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class Circle {
|
||||||
|
// source: 'canvas.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method draw(@org.jetbrains.annotations.NotNull p0: Canvas): java.lang.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class MyCanvas {
|
||||||
|
// source: 'canvas.kt'
|
||||||
|
public final static @org.jetbrains.annotations.NotNull field INSTANCE: MyCanvas
|
||||||
|
private final static @org.jetbrains.annotations.NotNull field suffix: java.lang.String
|
||||||
|
static method <clinit>(): void
|
||||||
|
private method <init>(): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method getSuffix(): java.lang.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public interface Shape {
|
||||||
|
// source: 'canvas.kt'
|
||||||
|
public abstract @org.jetbrains.annotations.NotNull method draw(@org.jetbrains.annotations.NotNull p0: Canvas): java.lang.String
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
|
||||||
|
data class Pair<A, B>(val first: A, val second: B)
|
||||||
|
|
||||||
|
context(Comparator<T>)
|
||||||
|
infix operator fun <T> T.compareTo(other: T) = compare(this, other)
|
||||||
|
|
||||||
|
context(Comparator<T>)
|
||||||
|
val <T> Pair<T, T>.min get() = if (first < second) first else second
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class CompareToKt {
|
||||||
|
// source: 'compareTo.kt'
|
||||||
|
public final static method compareTo(@org.jetbrains.annotations.NotNull p0: java.util.Comparator, p1: java.lang.Object, p2: java.lang.Object): int
|
||||||
|
public final static method getMin(@org.jetbrains.annotations.NotNull p0: java.util.Comparator, @org.jetbrains.annotations.NotNull p1: Pair): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class Pair {
|
||||||
|
// source: 'compareTo.kt'
|
||||||
|
private final field first: java.lang.Object
|
||||||
|
private final field second: java.lang.Object
|
||||||
|
public method <init>(p0: java.lang.Object, p1: java.lang.Object): void
|
||||||
|
public final method component1(): java.lang.Object
|
||||||
|
public final method component2(): java.lang.Object
|
||||||
|
public synthetic static method copy$default(p0: Pair, p1: java.lang.Object, p2: java.lang.Object, p3: int, p4: java.lang.Object): Pair
|
||||||
|
public final @org.jetbrains.annotations.NotNull method copy(p0: java.lang.Object, p1: java.lang.Object): Pair
|
||||||
|
public method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
|
||||||
|
public final method getFirst(): java.lang.Object
|
||||||
|
public final method getSecond(): java.lang.Object
|
||||||
|
public method hashCode(): int
|
||||||
|
public @org.jetbrains.annotations.NotNull method toString(): java.lang.String
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
|
||||||
|
class View {
|
||||||
|
val coefficient = 42
|
||||||
|
}
|
||||||
|
|
||||||
|
context(View) val Int.dp get() = coefficient * this
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class DpKt {
|
||||||
|
// source: 'dp.kt'
|
||||||
|
public final static method getDp(@org.jetbrains.annotations.NotNull p0: View, p1: int): int
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class View {
|
||||||
|
// source: 'dp.kt'
|
||||||
|
private final field coefficient: int
|
||||||
|
public method <init>(): void
|
||||||
|
public final method getCoefficient(): int
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
|
||||||
|
class Param
|
||||||
|
class O {
|
||||||
|
val o = "O"
|
||||||
|
}
|
||||||
|
class K {
|
||||||
|
val k = "K"
|
||||||
|
}
|
||||||
|
|
||||||
|
context(O)
|
||||||
|
fun <T> K.f(g: context(O) K.(Param) -> T) = g(this@O, this@K, Param())
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class FunctionalTypeKt {
|
||||||
|
// source: 'functionalType.kt'
|
||||||
|
public final static method f(@org.jetbrains.annotations.NotNull p0: O, @org.jetbrains.annotations.NotNull p1: K, @org.jetbrains.annotations.NotNull p2: kotlin.jvm.functions.Function3): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class K {
|
||||||
|
// source: 'functionalType.kt'
|
||||||
|
private final @org.jetbrains.annotations.NotNull field k: java.lang.String
|
||||||
|
public method <init>(): void
|
||||||
|
public final @org.jetbrains.annotations.NotNull method getK(): java.lang.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class O {
|
||||||
|
// source: 'functionalType.kt'
|
||||||
|
private final @org.jetbrains.annotations.NotNull field o: java.lang.String
|
||||||
|
public method <init>(): void
|
||||||
|
public final @org.jetbrains.annotations.NotNull method getO(): java.lang.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class Param {
|
||||||
|
// source: 'functionalType.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
interface Semigroup<T> {
|
||||||
|
infix fun T.combine(other: T): T
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Monoid<T> : Semigroup<T> {
|
||||||
|
val unit: T
|
||||||
|
}
|
||||||
|
object IntMonoid : Monoid<Int> {
|
||||||
|
override fun Int.combine(other: Int): Int = this + other
|
||||||
|
override val unit: Int = 0
|
||||||
|
}
|
||||||
|
object StringMonoid : Monoid<String> {
|
||||||
|
override fun String.combine(other: String): String = this + other
|
||||||
|
override val unit: String = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
context(Monoid<T>)
|
||||||
|
fun <T> List<T>.sum(): T = fold(unit) { acc, e -> acc.combine(e) }
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class IntMonoid {
|
||||||
|
// source: 'monoidSum.kt'
|
||||||
|
public final static @org.jetbrains.annotations.NotNull field INSTANCE: IntMonoid
|
||||||
|
private final static field unit: int
|
||||||
|
static method <clinit>(): void
|
||||||
|
private method <init>(): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method combine(p0: int, p1: int): java.lang.Integer
|
||||||
|
public synthetic bridge method combine(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
|
||||||
|
public @org.jetbrains.annotations.NotNull method getUnit(): java.lang.Integer
|
||||||
|
public synthetic bridge method getUnit(): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public interface Monoid {
|
||||||
|
// source: 'monoidSum.kt'
|
||||||
|
public abstract method getUnit(): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class MonoidSumKt {
|
||||||
|
// source: 'monoidSum.kt'
|
||||||
|
public final static method sum(@org.jetbrains.annotations.NotNull p0: Monoid, @org.jetbrains.annotations.NotNull p1: java.util.List): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public interface Semigroup {
|
||||||
|
// source: 'monoidSum.kt'
|
||||||
|
public abstract method combine(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class StringMonoid {
|
||||||
|
// source: 'monoidSum.kt'
|
||||||
|
public final static @org.jetbrains.annotations.NotNull field INSTANCE: StringMonoid
|
||||||
|
private final static @org.jetbrains.annotations.NotNull field unit: java.lang.String
|
||||||
|
static method <clinit>(): void
|
||||||
|
private method <init>(): void
|
||||||
|
public @org.jetbrains.annotations.NotNull method combine(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: java.lang.String): java.lang.String
|
||||||
|
public synthetic bridge method combine(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
|
||||||
|
public synthetic bridge method getUnit(): java.lang.Object
|
||||||
|
public @org.jetbrains.annotations.NotNull method getUnit(): java.lang.String
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
|
||||||
|
class C {
|
||||||
|
val c = 42
|
||||||
|
}
|
||||||
|
|
||||||
|
context(C)
|
||||||
|
fun foo() {
|
||||||
|
c
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(c: C) {
|
||||||
|
with(c) {
|
||||||
|
foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public final class C {
|
||||||
|
// source: 'function.kt'
|
||||||
|
private final field c: int
|
||||||
|
public method <init>(): void
|
||||||
|
public final method getC(): int
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class FunctionKt {
|
||||||
|
// source: 'function.kt'
|
||||||
|
public final static method bar(@org.jetbrains.annotations.NotNull p0: C): void
|
||||||
|
public final static method foo(@org.jetbrains.annotations.NotNull p0: C): void
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// !LANGUAGE: +ContextReceivers
|
||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
|
||||||
|
interface A {
|
||||||
|
fun a(): Int
|
||||||
|
}
|
||||||
|
interface B {
|
||||||
|
fun b(): Int
|
||||||
|
}
|
||||||
|
|
||||||
|
context(A, B)
|
||||||
|
val c get() = a() + b()
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
@kotlin.Metadata
|
||||||
|
public interface A {
|
||||||
|
// source: 'property.kt'
|
||||||
|
public abstract method a(): int
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public interface B {
|
||||||
|
// source: 'property.kt'
|
||||||
|
public abstract method b(): int
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class PropertyKt {
|
||||||
|
// source: 'property.kt'
|
||||||
|
public final static method getC(@org.jetbrains.annotations.NotNull p0: B, @org.jetbrains.annotations.NotNull p1: A): int
|
||||||
|
}
|
||||||
+20
@@ -847,6 +847,26 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@TestMetadata("compiler/testData/codegen/bytecodeListing/contextReceivers")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
public class ContextReceivers {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInContextReceivers() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@TestMetadata("compiler/testData/codegen/bytecodeListing/contextReceivers/fromKEEP")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
public class FromKEEP {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInFromKEEP() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@TestMetadata("compiler/testData/codegen/bytecodeListing/coroutines")
|
@TestMetadata("compiler/testData/codegen/bytecodeListing/coroutines")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
|||||||
+68
@@ -895,6 +895,74 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@TestMetadata("compiler/testData/codegen/bytecodeListing/contextReceivers")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
public class ContextReceivers {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInContextReceivers() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("class.kt")
|
||||||
|
public void testClass() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/contextReceivers/class.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("function.kt")
|
||||||
|
public void testFunction() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/contextReceivers/function.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("property.kt")
|
||||||
|
public void testProperty() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/contextReceivers/property.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@TestMetadata("compiler/testData/codegen/bytecodeListing/contextReceivers/fromKEEP")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
public class FromKEEP {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInFromKEEP() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("canvas.kt")
|
||||||
|
public void testCanvas() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/contextReceivers/fromKEEP/canvas.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("compareTo.kt")
|
||||||
|
public void testCompareTo() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/contextReceivers/fromKEEP/compareTo.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("dp.kt")
|
||||||
|
public void testDp() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/contextReceivers/fromKEEP/dp.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("functionalType.kt")
|
||||||
|
public void testFunctionalType() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/contextReceivers/fromKEEP/functionalType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("monoidSum.kt")
|
||||||
|
public void testMonoidSum() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/contextReceivers/fromKEEP/monoidSum.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
@TestMetadata("compiler/testData/codegen/bytecodeListing/coroutines")
|
@TestMetadata("compiler/testData/codegen/bytecodeListing/coroutines")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
|||||||
Reference in New Issue
Block a user