From 11ce50f0d6537f300f2b15b02a5dbe8c62d55f7a Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Tue, 17 Mar 2015 11:32:52 +0300 Subject: [PATCH] Tests for obsolete KT-6434: android compile error: local variable type mismatch #KT-6434 Obsolete --- .../boxWithStdlib/regressions/kt6434.kt | 28 +++++++++++++++++++ .../boxWithStdlib/regressions/kt6434_2.kt | 7 +++++ ...lackBoxWithStdlibCodegenTestGenerated.java | 12 ++++++++ 3 files changed, 47 insertions(+) create mode 100644 compiler/testData/codegen/boxWithStdlib/regressions/kt6434.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/regressions/kt6434_2.kt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt6434.kt b/compiler/testData/codegen/boxWithStdlib/regressions/kt6434.kt new file mode 100644 index 00000000000..a2b2e589fb3 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/regressions/kt6434.kt @@ -0,0 +1,28 @@ +enum class E { + VALUE + VALUE2 +} + +class C(val nums: Map) { + val normalizedNums = loadNormalizedNums() + + private fun loadNormalizedNums(): Map { + val vals = nums.values() + val min = vals.min()!! + val max = vals.max()!! + val rangeDiff = (max - min).toFloat() + val normalizedNums = nums.map { kvp -> + val (e, num) = kvp + //val e = kvp.key + //val num = kvp.value + val normalized = (num - min) / rangeDiff + Pair(e, normalized) + }.toMap() + return normalizedNums + } +} + +fun box(): String { + val res = C(hashMapOf(E.VALUE to 11, E.VALUE2 to 12)).normalizedNums.values().sort().joinToString() + return if ("0.0, 1.0" == res) "OK" else "fail $res" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt6434_2.kt b/compiler/testData/codegen/boxWithStdlib/regressions/kt6434_2.kt new file mode 100644 index 00000000000..f67a2d90e3e --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/regressions/kt6434_2.kt @@ -0,0 +1,7 @@ +fun box(): String { + val p = 1 to 1 + val (e, num) = p + val a = 1f + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index cdfd9c09f0a..54f8dcc7858 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -3068,6 +3068,18 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("kt6434.kt") + public void testKt6434() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt6434.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("kt6434_2.kt") + public void testKt6434_2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt6434_2.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("kt715.kt") public void testKt715() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt715.kt");