tidying up tests
This commit is contained in:
parent
8c1e43f001
commit
025428d0ae
|
@ -131,12 +131,6 @@ static:
|
||||||
suite "Wider signed int bitwise coverage":
|
suite "Wider signed int bitwise coverage":
|
||||||
testBitwise(check, test)
|
testBitwise(check, test)
|
||||||
|
|
||||||
when defined(cpp):
|
|
||||||
import quicktest, ttmath_compat
|
|
||||||
|
|
||||||
func high(T: typedesc[SomeUnsignedInt]): T =
|
|
||||||
not T(0)
|
|
||||||
|
|
||||||
suite "Testing signed int bitwise operations":
|
suite "Testing signed int bitwise operations":
|
||||||
test "Shift Left":
|
test "Shift Left":
|
||||||
var y = 1.u256
|
var y = 1.u256
|
||||||
|
@ -180,6 +174,14 @@ suite "Testing signed int bitwise operations":
|
||||||
check c != cast[stint.Int256](b)
|
check c != cast[stint.Int256](b)
|
||||||
check c == a
|
check c == a
|
||||||
|
|
||||||
|
#[
|
||||||
|
|
||||||
|
when defined(cpp):
|
||||||
|
import quicktest, ttmath_compat
|
||||||
|
|
||||||
|
func high(T: typedesc[SomeUnsignedInt]): T =
|
||||||
|
not T(0)
|
||||||
|
|
||||||
when defined(cpp):
|
when defined(cpp):
|
||||||
const
|
const
|
||||||
hi = high(int64)
|
hi = high(int64)
|
||||||
|
@ -221,3 +223,4 @@ suite "Testing signed int bitwise operations":
|
||||||
mp_z = mp_x shr y
|
mp_z = mp_x shr y
|
||||||
|
|
||||||
check ttm_z.asSt == mp_z
|
check ttm_z.asSt == mp_z
|
||||||
|
]#
|
||||||
|
|
|
@ -248,21 +248,21 @@ template testComparison(chk, tst: untyped) =
|
||||||
chkNotIsOdd(chk, "FFFFFFFFFFFFFFFFFA", 256)
|
chkNotIsOdd(chk, "FFFFFFFFFFFFFFFFFA", 256)
|
||||||
|
|
||||||
tst "operator `isEven`":
|
tst "operator `isEven`":
|
||||||
chkNotIsOdd(chk, "0", 128)
|
chkIsEven(chk, "0", 128)
|
||||||
chkNotIsOdd(chk, "0", 256)
|
chkIsEven(chk, "0", 256)
|
||||||
|
|
||||||
chkNotIsOdd(chk, "4", 128)
|
chkIsEven(chk, "4", 128)
|
||||||
chkNotIsOdd(chk, "4", 256)
|
chkIsEven(chk, "4", 256)
|
||||||
|
|
||||||
chkNotIsOdd(chk, "FFFFFFFFFFFFFFA", 128)
|
chkIsEven(chk, "FFFFFFFFFFFFFFA", 128)
|
||||||
chkNotIsOdd(chk, "FFFFFFFFFFFFFFFFFA", 256)
|
chkIsEven(chk, "FFFFFFFFFFFFFFFFFA", 256)
|
||||||
|
|
||||||
tst "operator not `isEven`":
|
tst "operator not `isEven`":
|
||||||
chkIsOdd(chk, "1", 128)
|
chkNotIsEven(chk, "1", 128)
|
||||||
chkIsOdd(chk, "1", 256)
|
chkNotIsEven(chk, "1", 256)
|
||||||
|
|
||||||
chkIsOdd(chk, "FFFFFFFFFFFFFFF", 128)
|
chkNotIsEven(chk, "FFFFFFFFFFFFFFF", 128)
|
||||||
chkIsOdd(chk, "FFFFFFFFFFFFFFFFFF", 256)
|
chkNotIsEven(chk, "FFFFFFFFFFFFFFFFFF", 256)
|
||||||
|
|
||||||
tst "isOne":
|
tst "isOne":
|
||||||
let x = 1.i128
|
let x = 1.i128
|
||||||
|
|
|
@ -939,6 +939,7 @@ proc main() =
|
||||||
|
|
||||||
let z = "115792089237316195423570985008687907853269984665640564039457584007913129639935".u256
|
let z = "115792089237316195423570985008687907853269984665640564039457584007913129639935".u256
|
||||||
let kk = z.truncate(int)
|
let kk = z.truncate(int)
|
||||||
|
check kk == 9223372036854775807
|
||||||
|
|
||||||
test "Parsing an unexpected 0x prefix for a decimal string is a CatchableError and not a defect":
|
test "Parsing an unexpected 0x prefix for a decimal string is a CatchableError and not a defect":
|
||||||
let s = "0x123456"
|
let s = "0x123456"
|
||||||
|
|
|
@ -60,7 +60,7 @@ template testdivmod(chk, tst: untyped) =
|
||||||
chkDivMod(chk, "FFFFFFFFFFFFFFFF", "27", "690690690690690", "F", 128)
|
chkDivMod(chk, "FFFFFFFFFFFFFFFF", "27", "690690690690690", "F", 128)
|
||||||
chkDivMod(chk, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "27", "6906906906906906906906906906906", "15", 128)
|
chkDivMod(chk, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "27", "6906906906906906906906906906906", "15", 128)
|
||||||
|
|
||||||
#[static:
|
static:
|
||||||
testdivmod(ctCheck, ctTest)
|
testdivmod(ctCheck, ctTest)
|
||||||
|
|
||||||
suite "Wider unsigned int muldiv coverage":
|
suite "Wider unsigned int muldiv coverage":
|
||||||
|
@ -101,7 +101,6 @@ suite "Testing unsigned int division and modulo implementation":
|
||||||
check:
|
check:
|
||||||
q == 123456789123456789'u64.u256
|
q == 123456789123456789'u64.u256
|
||||||
r == 0'u64.u256
|
r == 0'u64.u256
|
||||||
]#
|
|
||||||
|
|
||||||
suite "Testing specific failures highlighted by property-based testing":
|
suite "Testing specific failures highlighted by property-based testing":
|
||||||
test "Modulo: 65696211516342324 mod 174261910798982":
|
test "Modulo: 65696211516342324 mod 174261910798982":
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#
|
#
|
||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
import ../stint, unittest, math, test_helpers
|
import ../stint, unittest, test_helpers
|
||||||
|
|
||||||
template chkAddMod(chk: untyped, a, b, m, c: string, bits: int) =
|
template chkAddMod(chk: untyped, a, b, m, c: string, bits: int) =
|
||||||
chk addmod(fromHex(StUint[bits], a), fromHex(StUint[bits], b), fromHex(StUint[bits], m)) == fromHex(StUint[bits], c)
|
chk addmod(fromHex(StUint[bits], a), fromHex(StUint[bits], b), fromHex(StUint[bits], m)) == fromHex(StUint[bits], c)
|
||||||
|
|
Loading…
Reference in New Issue