Use NoScopeRecordCliBindingTrace for codegen tests
This commit is contained in:
+6
-1
@@ -1,3 +1,6 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun equals1(a: Double, b: Double) = a == b
|
||||
|
||||
fun equals2(a: Double?, b: Double?) = a!! == b!!
|
||||
@@ -15,7 +18,9 @@ fun box(): String {
|
||||
if (!equals2(-0.0, 0.0)) return "fail 2"
|
||||
if (!equals3(-0.0, 0.0)) return "fail 3"
|
||||
if (!equals4(-0.0, 0.0)) return "fail 4"
|
||||
if (!equals5(-0.0, 0.0)) return "fail 5"
|
||||
|
||||
// Smart casts behavior in 1.2
|
||||
if (equals5(-0.0, 0.0)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun equals1(a: Double, b: Double) = a == b
|
||||
|
||||
fun equals2(a: Double?, b: Double?) = a!! == b!!
|
||||
|
||||
fun equals3(a: Double?, b: Double?) = a != null && b != null && a == b
|
||||
|
||||
fun equals4(a: Double?, b: Double?) = if (a is Double && b is Double) a == b else null!!
|
||||
|
||||
fun equals5(a: Any?, b: Any?) = if (a is Double && b is Double) a == b else null!!
|
||||
|
||||
|
||||
fun box(): String {
|
||||
if (-0.0 != 0.0) return "fail 0"
|
||||
if (!equals1(-0.0, 0.0)) return "fail 1"
|
||||
if (!equals2(-0.0, 0.0)) return "fail 2"
|
||||
if (!equals3(-0.0, 0.0)) return "fail 3"
|
||||
if (!equals4(-0.0, 0.0)) return "fail 4"
|
||||
if (!equals5(-0.0, 0.0)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+6
-1
@@ -1,3 +1,6 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun equals1(a: Float, b: Float) = a == b
|
||||
|
||||
fun equals2(a: Float?, b: Float?) = a!! == b!!
|
||||
@@ -15,7 +18,9 @@ fun box(): String {
|
||||
if (!equals2(-0.0F, 0.0F)) return "fail 2"
|
||||
if (!equals3(-0.0F, 0.0F)) return "fail 3"
|
||||
if (!equals4(-0.0F, 0.0F)) return "fail 4"
|
||||
if (!equals5(-0.0F, 0.0F)) return "fail 5"
|
||||
|
||||
// Smart casts behavior in 1.2
|
||||
if (equals5(-0.0F, 0.0F)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun equals1(a: Float, b: Float) = a == b
|
||||
|
||||
fun equals2(a: Float?, b: Float?) = a!! == b!!
|
||||
|
||||
fun equals3(a: Float?, b: Float?) = a != null && b != null && a == b
|
||||
|
||||
fun equals4(a: Float?, b: Float?) = if (a is Float && b is Float) a == b else null!!
|
||||
|
||||
fun equals5(a: Any?, b: Any?) = if (a is Float && b is Float) a == b else null!!
|
||||
|
||||
|
||||
fun box(): String {
|
||||
if (-0.0F != 0.0F) return "fail 0"
|
||||
if (!equals1(-0.0F, 0.0F)) return "fail 1"
|
||||
if (!equals2(-0.0F, 0.0F)) return "fail 2"
|
||||
if (!equals3(-0.0F, 0.0F)) return "fail 3"
|
||||
if (!equals4(-0.0F, 0.0F)) return "fail 4"
|
||||
if (!equals5(-0.0F, 0.0F)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+12
-10
@@ -1,4 +1,6 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@@ -117,14 +119,14 @@ fun box(): String {
|
||||
assertFalse(adnq != dnq, "Double: (Any?)NaN != NaN?")
|
||||
assertFalse(adnq != adnq, "Double: (Any?)NaN != (Any?)NaN")
|
||||
|
||||
// Stable smart-casts
|
||||
// Stable smart-casts -- effectively not takein into account in 1.2
|
||||
if (adn is Double) {
|
||||
assertFalse(adn == adn, "Double smart-cast: NaN == NaN")
|
||||
assertTrue(adn != adn, "Double smart-cast: NaN == NaN")
|
||||
assertTrue(adn == adn, "Double smart-cast: NaN == NaN")
|
||||
assertFalse(adn != adn, "Double smart-cast: NaN == NaN")
|
||||
}
|
||||
if (adnq is Double?) {
|
||||
assertFalse(adnq == adnq, "Double? smart-cast: NaN? == NaN?")
|
||||
assertTrue(adnq != adnq, "Double? smart-cast: NaN? == NaN?")
|
||||
assertTrue(adnq == adnq, "Double? smart-cast: NaN? == NaN?")
|
||||
assertFalse(adnq != adnq, "Double? smart-cast: NaN? == NaN?")
|
||||
}
|
||||
// Unstable smart-casts
|
||||
if (gdn is Double) {
|
||||
@@ -192,14 +194,14 @@ fun box(): String {
|
||||
assertFalse(afnq != fnq, "Float: (Any?)NaN != NaN?")
|
||||
assertFalse(afnq != afnq, "Float: (Any?)NaN != (Any?)NaN")
|
||||
|
||||
// Stable smart-casts
|
||||
// Stable smart-casts -- effectively not takein into account in 1.2
|
||||
if (afn is Float) {
|
||||
assertFalse(afn == afn, "Float smart-cast: NaN == NaN")
|
||||
assertTrue(afn != afn, "Float smart-cast: NaN == NaN")
|
||||
assertTrue(afn == afn, "Float smart-cast: NaN == NaN")
|
||||
assertFalse(afn != afn, "Float smart-cast: NaN == NaN")
|
||||
}
|
||||
if (afnq is Float?) {
|
||||
assertFalse(afnq == afnq, "Float? smart-cast: NaN? == NaN?")
|
||||
assertTrue(afnq != afnq, "Float? smart-cast: NaN? == NaN?")
|
||||
assertTrue(afnq == afnq, "Float? smart-cast: NaN? == NaN?")
|
||||
assertFalse(afnq != afnq, "Float? smart-cast: NaN? == NaN?")
|
||||
}
|
||||
// Unstable smart-casts
|
||||
if (gfn is Float) {
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
object O {
|
||||
var equalsCalled: Boolean = false
|
||||
get(): Boolean {
|
||||
val result = field
|
||||
field = false
|
||||
return result
|
||||
}
|
||||
set(v: Boolean) {
|
||||
field = v
|
||||
}
|
||||
|
||||
override fun equals(a: Any?): Boolean {
|
||||
equalsCalled = true
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
val A: Any = O
|
||||
|
||||
fun <T: Double> testDouble(d: Double, v: T, vararg va: T) {
|
||||
assertFalse(d == d, "Double: d != d")
|
||||
assertFalse(d == v, "Double: d != v")
|
||||
assertFalse(d == va[0], "Double: d != va[0]")
|
||||
assertFalse(v == d, "Double: v != d")
|
||||
assertFalse(v == v, "Double: v != v")
|
||||
assertFalse(v == va[0], "Double: v != va[0]")
|
||||
assertFalse(va[0] == d, "Double: va[0] != d")
|
||||
assertFalse(va[0] == v, "Double: va[0] != v")
|
||||
assertFalse(va[0] == va[0], "Double: va[0] != va[0]")
|
||||
|
||||
assertTrue(d != d, "Double: d == d")
|
||||
assertTrue(d != v, "Double: d == v")
|
||||
assertTrue(d != va[0], "Double: d == va[0]")
|
||||
assertTrue(v != d, "Double: v == d")
|
||||
assertTrue(v != v, "Double: v == v")
|
||||
assertTrue(v != va[0], "Double: v == va[0]")
|
||||
assertTrue(va[0] != d, "Double: va[0] == d")
|
||||
assertTrue(va[0] != v, "Double: va[0] == v")
|
||||
assertTrue(va[0] != va[0], "Double: va[0] == va[0]")
|
||||
}
|
||||
|
||||
fun <T: Float> testFloat(d: Float, v: T, vararg va: T) {
|
||||
assertFalse(d == d, "Float: d != d")
|
||||
assertFalse(d == v, "Float: d != v")
|
||||
assertFalse(d == va[0], "Float: d != va[0]")
|
||||
assertFalse(v == d, "Float: v != d")
|
||||
assertFalse(v == v, "Float: v != v")
|
||||
assertFalse(v == va[0], "Float: v != va[0]")
|
||||
assertFalse(va[0] == d, "Float: va[0] != d")
|
||||
assertFalse(va[0] == v, "Float: va[0] != v")
|
||||
assertFalse(va[0] == va[0], "Float: va[0] != va[0]")
|
||||
|
||||
assertTrue(d != d, "Float: d == d")
|
||||
assertTrue(d != v, "Float: d == v")
|
||||
assertTrue(d != va[0], "Float: d == va[0]")
|
||||
assertTrue(v != d, "Float: v == d")
|
||||
assertTrue(v != v, "Float: v == v")
|
||||
assertTrue(v != va[0], "Float: v == va[0]")
|
||||
assertTrue(va[0] != d, "Float: va[0] == d")
|
||||
assertTrue(va[0] != v, "Float: va[0] == v")
|
||||
assertTrue(va[0] != va[0], "Float: va[0] == va[0]")
|
||||
}
|
||||
|
||||
var gdn: Any = Double.NaN
|
||||
var gfn: Any = Float.NaN
|
||||
|
||||
fun box(): String {
|
||||
|
||||
// Double
|
||||
|
||||
val dn = Double.NaN
|
||||
val adn: Any = dn
|
||||
val dnq: Double? = dn
|
||||
val adnq: Any? = dn
|
||||
|
||||
assertFalse(dn == dn, "Double: NaN == NaN")
|
||||
assertTrue(dn == adn, "Double: NaN != (Any)NaN")
|
||||
assertTrue(adn == dn, "Double: (Any)NaN != NaN")
|
||||
assertTrue(adn == adn, "Double: (Any)NaN != (Any)NaN")
|
||||
|
||||
assertFalse(dn == dnq, "Double: NaN == NaN?")
|
||||
assertTrue(dn == adnq, "Double: NaN != (Any?)NaN")
|
||||
assertTrue(adn == dnq, "Double: (Any)NaN != NaN?")
|
||||
assertTrue(adn == adnq, "Double: (Any)NaN != (Any?)NaN")
|
||||
|
||||
assertFalse(dnq == dn, "Double: NaN? == NaN")
|
||||
assertTrue(dnq == adn, "Double: NaN? != (Any)NaN")
|
||||
assertTrue(adnq == dn, "Double: (Any?)NaN != NaN")
|
||||
assertTrue(adnq == adn, "Double: (Any?)NaN != (Any)NaN")
|
||||
|
||||
assertFalse(dnq == dnq, "Double: NaN? == NaN?")
|
||||
assertTrue(dnq == adnq, "Double: NaN? != (Any?)NaN")
|
||||
assertTrue(adnq == dnq, "Double: (Any?)NaN != NaN?")
|
||||
assertTrue(adnq == adnq, "Double: (Any?)NaN != (Any?)NaN")
|
||||
|
||||
assertTrue(dn != dn, "Double: NaN == NaN")
|
||||
assertFalse(dn != adn, "Double: NaN != (Any)NaN")
|
||||
assertFalse(adn != dn, "Double: (Any)NaN != NaN")
|
||||
assertFalse(adn != adn, "Double: (Any)NaN != (Any)NaN")
|
||||
|
||||
assertTrue(dn != dnq, "Double: NaN == NaN?")
|
||||
assertFalse(dn != adnq, "Double: NaN != (Any?)NaN")
|
||||
assertFalse(adn != dnq, "Double: (Any)NaN != NaN?")
|
||||
assertFalse(adn != adnq, "Double: (Any)NaN != (Any?)NaN")
|
||||
|
||||
assertTrue(dnq != dn, "Double: NaN? == NaN")
|
||||
assertFalse(dnq != adn, "Double: NaN? != (Any)NaN")
|
||||
assertFalse(adnq != dn, "Double: (Any?)NaN != NaN")
|
||||
assertFalse(adnq != adn, "Double: (Any?)NaN != (Any)NaN")
|
||||
|
||||
assertTrue(dnq != dnq, "Double: NaN? == NaN?")
|
||||
assertFalse(dnq != adnq, "Double: NaN? != (Any?)NaN")
|
||||
assertFalse(adnq != dnq, "Double: (Any?)NaN != NaN?")
|
||||
assertFalse(adnq != adnq, "Double: (Any?)NaN != (Any?)NaN")
|
||||
|
||||
// Stable smart-casts
|
||||
if (adn is Double) {
|
||||
assertFalse(adn == adn, "Double smart-cast: NaN == NaN")
|
||||
assertTrue(adn != adn, "Double smart-cast: NaN == NaN")
|
||||
}
|
||||
if (adnq is Double?) {
|
||||
assertFalse(adnq == adnq, "Double? smart-cast: NaN? == NaN?")
|
||||
assertTrue(adnq != adnq, "Double? smart-cast: NaN? == NaN?")
|
||||
}
|
||||
// Unstable smart-casts
|
||||
if (gdn is Double) {
|
||||
assertTrue(gdn == gdn, "Unstable Double smart-cast: NaN != NaN")
|
||||
assertFalse(gdn != gdn, "Unstable Double smart-cast: NaN != NaN")
|
||||
}
|
||||
if (gdn is Double?) {
|
||||
assertTrue(gdn == gdn, "Unstable Double smart-cast: NaN != NaN")
|
||||
assertFalse(gdn != gdn, "Unstable Double smart-cast: NaN != NaN")
|
||||
}
|
||||
|
||||
// Explicit .equals
|
||||
assertTrue(A == dn && O.equalsCalled, "A.equals not called for A == dn")
|
||||
assertTrue(dn != A && !O.equalsCalled, "A.equals called for dn == A")
|
||||
assertFalse(A != dn || !O.equalsCalled, "A.equals not called for A != dn")
|
||||
assertFalse(dn == A || O.equalsCalled, "A.equals called for dn != A")
|
||||
|
||||
// Generics and varags
|
||||
testDouble(Double.NaN, Double.NaN, Double.NaN)
|
||||
|
||||
// Float
|
||||
|
||||
val fn = Float.NaN
|
||||
val afn: Any = fn
|
||||
val fnq: Float? = fn
|
||||
val afnq: Any? = fn
|
||||
|
||||
assertFalse(fn == fn, "Float: NaN == NaN")
|
||||
assertTrue(fn == afn, "Float: NaN != (Any)NaN")
|
||||
assertTrue(afn == fn, "Float: (Any)NaN != NaN")
|
||||
assertTrue(afn == afn, "Float: (Any)NaN != (Any)NaN")
|
||||
|
||||
assertFalse(fn == fnq, "Float: NaN == NaN?")
|
||||
assertTrue(fn == afnq, "Float: NaN != (Any?)NaN")
|
||||
assertTrue(afn == fnq, "Float: (Any)NaN != NaN?")
|
||||
assertTrue(afn == afnq, "Float: (Any)NaN != (Any?)NaN")
|
||||
|
||||
assertFalse(fnq == fn, "Float: NaN? == NaN")
|
||||
assertTrue(fnq == afn, "Float: NaN? != (Any)NaN")
|
||||
assertTrue(afnq == fn, "Float: (Any?)NaN != NaN")
|
||||
assertTrue(afnq == afn, "Float: (Any?)NaN != (Any)NaN")
|
||||
|
||||
assertFalse(fnq == fnq, "Float: NaN? == NaN?")
|
||||
assertTrue(fnq == afnq, "Float: NaN? != (Any?)NaN")
|
||||
assertTrue(afnq == fnq, "Float: (Any?)NaN != NaN?")
|
||||
assertTrue(afnq == afnq, "Float: (Any?)NaN != (Any?)NaN")
|
||||
|
||||
assertTrue(fn != fn, "Float: NaN == NaN")
|
||||
assertFalse(fn != afn, "Float: NaN != (Any)NaN")
|
||||
assertFalse(afn != fn, "Float: (Any)NaN != NaN")
|
||||
assertFalse(afn != afn, "Float: (Any)NaN != (Any)NaN")
|
||||
|
||||
assertTrue(fn != fnq, "Float: NaN == NaN?")
|
||||
assertFalse(fn != afnq, "Float: NaN != (Any?)NaN")
|
||||
assertFalse(afn != fnq, "Float: (Any)NaN != NaN?")
|
||||
assertFalse(afn != afnq, "Float: (Any)NaN != (Any?)NaN")
|
||||
|
||||
assertTrue(fnq != fn, "Float: NaN? == NaN")
|
||||
assertFalse(fnq != afn, "Float: NaN? != (Any)NaN")
|
||||
assertFalse(afnq != fn, "Float: (Any?)NaN != NaN")
|
||||
assertFalse(afnq != afn, "Float: (Any?)NaN != (Any)NaN")
|
||||
|
||||
assertTrue(fnq != fnq, "Float: NaN? == NaN?")
|
||||
assertFalse(fnq != afnq, "Float: NaN? != (Any?)NaN")
|
||||
assertFalse(afnq != fnq, "Float: (Any?)NaN != NaN?")
|
||||
assertFalse(afnq != afnq, "Float: (Any?)NaN != (Any?)NaN")
|
||||
|
||||
// Stable smart-casts
|
||||
if (afn is Float) {
|
||||
assertFalse(afn == afn, "Float smart-cast: NaN == NaN")
|
||||
assertTrue(afn != afn, "Float smart-cast: NaN == NaN")
|
||||
}
|
||||
if (afnq is Float?) {
|
||||
assertFalse(afnq == afnq, "Float? smart-cast: NaN? == NaN?")
|
||||
assertTrue(afnq != afnq, "Float? smart-cast: NaN? == NaN?")
|
||||
}
|
||||
// Unstable smart-casts
|
||||
if (gfn is Float) {
|
||||
assertTrue(gfn == gfn, "Unstable Float smart-cast: NaN != NaN")
|
||||
assertFalse(gfn != gfn, "Unstable Float smart-cast: NaN != NaN")
|
||||
}
|
||||
if (gfn is Float?) {
|
||||
assertTrue(gfn == gfn, "Unstable Float smart-cast: NaN != NaN")
|
||||
assertFalse(gfn != gfn, "Unstable Float smart-cast: NaN != NaN")
|
||||
}
|
||||
|
||||
assertTrue(A == fn && O.equalsCalled, "A.equals not called for A == fn")
|
||||
assertTrue(fn != A && !O.equalsCalled, "A.equals called for fn == A")
|
||||
assertFalse(A != fn || !O.equalsCalled, "A.equals not called for A != fn")
|
||||
assertFalse(fn == A || O.equalsCalled, "A.equals called for fn != A")
|
||||
|
||||
// Generics and varags
|
||||
testFloat(Float.NaN, Float.NaN, Float.NaN)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun equals1(a: Double, b: Double?) = a == b
|
||||
|
||||
fun equals2(a: Double?, b: Double?) = a!! == b!!
|
||||
@@ -20,11 +23,16 @@ fun box(): String {
|
||||
if (!equals2(-0.0, 0.0)) return "fail 2"
|
||||
if (!equals3(-0.0, 0.0)) return "fail 3"
|
||||
if (!equals4(-0.0, 0.0)) return "fail 4"
|
||||
if (!equals5(-0.0, 0.0)) return "fail 5"
|
||||
if (!equals6(-0.0, 0.0)) return "fail 6"
|
||||
|
||||
// Smart casts behavior in 1.2
|
||||
if (equals5(-0.0, 0.0)) return "fail 5"
|
||||
if (equals6(-0.0, 0.0)) return "fail 6"
|
||||
|
||||
if (!equals7(-0.0, 0.0)) return "fail 7"
|
||||
|
||||
if (!equals8(-0.0, 0.0)) return "fail 8"
|
||||
// Smart casts behavior in 1.2
|
||||
if (equals8(-0.0, 0.0)) return "fail 8"
|
||||
|
||||
if (!equals8(null, null)) return "fail 9"
|
||||
if (equals8(null, 0.0)) return "fail 10"
|
||||
if (equals8(0.0, null)) return "fail 11"
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun equals1(a: Double, b: Double?) = a == b
|
||||
|
||||
fun equals2(a: Double?, b: Double?) = a!! == b!!
|
||||
|
||||
fun equals3(a: Double?, b: Double?) = a != null && a == b
|
||||
|
||||
fun equals4(a: Double?, b: Double?) = if (a is Double) a == b else null!!
|
||||
|
||||
fun equals5(a: Any?, b: Any?) = if (a is Double && b is Double?) a == b else null!!
|
||||
|
||||
fun equals6(a: Any?, b: Any?) = if (a is Double? && b is Double) a == b else null!!
|
||||
|
||||
fun equals7(a: Double?, b: Double?) = a == b
|
||||
|
||||
fun equals8(a: Any?, b: Any?) = if (a is Double? && b is Double?) a == b else null!!
|
||||
|
||||
|
||||
fun box(): String {
|
||||
if (!equals1(-0.0, 0.0)) return "fail 1"
|
||||
if (!equals2(-0.0, 0.0)) return "fail 2"
|
||||
if (!equals3(-0.0, 0.0)) return "fail 3"
|
||||
if (!equals4(-0.0, 0.0)) return "fail 4"
|
||||
|
||||
if (!equals5(-0.0, 0.0)) return "fail 5"
|
||||
if (!equals6(-0.0, 0.0)) return "fail 6"
|
||||
|
||||
if (!equals7(-0.0, 0.0)) return "fail 7"
|
||||
|
||||
if (!equals8(-0.0, 0.0)) return "fail 8"
|
||||
|
||||
if (!equals8(null, null)) return "fail 9"
|
||||
if (equals8(null, 0.0)) return "fail 10"
|
||||
if (equals8(0.0, null)) return "fail 11"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun equals1(a: Float, b: Float?) = a == b
|
||||
|
||||
fun equals2(a: Float?, b: Float?) = a!! == b!!
|
||||
@@ -20,11 +23,16 @@ fun box(): String {
|
||||
if (!equals2(-0.0F, 0.0F)) return "fail 2"
|
||||
if (!equals3(-0.0F, 0.0F)) return "fail 3"
|
||||
if (!equals4(-0.0F, 0.0F)) return "fail 4"
|
||||
if (!equals5(-0.0F, 0.0F)) return "fail 5"
|
||||
if (!equals6(-0.0F, 0.0F)) return "fail 6"
|
||||
|
||||
// Smart casts behavior in 1.2
|
||||
if (equals5(-0.0F, 0.0F)) return "fail 5"
|
||||
if (equals6(-0.0F, 0.0F)) return "fail 6"
|
||||
|
||||
if (!equals7(-0.0F, 0.0F)) return "fail 7"
|
||||
|
||||
if (!equals8(-0.0F, 0.0F)) return "fail 8"
|
||||
// Smart casts behavior in 1.2
|
||||
if (equals8(-0.0F, 0.0F)) return "fail 8"
|
||||
|
||||
if (!equals8(null, null)) return "fail 9"
|
||||
if (equals8(null, 0.0F)) return "fail 10"
|
||||
if (equals8(0.0F, null)) return "fail 11"
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun equals1(a: Float, b: Float?) = a == b
|
||||
|
||||
fun equals2(a: Float?, b: Float?) = a!! == b!!
|
||||
|
||||
fun equals3(a: Float?, b: Float?) = a != null && a == b
|
||||
|
||||
fun equals4(a: Float?, b: Float?) = if (a is Float) a == b else null!!
|
||||
|
||||
fun equals5(a: Any?, b: Any?) = if (a is Float && b is Float?) a == b else null!!
|
||||
|
||||
fun equals6(a: Any?, b: Any?) = if (a is Float? && b is Float) a == b else null!!
|
||||
|
||||
fun equals7(a: Float?, b: Float?) = a == b
|
||||
|
||||
fun equals8(a: Any?, b: Any?) = if (a is Float? && b is Float?) a == b else null!!
|
||||
|
||||
|
||||
fun box(): String {
|
||||
if (!equals1(-0.0F, 0.0F)) return "fail 1"
|
||||
if (!equals2(-0.0F, 0.0F)) return "fail 2"
|
||||
if (!equals3(-0.0F, 0.0F)) return "fail 3"
|
||||
if (!equals4(-0.0F, 0.0F)) return "fail 4"
|
||||
|
||||
if (!equals5(-0.0F, 0.0F)) return "fail 5"
|
||||
if (!equals6(-0.0F, 0.0F)) return "fail 6"
|
||||
|
||||
if (!equals7(-0.0F, 0.0F)) return "fail 7"
|
||||
|
||||
if (!equals8(-0.0F, 0.0F)) return "fail 8"
|
||||
|
||||
if (!equals8(null, null)) return "fail 9"
|
||||
if (equals8(null, 0.0F)) return "fail 10"
|
||||
if (equals8(0.0F, null)) return "fail 11"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+6
-1
@@ -1,3 +1,6 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun greater1(a: Double, b: Double) = a > b
|
||||
|
||||
fun greater2(a: Double?, b: Double?) = a!! > b!!
|
||||
@@ -14,7 +17,9 @@ fun box(): String {
|
||||
if (greater2(0.0, -0.0)) return "fail 2"
|
||||
if (greater3(0.0, -0.0)) return "fail 3"
|
||||
if (greater4(0.0, -0.0)) return "fail 4"
|
||||
if (greater5(0.0, -0.0)) return "fail 5"
|
||||
|
||||
// Smart casts behavior in 1.2
|
||||
if (!greater5(0.0, -0.0)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun greater1(a: Double, b: Double) = a > b
|
||||
|
||||
fun greater2(a: Double?, b: Double?) = a!! > b!!
|
||||
|
||||
fun greater3(a: Double?, b: Double?) = a != null && b != null && a > b
|
||||
|
||||
fun greater4(a: Double?, b: Double?) = if (a is Double && b is Double) a > b else null!!
|
||||
|
||||
fun greater5(a: Any?, b: Any?) = if (a is Double && b is Double) a > b else null!!
|
||||
|
||||
fun box(): String {
|
||||
if (0.0 > -0.0) return "fail 0"
|
||||
if (greater1(0.0, -0.0)) return "fail 1"
|
||||
if (greater2(0.0, -0.0)) return "fail 2"
|
||||
if (greater3(0.0, -0.0)) return "fail 3"
|
||||
if (greater4(0.0, -0.0)) return "fail 4"
|
||||
if (greater5(0.0, -0.0)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+6
-1
@@ -1,3 +1,6 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun greater1(a: Float, b: Float) = a > b
|
||||
|
||||
fun greater2(a: Float?, b: Float?) = a!! > b!!
|
||||
@@ -14,7 +17,9 @@ fun box(): String {
|
||||
if (greater2(0.0F, -0.0F)) return "fail 2"
|
||||
if (greater3(0.0F, -0.0F)) return "fail 3"
|
||||
if (greater4(0.0F, -0.0F)) return "fail 4"
|
||||
if (greater5(0.0F, -0.0F)) return "fail 5"
|
||||
|
||||
// Smart casts behavior in 1.2
|
||||
if (!greater5(0.0F, -0.0F)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun greater1(a: Float, b: Float) = a > b
|
||||
|
||||
fun greater2(a: Float?, b: Float?) = a!! > b!!
|
||||
|
||||
fun greater3(a: Float?, b: Float?) = a != null && b != null && a > b
|
||||
|
||||
fun greater4(a: Float?, b: Float?) = if (a is Float && b is Float) a > b else null!!
|
||||
|
||||
fun greater5(a: Any?, b: Any?) = if (a is Float && b is Float) a > b else null!!
|
||||
|
||||
fun box(): String {
|
||||
if (0.0F > -0.0F) return "fail 0"
|
||||
if (greater1(0.0F, -0.0F)) return "fail 1"
|
||||
if (greater2(0.0F, -0.0F)) return "fail 2"
|
||||
if (greater3(0.0F, -0.0F)) return "fail 3"
|
||||
if (greater4(0.0F, -0.0F)) return "fail 4"
|
||||
|
||||
if (greater5(0.0F, -0.0F)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+6
-1
@@ -1,3 +1,6 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun less1(a: Double, b: Double) = a < b
|
||||
|
||||
fun less2(a: Double?, b: Double?) = a!! < b!!
|
||||
@@ -14,7 +17,9 @@ fun box(): String {
|
||||
if (less2(-0.0, 0.0)) return "fail 2"
|
||||
if (less3(-0.0, 0.0)) return "fail 3"
|
||||
if (less4(-0.0, 0.0)) return "fail 4"
|
||||
if (less5(-0.0, 0.0)) return "fail 5"
|
||||
|
||||
// Smart casts behavior in 1.2
|
||||
if (!less5(-0.0, 0.0)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun less1(a: Double, b: Double) = a < b
|
||||
|
||||
fun less2(a: Double?, b: Double?) = a!! < b!!
|
||||
|
||||
fun less3(a: Double?, b: Double?) = a != null && b != null && a < b
|
||||
|
||||
fun less4(a: Double?, b: Double?) = if (a is Double && b is Double) a < b else null!!
|
||||
|
||||
fun less5(a: Any?, b: Any?) = if (a is Double && b is Double) a < b else null!!
|
||||
|
||||
fun box(): String {
|
||||
if (-0.0 < 0.0) return "fail 0"
|
||||
if (less1(-0.0, 0.0)) return "fail 1"
|
||||
if (less2(-0.0, 0.0)) return "fail 2"
|
||||
if (less3(-0.0, 0.0)) return "fail 3"
|
||||
if (less4(-0.0, 0.0)) return "fail 4"
|
||||
|
||||
if (less5(-0.0, 0.0)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+6
-1
@@ -1,3 +1,6 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun less1(a: Float, b: Float) = a < b
|
||||
|
||||
fun less2(a: Float?, b: Float?) = a!! < b!!
|
||||
@@ -14,7 +17,9 @@ fun box(): String {
|
||||
if (less2(-0.0F, 0.0F)) return "fail 2"
|
||||
if (less3(-0.0F, 0.0F)) return "fail 3"
|
||||
if (less4(-0.0F, 0.0F)) return "fail 4"
|
||||
if (less5(-0.0F, 0.0F)) return "fail 5"
|
||||
|
||||
// Smart casts behavior in 1.2
|
||||
if (!less5(-0.0F, 0.0F)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun less1(a: Float, b: Float) = a < b
|
||||
|
||||
fun less2(a: Float?, b: Float?) = a!! < b!!
|
||||
|
||||
fun less3(a: Float?, b: Float?) = a != null && b != null && a < b
|
||||
|
||||
fun less4(a: Float?, b: Float?) = if (a is Float && b is Float) a < b else true
|
||||
|
||||
fun less5(a: Any?, b: Any?) = if (a is Float && b is Float) a < b else true
|
||||
|
||||
fun box(): String {
|
||||
if (-0.0F < 0.0F) return "fail 0"
|
||||
if (less1(-0.0F, 0.0F)) return "fail 1"
|
||||
if (less2(-0.0F, 0.0F)) return "fail 2"
|
||||
if (less3(-0.0F, 0.0F)) return "fail 3"
|
||||
if (less4(-0.0F, 0.0F)) return "fail 4"
|
||||
|
||||
if (less5(-0.0F, 0.0F)) return "fail 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+9
-2
@@ -1,25 +1,32 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun box(): String {
|
||||
val plusZero: Any = 0.0
|
||||
val minusZero: Any = -0.0
|
||||
val nullDouble: Double? = null
|
||||
if (plusZero is Double) {
|
||||
// Smart casts behavior in 1.2
|
||||
when (plusZero) {
|
||||
nullDouble -> {
|
||||
return "fail 1"
|
||||
}
|
||||
-0.0 -> {
|
||||
return "fail 2"
|
||||
}
|
||||
else -> return "fail 2"
|
||||
else -> {}
|
||||
}
|
||||
|
||||
if (minusZero is Double) {
|
||||
// Smart casts behavior in 1.2
|
||||
when (plusZero) {
|
||||
nullDouble -> {
|
||||
return "fail 3"
|
||||
}
|
||||
minusZero -> {
|
||||
return "fail 4"
|
||||
}
|
||||
else -> return "fail 4"
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-2
@@ -1,4 +1,6 @@
|
||||
// LANGUAGE_VERSION: 1.0
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun box(): String {
|
||||
val plusZero: Any = 0.0
|
||||
val minusZero: Any = -0.0
|
||||
@@ -9,8 +11,9 @@ fun box(): String {
|
||||
return "fail 1"
|
||||
}
|
||||
-0.0 -> {
|
||||
return "fail 2"
|
||||
}
|
||||
else -> return "fail 2"
|
||||
else -> {}
|
||||
}
|
||||
|
||||
if (minusZero is Double) {
|
||||
@@ -19,8 +22,9 @@ fun box(): String {
|
||||
return "fail 3"
|
||||
}
|
||||
minusZero -> {
|
||||
return "fail 4"
|
||||
}
|
||||
else -> return "fail 4"
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun box(): String {
|
||||
val plusZero: Any = 0.0
|
||||
val minusZero: Any = -0.0
|
||||
val nullDouble: Double? = null
|
||||
if (plusZero is Double) {
|
||||
when (plusZero) {
|
||||
nullDouble -> {
|
||||
return "fail 1"
|
||||
}
|
||||
-0.0 -> {
|
||||
}
|
||||
else -> {
|
||||
return "fail 2"
|
||||
}
|
||||
}
|
||||
|
||||
if (minusZero is Double) {
|
||||
when (plusZero) {
|
||||
nullDouble -> {
|
||||
return "fail 3"
|
||||
}
|
||||
minusZero -> {
|
||||
}
|
||||
else -> {
|
||||
return "fail 4"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+7
-4
@@ -1,3 +1,6 @@
|
||||
// !LANGUAGE: -ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun box(): String {
|
||||
val plusZero: Any = 0.0
|
||||
val minusZero: Any = -0.0
|
||||
@@ -7,18 +10,18 @@ fun box(): String {
|
||||
return "fail 1"
|
||||
}
|
||||
|
||||
plusZero > minusZero -> {
|
||||
return "fail 2"
|
||||
}
|
||||
plusZero > minusZero -> {}
|
||||
else -> {
|
||||
return "fail 2"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
when {
|
||||
plusZero == minusZero -> {
|
||||
return "fail 3"
|
||||
}
|
||||
else -> return "fail 3"
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun box(): String {
|
||||
val plusZero: Any = 0.0
|
||||
val minusZero: Any = -0.0
|
||||
if (plusZero is Double && minusZero is Double) {
|
||||
when {
|
||||
plusZero < minusZero -> {
|
||||
return "fail 1"
|
||||
}
|
||||
|
||||
plusZero > minusZero -> {
|
||||
return "fail 2"
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
|
||||
when {
|
||||
plusZero == minusZero -> {}
|
||||
else -> {
|
||||
return "fail 3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// !LANGUAGE: +ProperIeee754Comparisons
|
||||
|
||||
fun box(): String {
|
||||
val plusZero: Any = 0.0
|
||||
val minusZero: Any = -0.0
|
||||
val nullDouble: Double? = null
|
||||
if (plusZero is Double) {
|
||||
when (plusZero) {
|
||||
nullDouble -> {
|
||||
return "fail 1"
|
||||
}
|
||||
-0.0 -> {
|
||||
}
|
||||
else -> {
|
||||
return "fail 2"
|
||||
}
|
||||
}
|
||||
|
||||
if (minusZero is Double) {
|
||||
when (plusZero) {
|
||||
nullDouble -> {
|
||||
return "fail 3"
|
||||
}
|
||||
minusZero -> {
|
||||
}
|
||||
else -> {
|
||||
return "fail 4"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user