-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tests for signed comparisons, mod, div and sign extension #1768
base: arith-dev
Are you sure you want to change the base?
Added tests for signed comparisons, mod, div and sign extension #1768
Conversation
|
for (OpCode opCode : List.of(OpCode.SLT, OpCode.SGT, OpCode.SMOD, OpCode.SDIV)) { | ||
for (String a : VALUES) { | ||
for (String b : VALUES) { | ||
arguments.add(Arguments.of(opCode, a, b)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the signed case we should test more signed cases, we should explore more large or negative integers, e.g. by having as a set from which to choose
MIN_NEG = 0x80 00 .. 00
NEG_ONE = 0xff ff .. ff
ZERO = 0x00 00 .. 00
ONE = 0x00 00 .. 01
MAX_POS = 0x7f ff .. ff
RAN_POS_k // k = 1..10, ten or so BigIntegers, all positive, constructed from as many random 32 byte strings, by AND'ing with MAX_POS
RAN_NEG_k // k = 1..10, ten or so BigIntegers, all negative, constructed from as many random 32 byte strings, by OR'ing with MIN_NEG
And test all combinations of these.
arguments.add(Arguments.of(b, b.length() / 2 - 1)); | ||
// In this other case we assume there is always 00 as a prefix | ||
if (nTrailingBytes != 31) { | ||
arguments.add(Arguments.of(b, b.length() / 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good source of inputs would be e.g.
pos = 0, 1, 2, ..., 31, 32, 0xff,
256^16 - 1, 256^16, 256^16 + 1,
256^32 - 1
And
value = 0x 11 11 .. 11 [B] ff ff .. ff
Where [B]
is a byte from among e.g. { 0x00, 0x56, 0x7f, 0x80, 0xc2, 0xff }
and occupies the position i
-th byte, i = 0, 1, 2, ..., 31
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which would amount to 38 * 6 * 32 = 7 296
test cases, which is ok and which we will run on a weekly basis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lorenzogentile404 SIGNEXTEND
takes two arguments, one being the integer you want to sign extend, one being the position of the byte containing the sign bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More test vectors would make sense. We want to be exhaustive as much as possible like in the EXP
case.
…d source to be non-static
No description provided.