[IR] dumpKotlinLike: add testdata for FIR tests
This commit is contained in:
committed by
teamcityserver
parent
d7bd4240e1
commit
c68040753d
Vendored
+115
@@ -0,0 +1,115 @@
|
||||
fun test1d(x: Double, y: Double): Boolean {
|
||||
return x.equals(other = y)
|
||||
}
|
||||
|
||||
fun test2d(x: Double, y: Double?): Boolean {
|
||||
return x.equals(other = y)
|
||||
}
|
||||
|
||||
fun test3d(x: Double, y: Any): Boolean {
|
||||
return x.equals(other = y)
|
||||
}
|
||||
|
||||
fun test4d(x: Double, y: Number): Boolean {
|
||||
return x.equals(other = y)
|
||||
}
|
||||
|
||||
fun test5d(x: Double, y: Any): Boolean {
|
||||
return when {
|
||||
y is Double -> x.equals(other = y /*as Double */)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun test6d(x: Any, y: Any): Boolean {
|
||||
return when {
|
||||
when {
|
||||
x is Double -> y is Double
|
||||
else -> false
|
||||
} -> x /*as Double */.equals(other = y /*as Double */)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun test1f(x: Float, y: Float): Boolean {
|
||||
return x.equals(other = y)
|
||||
}
|
||||
|
||||
fun test2f(x: Float, y: Float?): Boolean {
|
||||
return x.equals(other = y)
|
||||
}
|
||||
|
||||
fun test3f(x: Float, y: Any): Boolean {
|
||||
return x.equals(other = y)
|
||||
}
|
||||
|
||||
fun test4f(x: Float, y: Number): Boolean {
|
||||
return x.equals(other = y)
|
||||
}
|
||||
|
||||
fun test5f(x: Float, y: Any): Boolean {
|
||||
return when {
|
||||
y is Float -> x.equals(other = y /*as Float */)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun test6f(x: Any, y: Any): Boolean {
|
||||
return when {
|
||||
when {
|
||||
x is Float -> y is Float
|
||||
else -> false
|
||||
} -> x /*as Float */.equals(other = y /*as Float */)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun testFD(x: Any, y: Any): Boolean {
|
||||
return when {
|
||||
when {
|
||||
x is Float -> y is Double
|
||||
else -> false
|
||||
} -> x /*as Float */.equals(other = y /*as Double */)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun testDF(x: Any, y: Any): Boolean {
|
||||
return when {
|
||||
when {
|
||||
x is Double -> y is Float
|
||||
else -> false
|
||||
} -> x /*as Double */.equals(other = y /*as Float */)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun Float.test1fr(x: Float): Boolean {
|
||||
return <this>.equals(other = x)
|
||||
}
|
||||
|
||||
fun Float.test2fr(x: Float?): Boolean {
|
||||
return <this>.equals(other = x)
|
||||
}
|
||||
|
||||
fun Float.test3fr(x: Any): Boolean {
|
||||
return <this>.equals(other = x)
|
||||
}
|
||||
|
||||
fun Float.test4fr(x: Number): Boolean {
|
||||
return <this>.equals(other = x)
|
||||
}
|
||||
|
||||
fun Float.test5fr(x: Any): Boolean {
|
||||
return when {
|
||||
x is Float -> <this>.equals(other = x /*as Float */)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun Float.test6fr(x: Any): Boolean {
|
||||
return when {
|
||||
x is Double -> <this>.equals(other = x /*as Double */)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.kt.txt
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
fun test(x: Any?, y: Double): Boolean {
|
||||
return when {
|
||||
x is Int -> less(arg0 = x /*as Int */.toDouble(), arg1 = y)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
fun testDD(x: Double?, y: Double?): Boolean {
|
||||
return ieee754equals(arg0 = x, arg1 = y)
|
||||
}
|
||||
|
||||
fun testDF(x: Double?, y: Any?): Boolean {
|
||||
return when {
|
||||
y is Float? -> ieee754equals(arg0 = x, arg1 = { // BLOCK
|
||||
val tmp0_safe_receiver: Float? = y /*as Float? */
|
||||
when {
|
||||
EQEQ(arg0 = tmp0_safe_receiver, arg1 = null) -> null
|
||||
else -> tmp0_safe_receiver.toDouble()
|
||||
}
|
||||
})
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun testDI(x: Double?, y: Any?): Boolean {
|
||||
return when {
|
||||
y is Int? -> ieee754equals(arg0 = x, arg1 = { // BLOCK
|
||||
val tmp1_safe_receiver: Int? = y /*as Int? */
|
||||
when {
|
||||
EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null
|
||||
else -> tmp1_safe_receiver.toDouble()
|
||||
}
|
||||
})
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun testDI2(x: Any?, y: Any?): Boolean {
|
||||
return when {
|
||||
when {
|
||||
x is Int? -> y is Double
|
||||
else -> false
|
||||
} -> ieee754equals(arg0 = { // BLOCK
|
||||
val tmp2_safe_receiver: Int? = x /*as Int? */
|
||||
when {
|
||||
EQEQ(arg0 = tmp2_safe_receiver, arg1 = null) -> null
|
||||
else -> tmp2_safe_receiver.toDouble()
|
||||
}
|
||||
}, arg1 = y /*as Double */)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
fun <T : Any?> test0(x: Any, y: T): Boolean {
|
||||
return when {
|
||||
x is Int -> EQEQ(arg0 = x /*as Int */, arg1 = y)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Float> test1(x: Any, y: T): Boolean {
|
||||
return when {
|
||||
x is Float -> ieee754equals(arg0 = x /*as Float */, arg1 = y)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Double> test2(x: Any, y: T): Boolean {
|
||||
return when {
|
||||
x is Float -> ieee754equals(arg0 = x /*as Float */.toDouble(), arg1 = y)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Float> test3(x: Any, y: T): Boolean {
|
||||
return when {
|
||||
x is Int -> ieee754equals(arg0 = x /*as Int */.toFloat(), arg1 = y)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Float?> test4(x: Any, y: T): Boolean {
|
||||
return when {
|
||||
x is Int -> ieee754equals(arg0 = x /*as Int */.toFloat(), arg1 = y)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Float?, R : T> test5(x: Any, y: R): Boolean {
|
||||
return when {
|
||||
x is Int -> ieee754equals(arg0 = x /*as Int */.toFloat(), arg1 = y)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : Number> test6(x: Any, y: T): Boolean {
|
||||
return when {
|
||||
x is Int -> EQEQ(arg0 = x /*as Int */, arg1 = y)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
class F<T : Float> {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
fun testCapturedType(x: T, y: Any): Boolean {
|
||||
return when {
|
||||
y is Double -> ieee754equals(arg0 = x.toDouble(), arg1 = y /*as Double */)
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
fun testSimple(x: Double): Int {
|
||||
return { // BLOCK
|
||||
val tmp0_subject: Double = x
|
||||
when {
|
||||
ieee754equals(arg0 = tmp0_subject, arg1 = 0.0D) -> 0
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun testSmartCastInWhenSubject(x: Any): Int {
|
||||
when {
|
||||
x !is Double -> return -1
|
||||
}
|
||||
return { // BLOCK
|
||||
val tmp1_subject: Double = x /*as Double */
|
||||
when {
|
||||
ieee754equals(arg0 = tmp1_subject, arg1 = 0.0D) -> 0
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun testSmartCastInWhenCondition(x: Double, y: Any): Int {
|
||||
when {
|
||||
y !is Double -> return -1
|
||||
}
|
||||
return { // BLOCK
|
||||
val tmp2_subject: Double = x
|
||||
when {
|
||||
ieee754equals(arg0 = tmp2_subject, arg1 = y /*as Double */) -> 0
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun testSmartCastInWhenConditionInBranch(x: Any): Int {
|
||||
return { // BLOCK
|
||||
val tmp3_subject: Any = x
|
||||
when {
|
||||
tmp3_subject !is Double -> -1
|
||||
EQEQ(arg0 = tmp3_subject, arg1 = 0.0D) -> 0
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun testSmartCastToDifferentTypes(x: Any, y: Any): Int {
|
||||
when {
|
||||
x !is Double -> return -1
|
||||
}
|
||||
when {
|
||||
y !is Float -> return -1
|
||||
}
|
||||
return { // BLOCK
|
||||
val tmp4_subject: Double = x /*as Double */
|
||||
when {
|
||||
ieee754equals(arg0 = tmp4_subject, arg1 = y /*as Float */.toDouble()) -> 0
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(x: Double): Double {
|
||||
return x
|
||||
}
|
||||
|
||||
fun testWithPrematureExitInConditionSubexpression(x: Any): Int {
|
||||
return { // BLOCK
|
||||
val tmp5_subject: Any = x
|
||||
when {
|
||||
EQEQ(arg0 = tmp5_subject, arg1 = foo(x = when {
|
||||
x !is Double -> return 42
|
||||
else -> x /*as Double */
|
||||
})) -> 0
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user