JS backend: testFiles -> testData
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package foo
|
||||
|
||||
fun testShortConversions(c: Short): Boolean {
|
||||
if (c.toDouble() != 3.0) {
|
||||
return false
|
||||
}
|
||||
if (c.toFloat() != 3.toFloat()) {
|
||||
return false
|
||||
}
|
||||
if (c.toByte() != 3.toByte()) {
|
||||
return false
|
||||
}
|
||||
if (c.toInt() != 3) {
|
||||
return false
|
||||
}
|
||||
if (c.toShort() != 3.toShort()) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun testByteConversions(c: Byte): Boolean {
|
||||
if (c.toDouble() != 3.0) {
|
||||
return false
|
||||
}
|
||||
if (c.toFloat() != 3.toFloat()) {
|
||||
return false
|
||||
}
|
||||
if (c.toByte() != 3.toByte()) {
|
||||
return false
|
||||
}
|
||||
if (c.toInt() != 3) {
|
||||
return false
|
||||
}
|
||||
if (c.toShort() != 3.toShort()) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun box() = testShortConversions(3) && testByteConversions(3)
|
||||
@@ -0,0 +1,44 @@
|
||||
package foo
|
||||
|
||||
fun box(): Any? {
|
||||
if (3 / 4 != 0) {
|
||||
return "1"
|
||||
}
|
||||
if (-5 / 4 != -1) {
|
||||
return -5 / 4
|
||||
}
|
||||
if ((3.0 / 4.0 - 0.75) > 0.01) {
|
||||
return "3"
|
||||
}
|
||||
if ((-10.0 / 4.0 + 2.5) > 0.01) {
|
||||
return "4"
|
||||
}
|
||||
val i1: Int = 5
|
||||
val i2: Int = 2
|
||||
if (i1 / i2 != 2) {
|
||||
return "5"
|
||||
}
|
||||
val i3: Short = 5
|
||||
val i4: Short = 2
|
||||
if (i3 / i4 != 2) {
|
||||
return "6"
|
||||
}
|
||||
val i5: Byte = 5
|
||||
val i6: Byte = 2
|
||||
if (i5 / i6 != 2) {
|
||||
return "7"
|
||||
}
|
||||
|
||||
val f1: Double = 5.0
|
||||
val f2: Double = 2.0
|
||||
if ((f1 / f2 - 2.5) > 0.01) {
|
||||
return "8"
|
||||
}
|
||||
|
||||
val f3: Float = 5.0.toFloat()
|
||||
val f4: Float = 2.0.toFloat()
|
||||
if ((f3 / f4 - 2.5.toFloat()) > 0.01) {
|
||||
return "9"
|
||||
}
|
||||
return "SUCCESS"
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package foo
|
||||
|
||||
fun box(): Boolean {
|
||||
val c: Double = 3.6
|
||||
if (c.toDouble() != 3.6) {
|
||||
return false
|
||||
}
|
||||
if (c.toFloat() != 3.6.toFloat()) {
|
||||
return false
|
||||
}
|
||||
if (c.toByte() != 3.toByte()) {
|
||||
return false
|
||||
}
|
||||
if (c.toInt() != 3) {
|
||||
return false
|
||||
}
|
||||
if (c.toShort() != 3.toShort()) {
|
||||
return false
|
||||
}
|
||||
|
||||
val cn: Double = -3.6
|
||||
if (cn.toDouble() != -3.6) {
|
||||
return false
|
||||
}
|
||||
if (cn.toFloat() != -3.6.toFloat()) {
|
||||
return false
|
||||
}
|
||||
if (cn.toByte() != (-3).toByte()) {
|
||||
return false
|
||||
}
|
||||
if (cn.toInt() != -3) {
|
||||
return false
|
||||
}
|
||||
if (cn.toShort() != (-3).toShort()) {
|
||||
return false
|
||||
}
|
||||
|
||||
val f: Float = 3.6.toFloat()
|
||||
if (f.toDouble() != 3.6) {
|
||||
return false
|
||||
}
|
||||
if (f.toFloat() != 3.6.toFloat()) {
|
||||
return false
|
||||
}
|
||||
if (f.toByte() != 3.toByte()) {
|
||||
return false
|
||||
}
|
||||
if (f.toInt() != 3) {
|
||||
return false
|
||||
}
|
||||
if (f.toShort() != 3.toShort()) {
|
||||
return false
|
||||
}
|
||||
|
||||
val fn: Float = -3.6.toFloat()
|
||||
if (fn.toDouble() != -3.6) {
|
||||
return false
|
||||
}
|
||||
if (fn.toFloat() != -3.6.toFloat()) {
|
||||
return false
|
||||
}
|
||||
if (fn.toByte() != (-3).toByte()) {
|
||||
return false
|
||||
}
|
||||
if (fn.toInt() != -3) {
|
||||
return false
|
||||
}
|
||||
if (fn.toShort() != (-3).toShort()) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package foo
|
||||
|
||||
fun box(): Boolean {
|
||||
val i = 0x80000000 + 0x8000000
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package foo
|
||||
|
||||
fun box(): Boolean {
|
||||
val c: Int = 3
|
||||
if (c.toDouble() != 3.0) {
|
||||
return false
|
||||
}
|
||||
if (c.toFloat() != 3.toFloat()) {
|
||||
return false
|
||||
}
|
||||
if (c.toByte() != 3.toByte()) {
|
||||
return false
|
||||
}
|
||||
if (c.toInt() != 3) {
|
||||
return false
|
||||
}
|
||||
if (c.toShort() != 3.toShort()) {
|
||||
return false
|
||||
}
|
||||
val c2: Int = -5
|
||||
if (c2.toShort() != (-5).toShort()) {
|
||||
return false
|
||||
}
|
||||
if (c2.toFloat() != -5.toFloat()) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package foo
|
||||
|
||||
fun test(a: Int, b: Int, expected: Int): String {
|
||||
val result = a / b
|
||||
if (expected == result) return "OK"
|
||||
return "$a / $b = $result. Expected $expected"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var r = test(10, 3, 3)
|
||||
if (r != "OK") return r
|
||||
|
||||
r = test(49, 6, 8)
|
||||
if (r != "OK") return r
|
||||
|
||||
if (2133 / 3 / 7 / (91 / 5) != 5) return "2133 / 3 / 7 / (91 / 5) != 5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package foo
|
||||
|
||||
fun testIntegerConversions(c: Number): Boolean {
|
||||
if (c.toDouble() != 3.0) {
|
||||
return false
|
||||
}
|
||||
if (c.toFloat() != 3.toFloat()) {
|
||||
return false
|
||||
}
|
||||
if (c.toByte() != 3.toByte()) {
|
||||
return false
|
||||
}
|
||||
if (c.toInt() != 3) {
|
||||
return false
|
||||
}
|
||||
if (c.toShort() != 3.toShort()) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun testFloatingPointConversions(c: Number): Boolean {
|
||||
if (c.toDouble() != 3.6) {
|
||||
return false
|
||||
}
|
||||
if (c.toFloat() != 3.6.toFloat()) {
|
||||
return false
|
||||
}
|
||||
if (c.toByte() != 3.toByte()) {
|
||||
return false
|
||||
}
|
||||
if (c.toInt() != 3) {
|
||||
return false
|
||||
}
|
||||
if (c.toShort() != 3.toShort()) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun box(): Boolean = testIntegerConversions(3) && testFloatingPointConversions(3.6) && testFloatingPointConversions(3.6.toFloat()) &&
|
||||
testIntegerConversions(3.toByte()) && testIntegerConversions(3.toShort())
|
||||
Reference in New Issue
Block a user