Unsigned arith corrected for JS

This commit is contained in:
Yuriy Glukhov
2016-01-21 01:27:34 +02:00
parent 72b975d1ff
commit c0d0e5efd9
4 changed files with 67 additions and 147 deletions

View File

@@ -1,14 +1,28 @@
discard """
output: '''253'''
"""
# bug #2427
block: # bug #2427
var x = 0'u8
dec x # OverflowError
x -= 1 # OverflowError
x = x - 1 # No error
import unsigned
doAssert(x == 253'u8)
var x = 0'u8
dec x # OverflowError
x -= 1 # OverflowError
x = x - 1 # No error
block:
var x = 130'u8
x += 130'u8
doAssert(x == 4'u8)
echo x
block:
var x = 40000'u16
x = x + 40000'u16
doAssert(x == 14464'u16)
block:
var x = 4000000000'u32
x = x + 4000000000'u32
doAssert(x == 3705032704'u32)
block:
var x = 123'u16
x -= 125
doAssert(x == 65534'u16)

View File

@@ -220,7 +220,7 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
"actiontable/tactiontable", "method/tmultim1",
"method/tmultim3", "method/tmultim4",
"varres/tvarres0", "varres/tvarres3", "varres/tvarres4",
"varres/tvartup"]:
"varres/tvartup", "misc/tunsignedinc"]:
test "tests/" & testfile & ".nim"
for testfile in ["pure/strutils"]: