[K/N] FileCheck-based tests
Introduce a simple infrastructure for testing produced bitcode with FileCheck LLVM utility. ^KT-48925
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
class A(val x: Int)
|
||||
|
||||
// CHECK-LABEL: "kfun:#main(){}"
|
||||
fun main() {
|
||||
// CHECK-DEBUG: call %struct.ObjHeader* @AllocInstance
|
||||
// CHECK-OPT: alloca %"kclassbody:A#internal"
|
||||
val a = A(5)
|
||||
println(a.x)
|
||||
// CHECK-LABEL: epilogue
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// CHECK-LABEL: "kfun:#and(kotlin.Int;kotlin.Int){}kotlin.Int"
|
||||
fun and(a: Int, b: Int): Int {
|
||||
// CHECK: and {{.*}}, {{.*}}
|
||||
return a and b
|
||||
// CHECK-LABEL: epilogue
|
||||
}
|
||||
|
||||
// CHECK-LABEL: "kfun:#ieee754(kotlin.Float;kotlin.Float){}kotlin.Boolean"
|
||||
fun ieee754(a: Float, b: Float): Boolean {
|
||||
// CHECK: fcmp oeq float {{.*}}, {{.*}}
|
||||
return a == b
|
||||
// CHECK-LABEL: epilogue
|
||||
}
|
||||
|
||||
// CHECK-LABEL: "kfun:#main(){}"
|
||||
fun main() {
|
||||
val x = and(1, 2)
|
||||
val y = ieee754(0.0f, 1.0f)
|
||||
// CHECK-LABEL: epilogue
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
fun flameThrower() {
|
||||
throw Throwable("🔥")
|
||||
}
|
||||
|
||||
// CHECK-LABEL: "kfun:#f1(){}"
|
||||
fun f1() {
|
||||
// CHECK: call void @"kfun:#flameThrower(){}"()
|
||||
flameThrower()
|
||||
// CHECK-LABEL: epilogue
|
||||
}
|
||||
|
||||
// CHECK-LABEL: "kfun:#f2(){}"
|
||||
fun f2() {
|
||||
try {
|
||||
// CHECK: invoke void @"kfun:#flameThrower(){}"()
|
||||
flameThrower()
|
||||
} catch (t: Throwable) {}
|
||||
// CHECK-LABEL: epilogue
|
||||
}
|
||||
|
||||
// CHECK-LABEL: "kfun:#main(){}"
|
||||
fun main() {
|
||||
f1()
|
||||
f2()
|
||||
// CHECK-LABEL: epilogue
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// CHECK-LABEL: "kfun:#id(kotlin.Any?){}kotlin.Any?"
|
||||
fun id(a: Any?): Any? {
|
||||
return a
|
||||
// CHECK-LABEL: epilogue
|
||||
}
|
||||
|
||||
// CHECK-LABEL: "kfun:#main(){}"
|
||||
fun main() {
|
||||
// CHECK: invoke %struct.ObjHeader* @"kfun:#id(kotlin.Any?){}kotlin.Any?"
|
||||
val x = id("Hello")
|
||||
// CHECK: invoke void @"kfun:kotlin.io#println(kotlin.Any?){}"(%struct.ObjHeader* {{.*}})
|
||||
println(x)
|
||||
// CHECK-LABEL: epilogue
|
||||
}
|
||||
Reference in New Issue
Block a user