make test green
This commit is contained in:
parent
e765687646
commit
2396f0ee71
3 changed files with 48 additions and 37 deletions
|
|
@ -149,7 +149,7 @@ proc checkConvertible(c: PContext, targetTyp: PType, src: PNode): TConvStatus =
|
||||||
(srcBaseTyp.kind in IntegralTypes):
|
(srcBaseTyp.kind in IntegralTypes):
|
||||||
if targetTyp.isOrdinalType:
|
if targetTyp.isOrdinalType:
|
||||||
if src.kind in nkCharLit..nkUInt64Lit and
|
if src.kind in nkCharLit..nkUInt64Lit and
|
||||||
src.intVal notin firstOrd(c.config, targetTyp)..lastOrd(c.config, targetTyp):
|
src.getInt notin firstOrd(c.config, targetTyp)..lastOrd(c.config, targetTyp):
|
||||||
result = convNotInRange
|
result = convNotInRange
|
||||||
elif src.kind in nkFloatLit..nkFloat64Lit and
|
elif src.kind in nkFloatLit..nkFloat64Lit and
|
||||||
(classify(src.floatVal) in {fcNan, fcNegInf, fcInf} or
|
(classify(src.floatVal) in {fcNan, fcNegInf, fcInf} or
|
||||||
|
|
|
||||||
|
|
@ -206,8 +206,9 @@ proc evalOp(m: TMagic, n, a, b, c: PNode; g: ModuleGraph): PNode =
|
||||||
of mSubI: result = foldSub(getInt(a), getInt(b), n, g)
|
of mSubI: result = foldSub(getInt(a), getInt(b), n, g)
|
||||||
of mMulI: result = foldMul(getInt(a), getInt(b), n, g)
|
of mMulI: result = foldMul(getInt(a), getInt(b), n, g)
|
||||||
of mMinI:
|
of mMinI:
|
||||||
if getInt(a) > getInt(b): result = newIntNodeT(getInt64(b), n, g)
|
let argA = getInt(a)
|
||||||
else: result = newIntNodeT(getInt64(a), n, g)
|
let argB = getInt(b)
|
||||||
|
result = newIntNodeT(if argA < argB: argA else: argB, n, g)
|
||||||
of mMaxI:
|
of mMaxI:
|
||||||
let argA = getInt(a)
|
let argA = getInt(a)
|
||||||
let argB = getInt(b)
|
let argB = getInt(b)
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,52 @@
|
||||||
template reject(e) =
|
discard """
|
||||||
static: assert(not compiles(e))
|
cmd: "nim check --hint[Processing]:off --hint[Conf]:off $file"
|
||||||
|
errormsg: "18446744073709551615 can't be converted to int8"
|
||||||
template accept(e) =
|
nimout: '''tcompiletime_range_checks.nim(36, 21) Error: 2147483648 can't be converted to int32
|
||||||
static: assert(compiles(e))
|
tcompiletime_range_checks.nim(37, 23) Error: -1 can't be converted to uint64
|
||||||
|
tcompiletime_range_checks.nim(38, 34) Error: 255 can't be converted to FullNegativeRange
|
||||||
|
tcompiletime_range_checks.nim(39, 34) Error: 18446744073709551615 can't be converted to HalfNegativeRange
|
||||||
|
tcompiletime_range_checks.nim(40, 34) Error: 300 can't be converted to FullPositiveRange
|
||||||
|
tcompiletime_range_checks.nim(41, 30) Error: 101 can't be converted to UnsignedRange
|
||||||
|
tcompiletime_range_checks.nim(42, 32) Error: -9223372036854775808 can't be converted to SemiOutOfBounds
|
||||||
|
tcompiletime_range_checks.nim(44, 22) Error: nan can't be converted to int32
|
||||||
|
tcompiletime_range_checks.nim(46, 23) Error: 1e+100 can't be converted to uint64
|
||||||
|
tcompiletime_range_checks.nim(49, 22) Error: 18446744073709551615 can't be converted to int64
|
||||||
|
tcompiletime_range_checks.nim(50, 22) Error: 18446744073709551615 can't be converted to int32
|
||||||
|
tcompiletime_range_checks.nim(51, 22) Error: 18446744073709551615 can't be converted to int16
|
||||||
|
tcompiletime_range_checks.nim(52, 21) Error: 18446744073709551615 can't be converted to int8
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
|
||||||
type
|
type
|
||||||
UnsignedRange = 0'u64 .. 100'u64
|
UnsignedRange* = range[0'u64 .. 100'u64]
|
||||||
SemiOutOfBounds = 0x7ffffffffffffe00'u64 .. 0x8000000000000100'u64
|
SemiOutOfBounds* = range[0x7ffffffffffffe00'u64 .. 0x8000000000000100'u64]
|
||||||
FullOutOfBounds = 0x8000000000000000'u64 .. 0x8000000000000200'u64
|
FullOutOfBounds* = range[0x8000000000000000'u64 .. 0x8000000000000200'u64]
|
||||||
|
|
||||||
FullNegativeRange = -200 .. -100
|
FullNegativeRange* = range[-200 .. -100]
|
||||||
HalfNegativeRange = -50 .. 50
|
HalfNegativeRange* = range[-50 .. 50]
|
||||||
FullPositiveRange = 100 .. 200
|
FullPositiveRange* = range[100 .. 200]
|
||||||
|
|
||||||
reject(int32(0x80000000'i64))
|
let acceptA* = int32(0x7fffffff'i64)
|
||||||
accept(int32(0x7fffffff'i64))
|
let acceptB* = (uint64(0'i64))
|
||||||
|
let acceptD* = (HalfNegativeRange(25'u64))
|
||||||
|
let acceptE* = (UnsignedRange(50'u64))
|
||||||
|
let acceptF* = (SemiOutOfBounds(0x7ffffffffffffe00'i64))
|
||||||
|
let acceptH* = (SemiOutOfBounds(0x8000000000000000'u64))
|
||||||
|
|
||||||
reject(uint64(-1'i64))
|
let rejectA* = int32(0x80000000'i64)
|
||||||
accept(uint64(0'i64))
|
let rejectB* = (uint64(-1'i64))
|
||||||
|
let rejectC* = (FullNegativeRange(0xff'u32))
|
||||||
|
let rejectD* = (HalfNegativeRange(0xffffffffffffffff'u64)) # internal `intVal` is `-1` which would be in range.
|
||||||
|
let rejectE* = (FullPositiveRange(300'u64))
|
||||||
|
let rejectF* = (UnsignedRange(101'u64))
|
||||||
|
let rejectG* = (SemiOutOfBounds(0x8000000000000000'i64)) #
|
||||||
|
|
||||||
reject(FullNegativeRange(0xff'u32))
|
let rejectH* = (int32(NaN))
|
||||||
reject(HalfNegativeRange(0xffffffffffffffff'u64)) # internal `intVal` is `-1` which would be in range.
|
let rejectI* = (int64(1e100))
|
||||||
accept(HalfNegativeRange(25'u64))
|
let rejectJ* = (uint64(1e100))
|
||||||
reject(FullPositiveRange(300'u64))
|
|
||||||
|
|
||||||
accept(UnsignedRange(50'u64))
|
|
||||||
reject(UnsignedRange(101'u64))
|
|
||||||
|
|
||||||
accept(SemiOutOfBounds(0x7ffffffffffffe00'i64))
|
|
||||||
reject(SemiOutOfBounds(0x8000000000000000'i64)) #
|
|
||||||
accept(SemiOutOfBounds(0x8000000000000000'u64)) # the last two literals have internally the same `intVal`.
|
|
||||||
|
|
||||||
reject(int32(NaN))
|
|
||||||
reject(int64(1e100))
|
|
||||||
reject(uint64(1e100))
|
|
||||||
|
|
||||||
# removed cross checks from tarithm.nim
|
# removed cross checks from tarithm.nim
|
||||||
reject(int64(0xFFFFFFFFFFFFFFFF'u64))
|
let rejectK* = (int64(0xFFFFFFFFFFFFFFFF'u64))
|
||||||
reject(int32(0xFFFFFFFFFFFFFFFF'u64))
|
let rejectL* = (int32(0xFFFFFFFFFFFFFFFF'u64))
|
||||||
reject(int16(0xFFFFFFFFFFFFFFFF'u64))
|
let rejectM* = (int16(0xFFFFFFFFFFFFFFFF'u64))
|
||||||
reject( int8(0xFFFFFFFFFFFFFFFF'u64))
|
let rejectN* = (int8(0xFFFFFFFFFFFFFFFF'u64))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue