JS: trying to implement integer overflow for increment and decrement

This commit is contained in:
Alexey Andreev
2016-09-23 17:17:32 +03:00
parent 446c4c0a33
commit c854b81a09
8 changed files with 238 additions and 74 deletions
@@ -0,0 +1,24 @@
package foo
fun box(): String {
var b: Byte = 0x7F
b++
if (b.toInt() != -0x80) return "fail1a: $b"
b--
if (b.toInt() != 0x7F) return "fail1b: $b"
var s: Short = 0x7FFF
s++
if (s.toInt() != -0x8000) return "fail2a: $s"
s--
if (s.toInt() != 0x7FFF) return "fail2b: $s"
var i: Int = 0x7FFFFFFF
i++
if (i != -0x80000000) return "fail3a: $i"
i--
if (i != 0x7FFFFFFF) return "fail3b: $i"
return "OK"
}