mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-13 00:21:28 +00:00
JVM: Update tests for IEEE 754 comparisons
This commit is contained in:
18
compiler/testData/codegen/bytecodeText/intrinsicsCompare/byteSmartCast_after.kt
vendored
Normal file
18
compiler/testData/codegen/bytecodeText/intrinsicsCompare/byteSmartCast_after.kt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
fun equals3(a: Byte?, b: Byte?) = a != null && b != null && a == b
|
||||
|
||||
fun equals4(a: Byte?, b: Byte?) = if (a is Byte && b is Byte) a == b else null!!
|
||||
|
||||
fun equals5(a: Any?, b: Any?) = if (a is Byte && b is Byte) a == b else null!!
|
||||
|
||||
fun less3(a: Byte?, b: Byte?) = a != null && b != null && a < b
|
||||
|
||||
fun less4(a: Byte?, b: Byte?) = if (a is Byte && b is Byte) a < b else true
|
||||
|
||||
fun less5(a: Any?, b: Any?) = if (a is Byte && b is Byte) a < b else true
|
||||
|
||||
// 3 Intrinsics\.areEqual
|
||||
// 0 Intrinsics\.compare
|
||||
// 0 IFGE
|
||||
// 3 IF_ICMPGE
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
fun equals3(a: Byte?, b: Byte?) = a != null && b != null && a == b
|
||||
|
||||
21
compiler/testData/codegen/bytecodeText/intrinsicsCompare/differentTypes_after.kt
vendored
Normal file
21
compiler/testData/codegen/bytecodeText/intrinsicsCompare/differentTypes_after.kt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
fun box(): String {
|
||||
val zero: Any = 0.0
|
||||
val floatZero: Any = -0.0F
|
||||
if (zero is Double && floatZero is Float) {
|
||||
if (zero == floatZero) return "fail 1"
|
||||
|
||||
if (zero <= floatZero) return "fail 2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
return "fail"
|
||||
}
|
||||
|
||||
// 0 Intrinsics\.areEqual
|
||||
// 0 Double\.compare
|
||||
// 2 F2D
|
||||
// 2 DCMPG
|
||||
// 1 IFNE
|
||||
// 1 IFGT
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
fun box(): String {
|
||||
val zero: Any = 0.0
|
||||
val floatZero: Any = -0.0F
|
||||
17
compiler/testData/codegen/bytecodeText/intrinsicsCompare/intSmartCast_after.kt
vendored
Normal file
17
compiler/testData/codegen/bytecodeText/intrinsicsCompare/intSmartCast_after.kt
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
fun equals3(a: Int?, b: Int?) = a != null && b != null && a == b
|
||||
|
||||
fun equals4(a: Int?, b: Int?) = if (a is Int && b is Int) a == b else null!!
|
||||
|
||||
fun equals5(a: Any?, b: Any?) = if (a is Int && b is Int) a == b else null!!
|
||||
|
||||
fun less3(a: Int?, b: Int?) = a != null && b != null && a < b
|
||||
|
||||
fun less4(a: Int?, b: Int?) = if (a is Int && b is Int) a < b else true
|
||||
|
||||
fun less5(a: Any?, b: Any?) = if (a is Int && b is Int) a < b else true
|
||||
|
||||
// 3 Intrinsics\.areEqual
|
||||
// 0 Intrinsics\.compare
|
||||
// 0 IFGE
|
||||
// 3 IF_ICMPGE
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
fun equals3(a: Int?, b: Int?) = a != null && b != null && a == b
|
||||
|
||||
18
compiler/testData/codegen/bytecodeText/intrinsicsCompare/shortSmartCast_after.kt
vendored
Normal file
18
compiler/testData/codegen/bytecodeText/intrinsicsCompare/shortSmartCast_after.kt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
fun equals3(a: Short?, b: Short?) = a != null && b != null && a == b
|
||||
|
||||
fun equals4(a: Short?, b: Short?) = if (a is Short && b is Short) a == b else null!!
|
||||
|
||||
fun equals5(a: Any?, b: Any?) = if (a is Short && b is Short) a == b else null!!
|
||||
|
||||
fun less3(a: Short?, b: Short?) = a != null && b != null && a < b
|
||||
|
||||
fun less4(a: Short?, b: Short?) = if (a is Short && b is Short) a < b else true
|
||||
|
||||
fun less5(a: Any?, b: Any?) = if (a is Short && b is Short) a < b else true
|
||||
|
||||
// 3 Intrinsics\.areEqual
|
||||
// 0 Intrinsics\.compare
|
||||
// 0 IFGE
|
||||
// 3 IF_ICMPGE
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
fun equals3(a: Short?, b: Short?) = a != null && b != null && a == b
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// !API_VERSION: 1.0
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
|
||||
fun equals5(a: Any?, b: Any?) = if (a is Double && b is Double?) a == b else null!!
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// !API_VERSION: 1.0
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
|
||||
fun equals5(a: Any?, b: Any?) = if (a is Float && b is Float?) a == b else null!!
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// !API_VERSION: 1.0
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
|
||||
fun box(): String {
|
||||
val plusZero: Any = 0.0
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// !API_VERSION: 1.0
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
|
||||
fun box(): String {
|
||||
val nullValue: Any? = null
|
||||
|
||||
Reference in New Issue
Block a user