KT-4349 Make jet.Boolean implement Comparable

#KT-4349
This commit is contained in:
Evgeny Gerashchenko
2013-12-25 21:07:55 +04:00
parent c616b4baa0
commit 513be47544
38 changed files with 38 additions and 32 deletions
+2 -1
View File
@@ -26,9 +26,10 @@ public final class Array</*0*/ reified T> {
public final fun set(/*0*/ index: jet.Int, /*1*/ value: T): jet.Unit
}
public final class Boolean {
public final class Boolean : jet.Comparable<jet.Boolean> {
/*primary*/ private constructor Boolean()
public final fun and(/*0*/ other: jet.Boolean): jet.Boolean
public open override /*1*/ fun compareTo(/*0*/ other: jet.Boolean): jet.Int
public final fun equals(/*0*/ other: jet.Any?): jet.Boolean
public final fun not(): jet.Boolean
public final fun or(/*0*/ other: jet.Boolean): jet.Boolean
@@ -0,0 +1,11 @@
fun checkLess(x: Boolean, y: Boolean) = when {
x >= y -> "Fail $x >= $y"
!(x < y) -> "Fail !($x < $y)"
!(x <= y) -> "Fail !($x <= $y)"
x > y -> "Fail $x > $y"
x.compareTo(y) >= 0 -> "Fail $x.compareTo($y) >= 0"
x compareTo y >= 0 -> "Fail $x compareTo $y >= 0"
else -> "OK"
}
fun box() = checkLess(false, true)
@@ -1,8 +0,0 @@
fun foo(x: Boolean) {
x <!UNRESOLVED_REFERENCE!><<!> x
x <!UNRESOLVED_REFERENCE!><=<!> x
x <!UNRESOLVED_REFERENCE!>><!> x
x <!UNRESOLVED_REFERENCE!>>=<!> x
x == x
x.<!UNRESOLVED_REFERENCE!>compareTo<!>(x)
}