int128 on firstOrd, lastOrd and lengthOrd (#11701)

* fixes #11847
This commit is contained in:
Arne Döring
2019-08-07 15:53:16 +02:00
committed by Andreas Rumpf
parent 8407a57499
commit afbcd1b330
34 changed files with 530 additions and 314 deletions

View File

@@ -29,6 +29,7 @@ block tcast:
let rt = ty(exp)
const ct = ty(exp)
if $rt != $ct:
echo astToStr(exp)
echo "Got ", ct
echo "Expected ", rt
@@ -52,7 +53,7 @@ block tcast:
crossCheck(uint8, uint8.high + 5'u8)
crossCheck(uint16, uint16.high + 5'u16)
crossCheck(uint32, uint32.high + 5'u32)
crossCheck(uint64, (-1).uint64 + 5'u64)
crossCheck(uint64, 0xFFFFFFFFFFFFFFFF'u64 + 5'u64)
doAssert $sub1(0'u8) == "255"
doAssert $sub1(0'u16) == "65535"
@@ -69,12 +70,10 @@ block tcast:
crossCheck(int64, high(int8).int16.int32.int64)
crossCheck(int64, low(int8).int16.int32.int64)
crossCheck(int64, 0xFFFFFFFFFFFFFFFF'u64)
crossCheck(int32, 0xFFFFFFFFFFFFFFFF'u64)
crossCheck(int16, 0xFFFFFFFFFFFFFFFF'u64)
crossCheck(int8 , 0xFFFFFFFFFFFFFFFF'u64)
doAssert not compiles(echo int64(0xFFFFFFFFFFFFFFFF'u64))
doAssert not compiles(echo int32(0xFFFFFFFFFFFFFFFF'u64))
doAssert not compiles(echo int16(0xFFFFFFFFFFFFFFFF'u64))
doAssert not compiles(echo int8(0xFFFFFFFFFFFFFFFF'u64))
block tnot:
# Signed types
@@ -116,32 +115,6 @@ block tnot:
doAssert t7 == 4
block tshl:
# Signed types
block:
const t0: int8 = 1'i8 shl 8
const t1: int16 = 1'i16 shl 16
const t2: int32 = 1'i32 shl 32
const t3: int64 = 1'i64 shl 64
doAssert t0 == 0
doAssert t1 == 0
doAssert t2 == 1
doAssert t3 == 1
# Unsigned types
block:
const t0: uint8 = 1'u8 shl 8
const t1: uint16 = 1'u16 shl 16
const t2: uint32 = 1'u32 shl 32
const t3: uint64 = 1'u64 shl 64
doAssert t0 == 0
doAssert t1 == 0
doAssert t2 == 0
doAssert t3 == 1
block tshr:
proc T() =
# let VI = -8

View File

@@ -122,8 +122,13 @@ let expLines = splitLines(expected.strip)
if resLines.len != expLines.len:
echo("Not matched! Wrong number of lines!")
echo()
echo(result)
echo expLines.len
echo resLines.len
echo("Expected: -----------")
echo expected
echo("Gotten: -------------")
echo result
echo("---------------------")
quit(QuitFailure)
var ok = true

View File

@@ -24,4 +24,4 @@ doAssertRaises(OverflowError): discard high(int64) * 2
doAssert abs(-1) == 1
doAssert 2 div 2 == 1
doAssert 2 * 3 == 6
doAssert 2 * 3 == 6

View File

@@ -5,7 +5,7 @@ discard """
static:
proc p =
var
x = 1 shl 62
x = 1'i64 shl 62
discard x * 2
assert false
p()