[JS IR BE] Fix translation for float literals
This commit is contained in:
+3
-1
@@ -44,11 +44,13 @@ class IrElementToJsExpressionTransformer : BaseIrElementToJsNodeTransformer<JsEx
|
||||
is IrConstKind.Int -> JsIntLiteral(kind.valueOf(expression))
|
||||
is IrConstKind.Long -> throw IllegalStateException("Long const should have been lowered at this point")
|
||||
is IrConstKind.Char -> throw IllegalStateException("Char const should have been lowered at this point")
|
||||
is IrConstKind.Float -> JsDoubleLiteral(kind.valueOf(expression).toDouble())
|
||||
is IrConstKind.Float -> JsDoubleLiteral(toDoubleConst(kind.valueOf(expression)))
|
||||
is IrConstKind.Double -> JsDoubleLiteral(kind.valueOf(expression))
|
||||
}
|
||||
}
|
||||
|
||||
private fun toDoubleConst(f: Float) = if (f.isInfinite() || f.isNaN()) f.toDouble() else f.toString().toDouble()
|
||||
|
||||
override fun visitStringConcatenation(expression: IrStringConcatenation, context: JsGenerationContext): JsExpression {
|
||||
// TODO revisit
|
||||
return expression.arguments.fold<IrExpression, JsExpression>(JsStringLiteral("")) { jsExpr, irExpr ->
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
fun box(): String {
|
||||
if (1F != 1.toFloat()) return "fail 1"
|
||||
if (1.0F != 1.0.toFloat()) return "fail 2"
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun checkByteArray(): Boolean {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
Reference in New Issue
Block a user