From 6551fdc695bc5b1f608ca7cfa1410116a0aa738c Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Mon, 3 Jul 2017 14:51:20 +0300 Subject: [PATCH] Add test for nullable primitive in range --- .../ranges/contains/nullableInPrimitiveRange.kt | 14 ++++++++++++++ .../codegen/ir/IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/LightAnalysisModeTestGenerated.java | 6 ++++++ .../test/semantics/JsCodegenBoxTestGenerated.java | 6 ++++++ 5 files changed, 38 insertions(+) create mode 100644 compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt diff --git a/compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt b/compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt new file mode 100644 index 00000000000..fd05c2601f9 --- /dev/null +++ b/compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt @@ -0,0 +1,14 @@ +// WITH_RUNTIME + +val x: Int? = 42 +val n: Int? = null + +fun box(): String { + if (x in 0..2) return "Fail in" + if (!(x !in 0..2)) return "Fail !in" + + if (n in 0..2) return "Fail in null" + if (!(n !in 0..2)) return "Fail !in null" + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 09613afaeed..f237bc17d22 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -13315,6 +13315,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("nullableInPrimitiveRange.kt") + public void testNullableInPrimitiveRange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt"); + doTest(fileName); + } + @TestMetadata("rangeContainsString.kt") public void testRangeContainsString() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/rangeContainsString.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index cb67ff999ad..bb5f263d793 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -13315,6 +13315,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("nullableInPrimitiveRange.kt") + public void testNullableInPrimitiveRange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt"); + doTest(fileName); + } + @TestMetadata("rangeContainsString.kt") public void testRangeContainsString() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/rangeContainsString.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index a7e537da218..cdb272e7634 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13315,6 +13315,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } + @TestMetadata("nullableInPrimitiveRange.kt") + public void testNullableInPrimitiveRange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt"); + doTest(fileName); + } + @TestMetadata("rangeContainsString.kt") public void testRangeContainsString() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/rangeContainsString.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 14aa8e24245..6f776ea66df 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -14995,6 +14995,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { doTest(fileName); } + @TestMetadata("nullableInPrimitiveRange.kt") + public void testNullableInPrimitiveRange() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/nullableInPrimitiveRange.kt"); + doTest(fileName); + } + @TestMetadata("rangeContainsString.kt") public void testRangeContainsString() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/rangeContainsString.kt");