fixes operator precedence issue with nim 19.6
This commit is contained in:
parent
5b9e73e488
commit
c456190980
|
@ -13,31 +13,31 @@ template chkLT(chk: untyped, a, b: string, bits: int) =
|
|||
chk fromHex(Stint[bits], a) < fromHex(Stint[bits], b)
|
||||
|
||||
template chknotLT(chk: untyped, a, b: string, bits: int) =
|
||||
chk not(fromHex(Stint[bits], b) < fromHex(Stint[bits], a))
|
||||
chk (not(fromHex(Stint[bits], b) < fromHex(Stint[bits], a)))
|
||||
|
||||
template chkLTE(chk: untyped, a, b: string, bits: int) =
|
||||
chk fromHex(Stint[bits], a) <= fromHex(Stint[bits], b)
|
||||
|
||||
template chknotLTE(chk: untyped, a, b: string, bits: int) =
|
||||
chk not(fromHex(Stint[bits], b) <= fromHex(Stint[bits], a))
|
||||
chk (not(fromHex(Stint[bits], b) <= fromHex(Stint[bits], a)))
|
||||
|
||||
template chkEQ(chk: untyped, a, b: string, bits: int) =
|
||||
chk fromHex(Stint[bits], a) == fromHex(Stint[bits], b)
|
||||
|
||||
template chknotEQ(chk: untyped, a, b: string, bits: int) =
|
||||
chk not(fromHex(Stint[bits], a) == fromHex(Stint[bits], b))
|
||||
chk (not(fromHex(Stint[bits], a) == fromHex(Stint[bits], b)))
|
||||
|
||||
template chkisZero(chk: untyped, a: string, bits: int) =
|
||||
chk fromHex(Stint[bits], a).isZero()
|
||||
|
||||
template chknotisZero(chk: untyped, a: string, bits: int) =
|
||||
chk not fromHex(Stint[bits], a).isZero()
|
||||
chk (not fromHex(Stint[bits], a).isZero())
|
||||
|
||||
template chkisNegative(chk: untyped, a: string, bits: int) =
|
||||
chk fromHex(Stint[bits], a).isNegative()
|
||||
|
||||
template chknotisNegative(chk: untyped, a: string, bits: int) =
|
||||
chk not fromHex(Stint[bits], a).isNegative()
|
||||
chk (not fromHex(Stint[bits], a).isNegative())
|
||||
|
||||
template chkisOdd(chk: untyped, a: string, bits: int) =
|
||||
chk fromHex(Stint[bits], a).isOdd()
|
||||
|
@ -49,7 +49,7 @@ template chkisEven(chk: untyped, a: string, bits: int) =
|
|||
chk fromHex(Stint[bits], a).isEven()
|
||||
|
||||
template chknotisEven(chk: untyped, a: string, bits: int) =
|
||||
chk not fromHex(Stint[bits], a).isEven()
|
||||
chk (not fromHex(Stint[bits], a).isEven())
|
||||
|
||||
template ctTest(name: string, body: untyped) =
|
||||
body
|
||||
|
|
|
@ -13,25 +13,25 @@ template chkLT(chk: untyped, a, b: string, bits: int) =
|
|||
chk fromHex(Stuint[bits], a) < fromHex(Stuint[bits], b)
|
||||
|
||||
template chknotLT(chk: untyped, a, b: string, bits: int) =
|
||||
chk not(fromHex(Stuint[bits], b) < fromHex(Stuint[bits], a))
|
||||
chk (not(fromHex(Stuint[bits], b) < fromHex(Stuint[bits], a)))
|
||||
|
||||
template chkLTE(chk: untyped, a, b: string, bits: int) =
|
||||
chk fromHex(Stuint[bits], a) <= fromHex(Stuint[bits], b)
|
||||
|
||||
template chknotLTE(chk: untyped, a, b: string, bits: int) =
|
||||
chk not(fromHex(Stuint[bits], b) <= fromHex(Stuint[bits], a))
|
||||
chk (not(fromHex(Stuint[bits], b) <= fromHex(Stuint[bits], a)))
|
||||
|
||||
template chkEQ(chk: untyped, a, b: string, bits: int) =
|
||||
chk fromHex(Stuint[bits], a) == fromHex(Stuint[bits], b)
|
||||
|
||||
template chknotEQ(chk: untyped, a, b: string, bits: int) =
|
||||
chk not(fromHex(Stuint[bits], a) == fromHex(Stuint[bits], b))
|
||||
chk (not(fromHex(Stuint[bits], a) == fromHex(Stuint[bits], b)))
|
||||
|
||||
template chkisZero(chk: untyped, a: string, bits: int) =
|
||||
chk fromHex(Stuint[bits], a).isZero()
|
||||
|
||||
template chknotisZero(chk: untyped, a: string, bits: int) =
|
||||
chk not fromHex(Stuint[bits], a).isZero()
|
||||
chk (not fromHex(Stuint[bits], a).isZero())
|
||||
|
||||
template chkisOdd(chk: untyped, a: string, bits: int) =
|
||||
chk fromHex(Stuint[bits], a).isOdd()
|
||||
|
@ -43,7 +43,7 @@ template chkisEven(chk: untyped, a: string, bits: int) =
|
|||
chk fromHex(Stuint[bits], a).isEven()
|
||||
|
||||
template chknotisEven(chk: untyped, a: string, bits: int) =
|
||||
chk not fromHex(Stuint[bits], a).isEven()
|
||||
chk (not fromHex(Stuint[bits], a).isEven())
|
||||
|
||||
template ctTest(name: string, body: untyped) =
|
||||
body
|
||||
|
|
|
@ -9,6 +9,32 @@
|
|||
|
||||
import ../stint, unittest
|
||||
|
||||
template chkMul(chk: untyped, a, b, c: string, bits: int) =
|
||||
chk (fromHex(Stuint[bits], a) * fromHex(Stuint[bits], b)) == fromHex(Stuint[bits], c)
|
||||
|
||||
template chkDiv(chk: untyped, a, b, c: string, bits: int) =
|
||||
chk (fromHex(Stuint[bits], a) div fromHex(Stuint[bits], b)) == fromHex(Stuint[bits], c)
|
||||
|
||||
template chkMod(chk: untyped, a, b, c: string, bits: int) =
|
||||
chk (fromHex(Stuint[bits], a) mod fromHex(Stuint[bits], b)) == fromHex(Stuint[bits], c)
|
||||
|
||||
template chkDivMod(chk: untyped, a, b, c, d: string, bits: int) =
|
||||
chk (fromHex(Stuint[bits], a) divmod fromHex(Stuint[bits], b)) == (fromHex(Stuint[bits], c), fromHex(Stuint[bits], d))
|
||||
|
||||
template testMuldiv(chk, tst: untyped) =
|
||||
tst "operator `mul`":
|
||||
chkMul(chk, "0", "3", "0", 8)
|
||||
|
||||
#tst "operator `div`":
|
||||
#tst "operator `mod`":
|
||||
#tst "operator `divmod`":
|
||||
|
||||
static:
|
||||
testMuldiv(doAssert, ctTest)
|
||||
|
||||
suite "Wider unsigned int muldiv coverage":
|
||||
testMuldiv(check, test)
|
||||
|
||||
suite "Testing unsigned int multiplication implementation":
|
||||
test "Multiplication with result fitting in low half":
|
||||
|
||||
|
|
Loading…
Reference in New Issue