[JS BE] Support val in when subject
#KT-25014 Fixed
This commit is contained in:
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun box(): String {
|
||||
var y: String = "OK"
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS, JS_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
fun dense(x: Int): Int {
|
||||
return when (val xx = x) {
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
val x = 1
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
val dz = -0.0
|
||||
val fz = -0.0f
|
||||
@@ -29,5 +28,14 @@ fun box(): String {
|
||||
}
|
||||
}
|
||||
|
||||
testDoubleAsUpperBound(-0.0)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun <T: Double> testDoubleAsUpperBound(v: T): Boolean {
|
||||
return when (val a = v*v) {
|
||||
0.0 -> true
|
||||
else -> throw AssertionError()
|
||||
}
|
||||
}
|
||||
|
||||
+15
-5
@@ -1,22 +1,32 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject +ProperIeee754Comparisons
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND: JS, JS_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
val az: Any = -0.0
|
||||
val afz: Any = -0.0f
|
||||
|
||||
fun box(): String {
|
||||
when (val y = az) {
|
||||
val y = az
|
||||
when (y) {
|
||||
!is Double -> throw AssertionError()
|
||||
0.0 -> {}
|
||||
else -> throw AssertionError()
|
||||
}
|
||||
|
||||
when (val y = afz) {
|
||||
val yy = afz
|
||||
when (yy) {
|
||||
!is Float -> throw AssertionError()
|
||||
0.0 -> {}
|
||||
else -> throw AssertionError()
|
||||
}
|
||||
|
||||
testDoubleAsUpperBound(-0.0)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun <T: Double> testDoubleAsUpperBound(v: T): Boolean {
|
||||
return when (val a = v*v) {
|
||||
0.0 -> true
|
||||
else -> throw AssertionError()
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
val x: Any = 1
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS, JS_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
fun sparse(x: Int): Int {
|
||||
return when (val xx = (x % 4) * 100) {
|
||||
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
var effectCount = 0
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS, JS_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS, JS_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
|
||||
Reference in New Issue
Block a user