Files
kotlin-fork/compiler/testData/codegen/box/ranges/contains/inRangeWithCustomContains.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

26 lines
627 B
Kotlin
Vendored

// WITH_STDLIB
import kotlin.test.*
class Value(val x: Int) : Comparable<Value> {
override fun compareTo(other: Value): Int {
throw AssertionError("Should not be called")
}
}
class ValueRange(override val start: Value,
override val endInclusive: Value) : ClosedRange<Value> {
override fun contains(value: Value): Boolean {
return value.x == 42
}
}
operator fun Value.rangeTo(other: Value): ClosedRange<Value> = ValueRange(this, other)
fun box(): String {
assertTrue(Value(42) in Value(1)..Value(2))
assertTrue(Value(41) !in Value(40)..Value(42))
return "OK"
}