Add test for in/!in in a custom object range

This commit is contained in:
Dmitry Petrov
2017-07-06 17:14:54 +03:00
parent 9d1901fc7c
commit 64f880ba71
5 changed files with 46 additions and 0 deletions
@@ -0,0 +1,22 @@
// WITH_RUNTIME
class A(val z: Int) : Comparable<A> {
override fun compareTo(other: A): Int {
return Integer.compare(z, other.z)
}
}
operator fun A.rangeTo(that: A): ClosedRange<A> = object: ClosedRange<A> {
override val endInclusive: A
get() = that
override val start: A
get() = this@rangeTo
}
operator fun ClosedRange<A>.iterator() = (start.z..endInclusive.z).map { A(it) }.iterator()
fun box(): String {
if (!( A(2) in A(1)..A(12) )) return "Fail 1"
if ( A(2) !in A(1)..A(12) ) return "Fail 2"
return "OK"
}
@@ -13213,6 +13213,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("inCustomObjectRange.kt")
public void testInCustomObjectRange() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCustomObjectRange.kt");
doTest(fileName);
}
@TestMetadata("inDoubleRangeLiteralVsComparableRangeLiteral.kt")
public void testInDoubleRangeLiteralVsComparableRangeLiteral() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inDoubleRangeLiteralVsComparableRangeLiteral.kt");
@@ -13213,6 +13213,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("inCustomObjectRange.kt")
public void testInCustomObjectRange() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCustomObjectRange.kt");
doTest(fileName);
}
@TestMetadata("inDoubleRangeLiteralVsComparableRangeLiteral.kt")
public void testInDoubleRangeLiteralVsComparableRangeLiteral() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inDoubleRangeLiteralVsComparableRangeLiteral.kt");
@@ -13213,6 +13213,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTest(fileName);
}
@TestMetadata("inCustomObjectRange.kt")
public void testInCustomObjectRange() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCustomObjectRange.kt");
doTest(fileName);
}
@TestMetadata("inDoubleRangeLiteralVsComparableRangeLiteral.kt")
public void testInDoubleRangeLiteralVsComparableRangeLiteral() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inDoubleRangeLiteralVsComparableRangeLiteral.kt");
@@ -14827,6 +14827,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("inCustomObjectRange.kt")
public void testInCustomObjectRange() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCustomObjectRange.kt");
doTest(fileName);
}
@TestMetadata("inDoubleRangeLiteralVsComparableRangeLiteral.kt")
public void testInDoubleRangeLiteralVsComparableRangeLiteral() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inDoubleRangeLiteralVsComparableRangeLiteral.kt");