From d70e292571754f1c00baf9651c558378537cdba8 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 2 Sep 2019 22:03:06 +0200 Subject: [PATCH] makes more tests green --- compiler/int128.nim | 8 -------- compiler/semfold.nim | 4 ++-- tests/stdlib/tbitops.nim | 14 +++++++------- tests/vm/ttouintconv.nim | 4 ++-- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/compiler/int128.nim b/compiler/int128.nim index efa55f9c7..5d326ccab 100644 --- a/compiler/int128.nim +++ b/compiler/int128.nim @@ -16,13 +16,6 @@ template sdata(arg: Int128, idx: int): int32 = # encoding least significant int first (like LittleEndian) -type - InvalidArgument = object of Exception - -template require(cond: bool) = - if unlikely(not cond): - raise newException(InvalidArgument, "") - const Zero* = Int128(udata: [0'u32,0,0,0]) One* = Int128(udata: [1'u32,0,0,0]) @@ -378,7 +371,6 @@ proc `*`*(lhs,rhs: Int128): Int128 = result = result + toInt128(a00 * b32) shl 32 if isNegative != isNegative(result): - echo result assert(false, "overflow") proc `*=`*(a: var Int128, b: Int128) = diff --git a/compiler/semfold.nim b/compiler/semfold.nim index a1732ebb4..cf1586144 100644 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -396,13 +396,13 @@ proc leValueConv*(a, b: PNode): bool = case a.kind of nkCharLit..nkUInt64Lit: case b.kind - of nkCharLit..nkUInt64Lit: result = a.intVal <= b.intVal + of nkCharLit..nkUInt64Lit: result = a.getInt <= b.getInt of nkFloatLit..nkFloat128Lit: result = a.intVal <= round(b.floatVal).int else: result = false #internalError(a.info, "leValueConv") of nkFloatLit..nkFloat128Lit: case b.kind of nkFloatLit..nkFloat128Lit: result = a.floatVal <= b.floatVal - of nkCharLit..nkUInt64Lit: result = a.floatVal <= toFloat(int(b.intVal)) + of nkCharLit..nkUInt64Lit: result = a.floatVal <= toFloat64(b.getInt) else: result = false # internalError(a.info, "leValueConv") else: result = false # internalError(a.info, "leValueConv") diff --git a/tests/stdlib/tbitops.nim b/tests/stdlib/tbitops.nim index b2393b755..e4461345e 100644 --- a/tests/stdlib/tbitops.nim +++ b/tests/stdlib/tbitops.nim @@ -211,15 +211,15 @@ proc main() = proc testReverseBitsPerType(x, reversed: uint64) = doAssert reverseBits(x) == reversed - doAssert reverseBits(uint32(x)) == uint32(reversed shr 32) - doAssert reverseBits(uint32(x shr 16)) == uint32(reversed shr 16) - doAssert reverseBits(uint16(x)) == uint16(reversed shr 48) - doAssert reverseBits(uint8(x)) == uint8(reversed shr 56) + doAssert reverseBits(cast[uint32](x)) == cast[uint32](reversed shr 32) + doAssert reverseBits(cast[uint32](x shr 16)) == cast[uint32](reversed shr 16) + doAssert reverseBits(cast[uint16](x)) == cast[uint16](reversed shr 48) + doAssert reverseBits(cast[uint8](x)) == cast[uint8](reversed shr 56) testReverseBitsInvo(x) - testReverseBitsInvo(uint32(x)) - testReverseBitsInvo(uint16(x)) - testReverseBitsInvo(uint8(x)) + testReverseBitsInvo(cast[uint32](x)) + testReverseBitsInvo(cast[uint16](x)) + testReverseBitsInvo(cast[uint8](x)) proc testReverseBitsRefl(x, reversed: uint64) = testReverseBitsPerType(x, reversed) diff --git a/tests/vm/ttouintconv.nim b/tests/vm/ttouintconv.nim index 403de8f41..ff2187a36 100644 --- a/tests/vm/ttouintconv.nim +++ b/tests/vm/ttouintconv.nim @@ -69,8 +69,8 @@ macro foo2() = echo zz var ww = -9 - var vv = ww.uint - var kk = vv.uint32 + var vv = cast[uint](ww) + var kk = cast[uint32](vv) echo kk foo()