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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,9 +1,9 @@
& 2 & 2
 
 Z  Z
0B 0B
 Z  Z
&0B &0B
 j  j
Ć0B Ć0B
 
Binary file not shown.
@@ -1,9 +1,9 @@
&2 &2
 
 Z  Z
0B 0B
 Z  Z
&0?B &0?B
 j  j
0B 0B
 
Binary file not shown.
@@ -1,7 +1,7 @@
&"2 &"2
 
Z Z
0B 0B
Z Z
&0MB &0MB
j j
Binary file not shown.
@@ -1,7 +1,7 @@
&*2 &*2
 
Z Z
0B 0B
Z Z
&0]B &0]B
j j
Binary file not shown.
@@ -1,7 +1,7 @@
&F2 &F2
 
Z Z
0B 0B
Z &0ŞB Z &0ŞB
j j
Ć0B Ć0B
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
&f2 &f2
 
Z Z
0B 0B
Z &0ŇB Z &0ŇB
j j
Ć0B Ć0B
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
&ą2 &ą2
 
Z Z
0B 0B
Z &0ŠB Z &0ŠB
j j
Ć0B Ć0B
@@ -1,7 +1,7 @@
& 2 &2
 Z  Z
&06B &06B
 Z  Z
&07B &07B
Z Z
&08B &08B
@@ -15,4 +15,4 @@
&0<B &0<B
j j
Ć0B Ć0B
 
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
&Ă2 &Ă2
 
Z Z
0B 0B
Z &0ŇB Z &0ŇB
j j
Ć0B Ć0B
Binary file not shown.
+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 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() /*primary*/ private constructor Boolean()
public final fun and(/*0*/ other: jet.Boolean): jet.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 equals(/*0*/ other: jet.Any?): jet.Boolean
public final fun not(): jet.Boolean public final fun not(): jet.Boolean
public final fun or(/*0*/ other: jet.Boolean): 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)
}
@@ -4614,11 +4614,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/library"), Pattern.compile("^(.+)\\.kt$"), true); JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/library"), Pattern.compile("^(.+)\\.kt$"), true);
} }
@TestMetadata("BooleanIsNotComparable.kt")
public void testBooleanIsNotComparable() throws Exception {
doTest("compiler/testData/diagnostics/tests/library/BooleanIsNotComparable.kt");
}
@TestMetadata("Collections.kt") @TestMetadata("Collections.kt")
public void testCollections() throws Exception { public void testCollections() throws Exception {
doTest("compiler/testData/diagnostics/tests/library/Collections.kt"); doTest("compiler/testData/diagnostics/tests/library/Collections.kt");
@@ -4051,6 +4051,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/box/operatorConventions/compareTo"), Pattern.compile("^(.+)\\.kt$"), true); JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/box/operatorConventions/compareTo"), Pattern.compile("^(.+)\\.kt$"), true);
} }
@TestMetadata("boolean.kt")
public void testBoolean() throws Exception {
doTest("compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt");
}
@TestMetadata("comparable.kt") @TestMetadata("comparable.kt")
public void testComparable() throws Exception { public void testComparable() throws Exception {
doTest("compiler/testData/codegen/box/operatorConventions/compareTo/comparable.kt"); doTest("compiler/testData/codegen/box/operatorConventions/compareTo/comparable.kt");
+3 -1
View File
@@ -37,7 +37,7 @@ public trait Hashable {
public fun equals(other : Any?) : Boolean public fun equals(other : Any?) : Boolean
} }
public class Boolean private () { public class Boolean private () : Comparable<Boolean> {
public fun not() : Boolean public fun not() : Boolean
public fun and(other : Boolean) : Boolean public fun and(other : Boolean) : Boolean
@@ -46,6 +46,8 @@ public class Boolean private () {
public fun xor(other : Boolean) : Boolean public fun xor(other : Boolean) : Boolean
public override fun compareTo(other : Boolean) : Int
public fun equals(other : Any?) : Boolean public fun equals(other : Any?) : Boolean
} }