Files
kotlin-fork/js/js.translator/testData/wasmBox/number/doubleConversions.kt
T
Svyatoslav Kuzmich 6e6ffa12a6 [WASM] Initial infrastructure
- New module ":compiler:backend.wasm"
    - Initial compiler infra (driver, phaser, context)
    - Subset of Wasm AST
    - Skeleton of IR -> Wasm AST
    - Wasm AST -> WAT transformer

- Testing infra

- SpiderMonkey jsshell tool
2019-08-22 15:59:54 +03:00

77 lines
1.6 KiB
Kotlin
Vendored

// EXPECTED_REACHABLE_NODES: 1222
// IGNORE_BACKEND: WASM
// TODO: Support floating-point to integer conversions
package foo
fun box(): String {
val c: Double = 3.6
if (c.toDouble() != 3.6) {
return "fail1"
}
if (c.toFloat() != 3.6.toFloat()) {
return "fail2"
}
if (c.toByte() != 3.toByte()) {
return "fail3"
}
if (c.toInt() != 3) {
return "fail4"
}
if (c.toShort() != 3.toShort()) {
return "fail5"
}
val cn: Double = -3.6
if (cn.toDouble() != -3.6) {
return "fail6"
}
if (cn.toFloat() != -3.6.toFloat()) {
return "fail7"
}
if (cn.toByte() != (-3).toByte()) {
return "fail8"
}
if (cn.toInt() != -3) {
return "fail9"
}
if (cn.toShort() != (-3).toShort()) {
return "fail10"
}
val f: Float = 3.6.toFloat()
if (f.toDouble() != 3.6) {
return "fail11"
}
if (f.toFloat() != 3.6.toFloat()) {
return "fail12"
}
if (f.toByte() != 3.toByte()) {
return "fail13"
}
if (f.toInt() != 3) {
return "fail14"
}
if (f.toShort() != 3.toShort()) {
return "fail15"
}
val fn: Float = -3.6.toFloat()
if (fn.toDouble() != -3.6) {
return "fail16"
}
if (fn.toFloat() != -3.6.toFloat()) {
return "fail17"
}
if (fn.toByte() != (-3).toByte()) {
return "fail18"
}
if (fn.toInt() != -3) {
return "fail19"
}
if (fn.toShort() != (-3).toShort()) {
return "fail20"
}
return "OK"
}