Add more tests in uncommonCases folder
1) dataClass.kt - test with data class 2) receiver.kt - test with Int extension receiver 3) delegation.kt - test with implementation by delegation
This commit is contained in:
committed by
Mikhail Glukhikh
parent
b8ef09a157
commit
262f57d938
@@ -0,0 +1,55 @@
|
||||
data class Vector(val x: Int, val y: Int) {
|
||||
// Vector
|
||||
// │ constructor Vector(Int, Int)
|
||||
// │ │ val (Vector).x: Int
|
||||
// │ │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ │ Vector.plus.other: Vector
|
||||
// │ │ │ │ │ val (Vector).x: Int
|
||||
// │ │ │ │ │ │ val (Vector).y: Int
|
||||
// │ │ │ │ │ │ │ fun (Int).plus(Int): Int
|
||||
// │ │ │ │ │ │ │ │ Vector.plus.other: Vector
|
||||
// │ │ │ │ │ │ │ │ │ val (Vector).y: Int
|
||||
// │ │ │ │ │ │ │ │ │ │
|
||||
fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
// Vector
|
||||
// │ constructor Vector(Int, Int)
|
||||
// │ │ Int
|
||||
// │ │ │ Int
|
||||
// │ │ │ │
|
||||
val a = Vector(1, 2)
|
||||
// Vector
|
||||
// │ constructor Vector(Int, Int)
|
||||
// │ │ fun (Int).unaryMinus(): Int
|
||||
// │ │ │Int
|
||||
// │ │ ││ Int
|
||||
// │ │ ││ │
|
||||
val b = Vector(-1, 10)
|
||||
|
||||
// fun io/println(Any?): Unit
|
||||
// │ val main.a: Vector
|
||||
// │ │ val main.b: Vector
|
||||
// │ │ │ fun (Vector).toString(): String
|
||||
// │ │ │ │
|
||||
println("a = $a, b = ${b.toString()}")
|
||||
// fun io/println(Any?): Unit
|
||||
// │ fun (String).plus(Any?): String
|
||||
// │ │ val main.a: Vector
|
||||
// │ │ │ fun (Vector).plus(Vector): Vector
|
||||
// │ │ │ │ val main.b: Vector
|
||||
// │ │ │ │ │
|
||||
println("a + b = " + (a + b))
|
||||
// fun io/println(Any?): Unit
|
||||
// │ val main.a: Vector
|
||||
// │ │ fun (Vector).hashCode(): Int
|
||||
// │ │ │
|
||||
println("a hash - ${a.hashCode()}")
|
||||
|
||||
// val main.a: Vector
|
||||
// │ fun (Vector).equals(Any?): Boolean
|
||||
// fun io/println(Any?): Unit │ │ val main.b: Vector
|
||||
// │ │ │ │
|
||||
println("a is equal to b ${a.equals(b)}")
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
interface Base {
|
||||
fun printMessage()
|
||||
fun printMessageLine()
|
||||
}
|
||||
|
||||
class BaseImpl(val x: Int) : Base {
|
||||
// fun io/print(Int): Unit
|
||||
// │ val (BaseImpl).x: Int
|
||||
// │ │
|
||||
override fun printMessage() { print(x) }
|
||||
// fun io/println(Int): Unit
|
||||
// │ val (BaseImpl).x: Int
|
||||
// │ │
|
||||
override fun printMessageLine() { println(x) }
|
||||
}
|
||||
|
||||
// Derived.<init>.b: Base
|
||||
// │
|
||||
class Derived(b: Base) : Base by b {
|
||||
// fun io/print(Any?): Unit
|
||||
// │
|
||||
override fun printMessage() { print("abc") }
|
||||
}
|
||||
|
||||
fun main() {
|
||||
// BaseImpl
|
||||
// │ constructor BaseImpl(Int)
|
||||
// │ │ Int
|
||||
// │ │ │
|
||||
val b = BaseImpl(10)
|
||||
// constructor Derived(Base)
|
||||
// │ val main.b: BaseImpl
|
||||
// │ │ fun (Derived).printMessage(): Unit
|
||||
// │ │ │
|
||||
Derived(b).printMessage()
|
||||
// constructor Derived(Base)
|
||||
// │ val main.b: BaseImpl
|
||||
// │ │ fun (Derived).printMessageLine(): Unit
|
||||
// │ │ │
|
||||
Derived(b).printMessageLine()
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
fun Int.addOne(): Int {
|
||||
// fun (Int).plus(Int): Int
|
||||
// │ Int
|
||||
// │ │
|
||||
return this + 1
|
||||
}
|
||||
|
||||
// Int
|
||||
// │
|
||||
val Int.repeat: Int
|
||||
get() = this
|
||||
|
||||
fun main() {
|
||||
// Int Int
|
||||
// │ │
|
||||
val i = 2
|
||||
// val main.i: Int
|
||||
// │ fun Int.addOne(): Int
|
||||
// │ │
|
||||
i.addOne()
|
||||
// val main.i: Int
|
||||
// │ val Int.repeat: Int
|
||||
// │ │ fun (Int).times(Int): Int
|
||||
// Int │ │ │ Int
|
||||
// │ │ │ │ │
|
||||
val p = i.repeat * 2
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
data class Vector(val x: Int, val y: Int) {
|
||||
fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val a = Vector(1, 2)
|
||||
val b = Vector(-1, 10)
|
||||
|
||||
println("a = $a, b = ${b.toString()}")
|
||||
println("a + b = " + (a + b))
|
||||
println("a hash - ${a.hashCode()}")
|
||||
|
||||
println("a is equal to b ${a.equals(b)}")
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
interface Base {
|
||||
fun printMessage()
|
||||
fun printMessageLine()
|
||||
}
|
||||
|
||||
class BaseImpl(val x: Int) : Base {
|
||||
override fun printMessage() { print(x) }
|
||||
override fun printMessageLine() { println(x) }
|
||||
}
|
||||
|
||||
class Derived(b: Base) : Base by b {
|
||||
override fun printMessage() { print("abc") }
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val b = BaseImpl(10)
|
||||
Derived(b).printMessage()
|
||||
Derived(b).printMessageLine()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fun Int.addOne(): Int {
|
||||
return this + 1
|
||||
}
|
||||
|
||||
val Int.repeat: Int
|
||||
get() = this
|
||||
|
||||
fun main() {
|
||||
val i = 2
|
||||
i.addOne()
|
||||
val p = i.repeat * 2
|
||||
}
|
||||
+15
@@ -29,6 +29,16 @@ public class FirVisualizerForUncommonCasesGenerated extends AbstractFirVisualize
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/visualizer/testData/uncommonCases/testFiles"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dataClass.kt")
|
||||
public void testDataClass() throws Exception {
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegation.kt")
|
||||
public void testDelegation() throws Exception {
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerWith.kt")
|
||||
public void testInnerWith() throws Exception {
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/innerWith.kt");
|
||||
@@ -44,6 +54,11 @@ public class FirVisualizerForUncommonCasesGenerated extends AbstractFirVisualize
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/properties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("receiver.kt")
|
||||
public void testReceiver() throws Exception {
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("superTypes.kt")
|
||||
public void testSuperTypes() throws Exception {
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/superTypes.kt");
|
||||
|
||||
+15
@@ -29,6 +29,16 @@ public class PsiVisualizerForUncommonCasesGenerated extends AbstractPsiVisualize
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/visualizer/testData/uncommonCases/testFiles"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dataClass.kt")
|
||||
public void testDataClass() throws Exception {
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegation.kt")
|
||||
public void testDelegation() throws Exception {
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerWith.kt")
|
||||
public void testInnerWith() throws Exception {
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/innerWith.kt");
|
||||
@@ -44,6 +54,11 @@ public class PsiVisualizerForUncommonCasesGenerated extends AbstractPsiVisualize
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/properties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("receiver.kt")
|
||||
public void testReceiver() throws Exception {
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("superTypes.kt")
|
||||
public void testSuperTypes() throws Exception {
|
||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/superTypes.kt");
|
||||
|
||||
Reference in New Issue
Block a user