Update test data for compiler visualizer
This commit is contained in:
committed by
TeamCityServer
parent
4ac38e5f29
commit
919591909e
+31
@@ -0,0 +1,31 @@
|
||||
private fun resolveAccessorCall(
|
||||
// [ERROR : PropertyDescriptor]
|
||||
// │
|
||||
suspendPropertyDescriptor: PropertyDescriptor,
|
||||
// [ERROR : TranslationContext]
|
||||
// │
|
||||
context: TranslationContext
|
||||
// [ERROR : ResolvedCall<PropertyDescriptor>]<[ERROR : PropertyDescriptor]>
|
||||
// │ [ERROR : PropertyDescriptor]
|
||||
// │ │
|
||||
): ResolvedCall<PropertyDescriptor> {
|
||||
// [ERROR : ResolvedCall<PropertyDescriptor>]<[ERROR : PropertyDescriptor]>
|
||||
// │ [ERROR : PropertyDescriptor]
|
||||
// │ │
|
||||
return object : ResolvedCall<PropertyDescriptor> {
|
||||
// [ERROR : <ERROR PROPERTY TYPE>]
|
||||
// │ [ERROR: not resolved]
|
||||
// │ │ [ERROR: not resolved]
|
||||
// │ │ │
|
||||
override fun getStatus() = ResolutionStatus.SUCCESS
|
||||
|
||||
// [ERROR : PropertyDescriptor]
|
||||
// │ resolveAccessorCall.suspendPropertyDescriptor: [ERROR : PropertyDescriptor]
|
||||
// │ │
|
||||
override fun getCandidateDescriptor() = suspendPropertyDescriptor
|
||||
// [ERROR : PropertyDescriptor]
|
||||
// │ resolveAccessorCall.suspendPropertyDescriptor: [ERROR : PropertyDescriptor]
|
||||
// │ │
|
||||
override fun getResultingDescriptor() = suspendPropertyDescriptor
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
fun test1(s: String?) contract [returnsNotNull()] {
|
||||
// [ERROR: not resolved]
|
||||
// │
|
||||
contract {
|
||||
// [ERROR: not resolved]
|
||||
// │ [ERROR: not resolved]
|
||||
// │ │ test1.s: String?
|
||||
// │ │ │ fun (Any).equals(Any?): Boolean
|
||||
// │ │ │ │ Nothing?
|
||||
// │ │ │ │ │
|
||||
returns() implies (s != null)
|
||||
}
|
||||
// fun test1(String?): Unit
|
||||
// │
|
||||
test1()
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// new contracts syntax for property accessors
|
||||
class MyClass {
|
||||
// Int Int
|
||||
// │ │
|
||||
var myInt: Int = 0
|
||||
// Int
|
||||
// │
|
||||
get() contract [returnsNotNull()] = 1
|
||||
// Int
|
||||
// │
|
||||
set(value) {
|
||||
// var MyClass.<set-myInt>.field: Int
|
||||
// │ MyClass.<set-myInt>.value: Int
|
||||
// │ │ fun (Int).times(Int): Int
|
||||
// │ │ │ Int
|
||||
// │ │ │ │
|
||||
field = value * 10
|
||||
}
|
||||
}
|
||||
|
||||
class AnotherClass(multiplier: Int) {
|
||||
// Int Int
|
||||
// │ │
|
||||
var anotherInt: Int = 0
|
||||
// Int
|
||||
// │
|
||||
get() contract [returnsNotNull()] = 1
|
||||
// Int
|
||||
// │
|
||||
set(value) contract [returns()] {
|
||||
// var AnotherClass.<set-anotherInt>.field: Int
|
||||
// │ AnotherClass.<set-anotherInt>.value: Int
|
||||
// │ │ [ERROR: not resolved]
|
||||
// │ │ │ [ERROR: not resolved]
|
||||
// │ │ │ │
|
||||
field = value * multiplier
|
||||
}
|
||||
}
|
||||
|
||||
class SomeClass(multiplier: Int?) {
|
||||
// Int Int
|
||||
// │ │
|
||||
var someInt: Int = 0
|
||||
// Int
|
||||
// │
|
||||
get() contract [returnsNotNull()] = 1
|
||||
// Int [ERROR: unknown type]
|
||||
// │ │
|
||||
set(value) contract [returns() implies (value != null)] {
|
||||
// SomeClass.<set-someInt>.value: Int
|
||||
// │ [ERROR: not resolved]
|
||||
// │ │
|
||||
value ?: throw NullArgumentException()
|
||||
// var SomeClass.<set-someInt>.field: Int
|
||||
// │ SomeClass.<set-someInt>.value: Int
|
||||
// │ │
|
||||
field = value
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// new contracts syntax for simple functions
|
||||
// [ERROR : MyClass]? [ERROR: unknown type] [ERROR: unknown type]
|
||||
// │ │ │
|
||||
fun test1(s: MyClass?) contract [returns() implies (s != null), returns() implies (s is MySubClass)] {
|
||||
// [ERROR: not resolved]
|
||||
// │
|
||||
test_1()
|
||||
}
|
||||
|
||||
fun test2() contract [returnsNotNull()] {
|
||||
// fun test2(): Unit
|
||||
// │
|
||||
test2()
|
||||
}
|
||||
Vendored
+125
@@ -0,0 +1,125 @@
|
||||
// Should have raw description
|
||||
fun test_1() {
|
||||
// [ERROR: not resolved]
|
||||
// │
|
||||
contract {
|
||||
// [ERROR: not resolved]
|
||||
// │
|
||||
callsInPlace()
|
||||
}
|
||||
// fun test_1(): Unit
|
||||
// │
|
||||
test_1()
|
||||
}
|
||||
|
||||
fun test_2() {
|
||||
// fun contracts/contract(contracts/ContractBuilder.() -> Unit): Unit
|
||||
// package kotlin │ contract@0
|
||||
// │ │ │
|
||||
kotlin.contracts.contract {
|
||||
// this@0
|
||||
// fun <R> (contracts/ContractBuilder).callsInPlace<???>(Function<???>, contracts/InvocationKind = ...): contracts/CallsInPlace
|
||||
// │
|
||||
callsInPlace()
|
||||
// this@0
|
||||
// fun <R> (contracts/ContractBuilder).callsInPlace<???>(Function<???>, contracts/InvocationKind = ...): contracts/CallsInPlace
|
||||
// │
|
||||
callsInPlace()
|
||||
}
|
||||
// fun test_2(): Unit
|
||||
// │
|
||||
test_2()
|
||||
}
|
||||
|
||||
// Int Int
|
||||
// │ │
|
||||
var test_3: Int = 1
|
||||
get() {
|
||||
// [ERROR: not resolved]
|
||||
// │
|
||||
contract {
|
||||
// [ERROR: not resolved]
|
||||
// │
|
||||
callsInPlace()
|
||||
}
|
||||
// Int
|
||||
// │
|
||||
return 1
|
||||
}
|
||||
// Int
|
||||
// │
|
||||
set(value) {
|
||||
// fun contracts/contract(contracts/ContractBuilder.() -> Unit): Unit
|
||||
// package kotlin │ contract@0
|
||||
// │ │ │
|
||||
kotlin.contracts.contract {
|
||||
// this@0
|
||||
// fun <R> (contracts/ContractBuilder).callsInPlace<???>(Function<???>, contracts/InvocationKind = ...): contracts/CallsInPlace
|
||||
// │
|
||||
callsInPlace()
|
||||
// this@0
|
||||
// fun <R> (contracts/ContractBuilder).callsInPlace<???>(Function<???>, contracts/InvocationKind = ...): contracts/CallsInPlace
|
||||
// │
|
||||
callsInPlace()
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4() {
|
||||
// [ERROR: not resolved]
|
||||
// │
|
||||
contract()
|
||||
// fun test_4(): Unit
|
||||
// │
|
||||
test_4()
|
||||
}
|
||||
|
||||
// should not have raw description
|
||||
|
||||
fun test_5() {
|
||||
// fun test_5(): Unit
|
||||
// │
|
||||
test_5()
|
||||
// [ERROR: not resolved]
|
||||
// │
|
||||
contract()
|
||||
}
|
||||
|
||||
fun test_6() {
|
||||
// [ERROR: not resolved]
|
||||
// │ [ERROR: not resolved]
|
||||
// │ │ [ERROR: not resolved]
|
||||
// │ │ │ [ERROR: not resolved]
|
||||
// │ │ │ │
|
||||
aaa.bbb.ccc.contract {
|
||||
|
||||
}
|
||||
// fun test_6(): Unit
|
||||
// │
|
||||
test_6()
|
||||
}
|
||||
|
||||
fun test_7() {
|
||||
// [ERROR: not resolved]
|
||||
// │ [ERROR: not resolved]
|
||||
// │ │
|
||||
contracts.contract {
|
||||
|
||||
}
|
||||
// fun test_7(): Unit
|
||||
// │
|
||||
test_7()
|
||||
}
|
||||
|
||||
fun test_8() {
|
||||
// [ERROR: not resolved]
|
||||
// │ [ERROR: not resolved]
|
||||
// │ │ [ERROR: not resolved]
|
||||
// │ │ │ [ERROR: not resolved]
|
||||
// │ │ │ │
|
||||
aaa.kotlin.contracts.contract {
|
||||
|
||||
}
|
||||
// fun test_8(): Unit
|
||||
// │
|
||||
test_8()
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// package kotlin
|
||||
// │
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
// package kotlin
|
||||
// │
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
// fun <T> lazy<Int>(() -> Int): Lazy<Int>
|
||||
// │ Int
|
||||
// │ │ fun (Int).plus(Int): Int
|
||||
// Int │ │ │ Int
|
||||
// │ │ │ │ │
|
||||
val x: Int by lazy { 1 + 2 }
|
||||
|
||||
// properties/ReadWriteProperty<Any?, Int>
|
||||
// │ properties/ReadWriteProperty<Any?, Int>
|
||||
// │ │
|
||||
val delegate = object: ReadWriteProperty<Any?, Int> {
|
||||
// reflect/KProperty<*>
|
||||
// │ Int
|
||||
// │ │ Int
|
||||
// │ │ │
|
||||
override fun getValue(thisRef: Any?, property: KProperty<*>): Int = 1
|
||||
// reflect/KProperty<*>
|
||||
// │
|
||||
override fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) {}
|
||||
}
|
||||
|
||||
// Int val delegate: properties/ReadWriteProperty<Any?, Int>
|
||||
// │ │
|
||||
val value by delegate
|
||||
|
||||
// Int val delegate: properties/ReadWriteProperty<Any?, Int>
|
||||
// │ │
|
||||
var variable by delegate
|
||||
@@ -0,0 +1,5 @@
|
||||
fun test() {
|
||||
// test.<no name provided>
|
||||
// │
|
||||
val x = object {}
|
||||
}
|
||||
@@ -61,3 +61,22 @@ enum class Planet(val m: Double, internal val r: Double) {
|
||||
const val G = 6.67e-11
|
||||
}
|
||||
}
|
||||
|
||||
enum class PseudoInsn(val signature: String = "()V") {
|
||||
FIX_STACK_BEFORE_JUMP,
|
||||
// constructor PseudoInsn(String = ...)
|
||||
// │
|
||||
FAKE_ALWAYS_TRUE_IFEQ("()I"),
|
||||
// constructor PseudoInsn(String = ...)
|
||||
// │
|
||||
FAKE_ALWAYS_FALSE_IFEQ("()I"),
|
||||
SAVE_STACK_BEFORE_TRY,
|
||||
RESTORE_STACK_IN_TRY_CATCH,
|
||||
STORE_NOT_NULL,
|
||||
// constructor PseudoInsn(String = ...)
|
||||
// │
|
||||
AS_NOT_NULL("(Ljava/lang/Object;)Ljava/lang/Object;")
|
||||
;
|
||||
|
||||
fun emit() {}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
external class External
|
||||
|
||||
external fun foo(): String
|
||||
|
||||
// Int
|
||||
// │
|
||||
external val x: Int
|
||||
|
||||
class NotExternal {
|
||||
external fun bar(): String
|
||||
// Int
|
||||
// │
|
||||
var y: Int
|
||||
external get
|
||||
// Int
|
||||
// │
|
||||
set(value) {}
|
||||
}
|
||||
|
||||
// Int
|
||||
// │
|
||||
var z: Int
|
||||
external get
|
||||
external set
|
||||
@@ -1,5 +1,4 @@
|
||||
// FIR_IGNORE
|
||||
|
||||
interface Any
|
||||
|
||||
// T?
|
||||
|
||||
@@ -50,3 +50,9 @@ val test6 = A::qux
|
||||
// │ fun baz(): Unit
|
||||
// │ │
|
||||
val test7 = ::baz
|
||||
|
||||
// reflect/KFunction1<A?, Unit>
|
||||
// │ class A
|
||||
// │ │ fun (A).foo(): Unit
|
||||
// │ │ │
|
||||
val test8 = A?::foo
|
||||
|
||||
@@ -21,3 +21,11 @@ fun foo(some: Some) {
|
||||
// │
|
||||
z = ""
|
||||
}
|
||||
|
||||
fun bar(some: Some) {
|
||||
// Int
|
||||
// │ Double
|
||||
// │ │ String bar.some: Some
|
||||
// │ │ │ │
|
||||
val (a, _, `_`) = some
|
||||
}
|
||||
|
||||
@@ -12,6 +12,31 @@ fun foo() {
|
||||
}
|
||||
}
|
||||
|
||||
fun fooLabeled() {
|
||||
// fun io/println(Any?): Unit
|
||||
// │
|
||||
println("!!!")
|
||||
// Int
|
||||
// │fun (Int).rangeTo(Int): ranges/IntRange
|
||||
// Int ││ Int
|
||||
// │ ││ │
|
||||
label@ for (i in 1..10) {
|
||||
// Unit
|
||||
// │ val fooLabeled.i: Int
|
||||
// │ │ fun (Any).equals(Any?): Boolean
|
||||
// │ │ │ Int
|
||||
// │ │ │ │
|
||||
if (i == 5) continue@label
|
||||
// fun io/println(Int): Unit
|
||||
// │ val fooLabeled.i: Int
|
||||
// │ │
|
||||
println(i)
|
||||
}
|
||||
// fun io/println(Any?): Unit
|
||||
// │
|
||||
println("!!!")
|
||||
}
|
||||
|
||||
// collections/List<String>
|
||||
// │
|
||||
fun bar(list: List<String>) {
|
||||
@@ -50,3 +75,16 @@ fun baz(set: Set<Some>) {
|
||||
println("x = $x y = $y")
|
||||
}
|
||||
}
|
||||
|
||||
// collections/List<Some>
|
||||
// │
|
||||
fun withParameter(list: List<Some>) {
|
||||
// Some withParameter.list: collections/List<Some>
|
||||
// │ │
|
||||
for (s: Some in list) {
|
||||
// fun io/println(Any?): Unit
|
||||
// │ val withParameter.s: Some
|
||||
// │ │
|
||||
println(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fun main() {
|
||||
// [ERROR: not resolved]
|
||||
// │ [ERROR: not resolved]
|
||||
// │ │ [ERROR: not resolved]
|
||||
// │ │ │
|
||||
{ length } foo { bar() }
|
||||
}
|
||||
@@ -43,26 +43,32 @@ abstract class AbstractVisualizer : AbstractKotlinCompilerTest() {
|
||||
|
||||
forTestsMatching("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/*") {
|
||||
defaultDirectives {
|
||||
VisualizerDirectives.EXPECTED_FILE_PATH with "compiler/visualizer/testData/rawBuilder/declarations"
|
||||
VisualizerDirectives.TEST_FILE_PATH with "fir/raw-fir/psi2fir"
|
||||
VisualizerDirectives.EXPECTED_FILE_PATH with "visualizer"
|
||||
}
|
||||
}
|
||||
|
||||
forTestsMatching("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/*") {
|
||||
defaultDirectives {
|
||||
VisualizerDirectives.EXPECTED_FILE_PATH with "compiler/visualizer/testData/rawBuilder/expressions"
|
||||
VisualizerDirectives.TEST_FILE_PATH with "fir/raw-fir/psi2fir"
|
||||
VisualizerDirectives.EXPECTED_FILE_PATH with "visualizer"
|
||||
}
|
||||
}
|
||||
|
||||
forTestsMatching("compiler/visualizer/testData/uncommonCases/*") {
|
||||
defaultDirectives {
|
||||
VisualizerDirectives.EXPECTED_FILE_PATH with "compiler/visualizer/testData/uncommonCases/resultFiles"
|
||||
VisualizerDirectives.TEST_FILE_PATH with "uncommonCases/testFiles"
|
||||
VisualizerDirectives.EXPECTED_FILE_PATH with "uncommonCases/resultFiles"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal object VisualizerDirectives : SimpleDirectivesContainer() {
|
||||
val TEST_FILE_PATH by stringDirective(
|
||||
description = "Specify that part of test file path must be replaced with EXPECTED_FILE_PATH"
|
||||
)
|
||||
val EXPECTED_FILE_PATH by stringDirective(
|
||||
description = "Specify the path to expected result file"
|
||||
description = "Specify the path to expected result file that will be inserted instead of TEST_FILE_PATH"
|
||||
)
|
||||
}
|
||||
+5
-4
@@ -28,9 +28,10 @@ abstract class AbstractFirVisualizer : AbstractVisualizer() {
|
||||
val renderer = FirVisualizer(info.firFiles.values.first())
|
||||
val firRenderResult = renderer.render()
|
||||
|
||||
val fileName = info.firFiles.keys.first().name
|
||||
val expectedPath = it.defaultDirectives.get(VisualizerDirectives.EXPECTED_FILE_PATH).first() + "/$fileName"
|
||||
val expectedText = File(expectedPath).readLines()
|
||||
val replaceFrom = it.defaultDirectives[VisualizerDirectives.TEST_FILE_PATH].first()
|
||||
val replaceTo = it.defaultDirectives[VisualizerDirectives.EXPECTED_FILE_PATH].first()
|
||||
val path = info.firFiles.keys.first().originalFile.absolutePath.replace(replaceFrom, replaceTo)
|
||||
val expectedText = File(path).readLines()
|
||||
if (expectedText[0].startsWith("// FIR_IGNORE")) {
|
||||
Assert.assertFalse(
|
||||
"Files are identical, please delete ignore directive",
|
||||
@@ -38,7 +39,7 @@ abstract class AbstractFirVisualizer : AbstractVisualizer() {
|
||||
)
|
||||
return
|
||||
}
|
||||
KotlinTestUtils.assertEqualsToFile(File(expectedPath), firRenderResult) {
|
||||
KotlinTestUtils.assertEqualsToFile(File(path), firRenderResult) {
|
||||
return@assertEqualsToFile it.replace("// FIR_IGNORE\n", "")
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -27,9 +27,10 @@ abstract class AbstractPsiVisualizer : AbstractVisualizer() {
|
||||
val renderer = PsiVisualizer(info.ktFiles.values.first(), info.analysisResult)
|
||||
val psiRenderResult = renderer.render()
|
||||
|
||||
val fileName = info.ktFiles.keys.first().name
|
||||
val expectedPath = it.defaultDirectives.get(VisualizerDirectives.EXPECTED_FILE_PATH).first() + "/$fileName"
|
||||
KotlinTestUtils.assertEqualsToFile(File(expectedPath), psiRenderResult) {
|
||||
val replaceFrom = it.defaultDirectives[VisualizerDirectives.TEST_FILE_PATH].first()
|
||||
val replaceTo = it.defaultDirectives[VisualizerDirectives.EXPECTED_FILE_PATH].first()
|
||||
val path = info.ktFiles.keys.first().originalFile.absolutePath.replace(replaceFrom, replaceTo)
|
||||
KotlinTestUtils.assertEqualsToFile(File(path), psiRenderResult) {
|
||||
return@assertEqualsToFile it.replace("// FIR_IGNORE\n", "")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user