From 8cc8e54a9f32d40c45df62932e1f94596b83551d Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Mon, 10 Apr 2023 17:15:52 +0200 Subject: [PATCH] [IR] Extract `toString` interpretation test of float value into new file We need to distinguish `toString` results for JVM and JS --- ...LightTreeBlackBoxCodegenTestGenerated.java | 6 +++++ .../FirPsiBlackBoxCodegenTestGenerated.java | 6 +++++ .../dumpIrAndCheck/doubleOperations.kt | 11 -------- .../dumpIrAndCheck/floatOperations.kt | 11 -------- .../dumpIrAndCheck/jsFloatDoubleToString.kt | 27 +++++++++++++++++++ .../dumpIrAndCheck/jvmFloatDoubleToString.kt | 27 +++++++++++++++++++ .../box/involvesIrInterpreter/jsIrToConst.kt | 10 ------- .../IrBlackBoxCodegenTestGenerated.java | 6 +++++ ...kBoxCodegenWithIrInlinerTestGenerated.java | 6 +++++ .../fir/FirJsCodegenBoxTestGenerated.java | 12 ++++----- .../test/ir/IrJsCodegenBoxTestGenerated.java | 12 ++++----- .../ir/IrJsES6CodegenBoxTestGenerated.java | 12 ++++----- .../FirNativeCodegenBoxTestGenerated.java | 6 +++++ .../FirNativeCodegenBoxTestNoPLGenerated.java | 6 +++++ .../NativeCodegenBoxTestGenerated.java | 6 +++++ .../NativeCodegenBoxTestNoPLGenerated.java | 6 +++++ 16 files changed, 120 insertions(+), 50 deletions(-) create mode 100644 compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jsFloatDoubleToString.kt create mode 100644 compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt delete mode 100644 compiler/testData/codegen/box/involvesIrInterpreter/jsIrToConst.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index 7b324712169..84e10c48b6b 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -28430,6 +28430,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jvmFloatDoubleToString.kt") + public void testJvmFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt"); + } + @Test @TestMetadata("kCallableName.kt") public void testKCallableName() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index e19a955f1d5..dc1725fa82e 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -28430,6 +28430,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jvmFloatDoubleToString.kt") + public void testJvmFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt"); + } + @Test @TestMetadata("kCallableName.kt") public void testKCallableName() throws Exception { diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/doubleOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/doubleOperations.kt index 9dd266e3fac..d1223421502 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/doubleOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/doubleOperations.kt @@ -87,12 +87,6 @@ const val equals2 = twoVal == twoVal const val equals3 = threeVal == twoVal const val equals4 = fourVal == twoVal -const val toString1 = oneVal.toString() -const val toString2 = twoVal.toString() -const val toString3 = oneAndAHalf.toString() - -fun T.id(): T = this - fun box(): String { if (compareTo1 != -1) return "Fail 1.1" if (compareTo2 != 0) return "Fail 1.2" @@ -164,10 +158,5 @@ fun box(): String { if (equals3 != false) return "Fail 9.3" if (equals4 != false) return "Fail 9.4" - // id is needed to avoid evaluation and so match different cases for JVM and JS - if (toString1.id() != "1.0" && toString1.id() != "1" /* JS */) return "Fail 10.1" - if (toString2.id() != "2.0" && toString2.id() != "2" /* JS */) return "Fail 10.2" - if (toString3.id() != "1.5") return "Fail 10.3" - return "OK" } diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/floatOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/floatOperations.kt index 0e3843aff41..e40b5993b1d 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/floatOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/floatOperations.kt @@ -87,12 +87,6 @@ const val equals2 = twoVal == twoVal const val equals3 = threeVal == twoVal const val equals4 = fourVal == twoVal -const val toString1 = oneVal.toString() -const val toString2 = twoVal.toString() -const val toString3 = oneAndAHalf.toString() - -fun T.id(): T = this - fun box(): String { if (compareTo1 != -1) return "Fail 1.1" if (compareTo2 != 0) return "Fail 1.2" @@ -164,10 +158,5 @@ fun box(): String { if (equals3 != false) return "Fail 9.3" if (equals4 != false) return "Fail 9.4" - // id is needed to avoid evaluation and so match different cases for JVM and JS - if (toString1.id() != "1.0" && toString1.id() != "1" /* JS */) return "Fail 10.1" - if (toString2.id() != "2.0" && toString2.id() != "2" /* JS */) return "Fail 10.2" - if (toString3.id() != "1.5") return "Fail 10.3" - return "OK" } diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jsFloatDoubleToString.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jsFloatDoubleToString.kt new file mode 100644 index 00000000000..5a9f20de636 --- /dev/null +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jsFloatDoubleToString.kt @@ -0,0 +1,27 @@ +// TARGET_BACKEND: JS_IR +// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6 + +const val toStringDouble1 = 1.0.toString() +const val toStringDouble2 = 2.0.toString() +const val toStringDouble3 = 1.5.toString() + +const val toStringFloat1 = 1.0f.toString() +const val toStringFloat2 = 2.0f.toString() +const val toStringFloat3 = 1.5f.toString() + +fun box(): String { + if (toStringDouble1 != "1") return "Fail 1.1" + if (toStringDouble2 != "2") return "Fail 1.2" + if (toStringDouble3 != "1.5") return "Fail 1.3" + + if (toStringFloat1 != "1") return "Fail 2.1" + if (toStringFloat2 != "2") return "Fail 2.2" + if (toStringFloat3 != "1.5") return "Fail 2.3" + + val localDoubleToString = 1.0.toString() + val localFloatToString = 1.0f.toString() + if (localDoubleToString != toStringDouble1) return "Fail 3.1" + if (localFloatToString != toStringFloat1) return "Fail 3.2" + + return "OK" +} diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt new file mode 100644 index 00000000000..739a4e588cf --- /dev/null +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt @@ -0,0 +1,27 @@ +// TARGET_BACKEND: JVM_IR +// TARGET_BACKEND: NATIVE + +const val toStringDouble1 = 1.0.toString() +const val toStringDouble2 = 2.0.toString() +const val toStringDouble3 = 1.5.toString() + +const val toStringFloat1 = 1.0f.toString() +const val toStringFloat2 = 2.0f.toString() +const val toStringFloat3 = 1.5f.toString() + +fun box(): String { + if (toStringDouble1 != "1.0") return "Fail 1.1" + if (toStringDouble2 != "2.0") return "Fail 1.2" + if (toStringDouble3 != "1.5") return "Fail 1.3" + + if (toStringFloat1 != "1.0") return "Fail 2.1" + if (toStringFloat2 != "2.0") return "Fail 2.2" + if (toStringFloat3 != "1.5") return "Fail 2.3" + + val localDoubleToString = 1.0.toString() + val localFloatToString = 1.0f.toString() + if (localDoubleToString != toStringDouble1) return "Fail 3.1" + if (localFloatToString != toStringFloat1) return "Fail 3.2" + + return "OK" +} diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/jsIrToConst.kt b/compiler/testData/codegen/box/involvesIrInterpreter/jsIrToConst.kt deleted file mode 100644 index 91850babd8e..00000000000 --- a/compiler/testData/codegen/box/involvesIrInterpreter/jsIrToConst.kt +++ /dev/null @@ -1,10 +0,0 @@ -// TARGET_BACKEND: JS_IR -// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6 - -const val toStringInConst = 1.0.toString() - -fun box(): String { - if (toStringInConst != "1") return "Fail 1" - if (1.0.toString() != toStringInConst) return "Fail 2" - return "OK" -} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 47238e2e239..9aa5546852f 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -28430,6 +28430,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jvmFloatDoubleToString.kt") + public void testJvmFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt"); + } + @Test @TestMetadata("kCallableName.kt") public void testKCallableName() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 4809544354a..c4288fc46cf 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -28430,6 +28430,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jvmFloatDoubleToString.kt") + public void testJvmFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt"); + } + @Test @TestMetadata("kCallableName.kt") public void testKCallableName() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index dcb0fc3d391..28f0d254b7e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -21085,12 +21085,6 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/involvesIrInterpreter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } - @Test - @TestMetadata("jsIrToConst.kt") - public void testJsIrToConst() throws Exception { - runTest("compiler/testData/codegen/box/involvesIrInterpreter/jsIrToConst.kt"); - } - @Test @TestMetadata("kt55912.kt") public void testKt55912() throws Exception { @@ -21166,6 +21160,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jsFloatDoubleToString.kt") + public void testJsFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jsFloatDoubleToString.kt"); + } + @Test @TestMetadata("longOperations.kt") public void testLongOperations() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 4868fdca781..da3d45f4653 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -21085,12 +21085,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/involvesIrInterpreter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } - @Test - @TestMetadata("jsIrToConst.kt") - public void testJsIrToConst() throws Exception { - runTest("compiler/testData/codegen/box/involvesIrInterpreter/jsIrToConst.kt"); - } - @Test @TestMetadata("kt55912.kt") public void testKt55912() throws Exception { @@ -21166,6 +21160,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jsFloatDoubleToString.kt") + public void testJsFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jsFloatDoubleToString.kt"); + } + @Test @TestMetadata("longOperations.kt") public void testLongOperations() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index 9509a02cf5c..39e2fe73e6d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -21085,12 +21085,6 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/involvesIrInterpreter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } - @Test - @TestMetadata("jsIrToConst.kt") - public void testJsIrToConst() throws Exception { - runTest("compiler/testData/codegen/box/involvesIrInterpreter/jsIrToConst.kt"); - } - @Test @TestMetadata("kt55912.kt") public void testKt55912() throws Exception { @@ -21166,6 +21160,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jsFloatDoubleToString.kt") + public void testJsFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jsFloatDoubleToString.kt"); + } + @Test @TestMetadata("longOperations.kt") public void testLongOperations() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java index 00b86af43e7..221780e81fa 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java @@ -24360,6 +24360,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jvmFloatDoubleToString.kt") + public void testJvmFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt"); + } + @Test @TestMetadata("longOperations.kt") public void testLongOperations() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java index 5a3d941de30..f73bb514e16 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java @@ -24830,6 +24830,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jvmFloatDoubleToString.kt") + public void testJvmFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt"); + } + @Test @TestMetadata("longOperations.kt") public void testLongOperations() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 9b7e822e6c5..293fbdc30bc 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -24125,6 +24125,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jvmFloatDoubleToString.kt") + public void testJvmFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt"); + } + @Test @TestMetadata("longOperations.kt") public void testLongOperations() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java index 3ea630aed67..01dba2c6d9c 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java @@ -24595,6 +24595,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt"); } + @Test + @TestMetadata("jvmFloatDoubleToString.kt") + public void testJvmFloatDoubleToString() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/jvmFloatDoubleToString.kt"); + } + @Test @TestMetadata("longOperations.kt") public void testLongOperations() throws Exception {