JVM: Update tests for IEEE 754 comparisons

This commit is contained in:
Dmitry Petrov
2020-01-14 11:18:27 +03:00
parent d5ff1047a5
commit f8341ad7eb
14 changed files with 146 additions and 24 deletions
@@ -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
@@ -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
@@ -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
@@ -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
@@ -2891,9 +2891,14 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/intrinsicsCompare"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("byteSmartCast.kt")
public void testByteSmartCast() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/byteSmartCast.kt");
@TestMetadata("byteSmartCast_after.kt")
public void testByteSmartCast_after() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/byteSmartCast_after.kt");
}
@TestMetadata("byteSmartCast_before.kt")
public void testByteSmartCast_before() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/byteSmartCast_before.kt");
}
@TestMetadata("charSmartCast.kt")
@@ -2901,14 +2906,24 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/charSmartCast.kt");
}
@TestMetadata("differentTypes.kt")
public void testDifferentTypes() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/differentTypes.kt");
@TestMetadata("differentTypes_after.kt")
public void testDifferentTypes_after() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/differentTypes_after.kt");
}
@TestMetadata("intSmartCast.kt")
public void testIntSmartCast() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/intSmartCast.kt");
@TestMetadata("differentTypes_before.kt")
public void testDifferentTypes_before() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/differentTypes_before.kt");
}
@TestMetadata("intSmartCast_after.kt")
public void testIntSmartCast_after() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/intSmartCast_after.kt");
}
@TestMetadata("intSmartCast_before.kt")
public void testIntSmartCast_before() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/intSmartCast_before.kt");
}
@TestMetadata("longSmartCast.kt")
@@ -2916,9 +2931,14 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/longSmartCast.kt");
}
@TestMetadata("shortSmartCast.kt")
public void testShortSmartCast() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/shortSmartCast.kt");
@TestMetadata("shortSmartCast_after.kt")
public void testShortSmartCast_after() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/shortSmartCast_after.kt");
}
@TestMetadata("shortSmartCast_before.kt")
public void testShortSmartCast_before() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/shortSmartCast_before.kt");
}
}
@@ -2936,9 +2936,14 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/intrinsicsCompare"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@TestMetadata("byteSmartCast.kt")
public void testByteSmartCast() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/byteSmartCast.kt");
@TestMetadata("byteSmartCast_after.kt")
public void testByteSmartCast_after() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/byteSmartCast_after.kt");
}
@TestMetadata("byteSmartCast_before.kt")
public void testByteSmartCast_before() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/byteSmartCast_before.kt");
}
@TestMetadata("charSmartCast.kt")
@@ -2946,14 +2951,24 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/charSmartCast.kt");
}
@TestMetadata("differentTypes.kt")
public void testDifferentTypes() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/differentTypes.kt");
@TestMetadata("differentTypes_after.kt")
public void testDifferentTypes_after() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/differentTypes_after.kt");
}
@TestMetadata("intSmartCast.kt")
public void testIntSmartCast() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/intSmartCast.kt");
@TestMetadata("differentTypes_before.kt")
public void testDifferentTypes_before() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/differentTypes_before.kt");
}
@TestMetadata("intSmartCast_after.kt")
public void testIntSmartCast_after() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/intSmartCast_after.kt");
}
@TestMetadata("intSmartCast_before.kt")
public void testIntSmartCast_before() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/intSmartCast_before.kt");
}
@TestMetadata("longSmartCast.kt")
@@ -2961,9 +2976,14 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/longSmartCast.kt");
}
@TestMetadata("shortSmartCast.kt")
public void testShortSmartCast() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/shortSmartCast.kt");
@TestMetadata("shortSmartCast_after.kt")
public void testShortSmartCast_after() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/shortSmartCast_after.kt");
}
@TestMetadata("shortSmartCast_before.kt")
public void testShortSmartCast_before() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/intrinsicsCompare/shortSmartCast_before.kt");
}
}