Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Aug 24, 2024
1 parent d460d14 commit 6262fa7
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 147 deletions.
3 changes: 1 addition & 2 deletions src/generated/RainterpreterNPE2.pointers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ bytes32 constant BYTECODE_HASH = bytes32(0xb2bb360cac3a5504625d94621550913d5024d
/// By setting these as a constant they can be inlined into the interpreter
/// and loaded at eval time for very low gas (~100) due to the compiler
/// optimising it to a single `codecopy` to build the in memory bytes array.
bytes constant OPCODE_FUNCTION_POINTERS =
hex"06b407040746091209f90a0b0a1d0a360a780aca0adb0aec0b8e0bcb0c7a0cfe0d4d0e43";
bytes constant OPCODE_FUNCTION_POINTERS = hex"06b407040746091209f90a0b0a1d0a360a780aca0adb0aec0b8e0bcb0c7a0cfe0d4d0e43";
6 changes: 3 additions & 3 deletions src/generated/RainterpreterParserNPE2.pointers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
pragma solidity =0.8.25;

/// @dev Hash of the known bytecode.
bytes32 constant BYTECODE_HASH = bytes32(0x943577dab2a943ee58c82e161256096c3025f5cf14afee602f91a18a8d0dfdcc);
bytes32 constant BYTECODE_HASH = bytes32(0xb00c8b5442942a92966bd7df002d68fe65735ff9714ff472fc9049d1c1fdc0a8);

/// @dev The parse meta that is used to lookup word definitions.
/// The structure of the parse meta is:
Expand Down Expand Up @@ -38,11 +38,11 @@ uint8 constant PARSE_META_BUILD_DEPTH = 2;
/// These positional indexes all map to the same indexes looked up in the parse
/// meta.
bytes constant OPERAND_HANDLER_FUNCTION_POINTERS =
hex"13ef13ef13ef14b415ab15ab15ab14b414b413ef13ef13ef15ab15ab15ab15ab15ab15ab";
hex"1450145014501515160c160c160c15151515145014501450160c160c160c160c160c160c";

/// @dev Every two bytes is a function pointer for a literal parser.
/// Literal dispatches are determined by the first byte(s) of the literal
/// rather than a full word lookup, and are done with simple conditional
/// jumps as the possibilities are limited compared to the number of words we
/// have.
bytes constant LITERAL_PARSER_FUNCTION_POINTERS = hex"0dab1073112411fe";
bytes constant LITERAL_PARSER_FUNCTION_POINTERS = hex"0dab10731185125f";
18 changes: 14 additions & 4 deletions src/lib/parse/literal/LibParseLiteralDecimal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,22 @@ library LibParseLiteralDecimal {
int256 signedCoefficient;
int256 exponent;
(cursor, signedCoefficient, exponent) = parseDecimalFloat(state, start, end);
(int256 normalizedSignedCoefficient, int256 normalizedExponent) =
LibDecimalFloatImplementation.normalize(signedCoefficient, exponent);
if (!LibDecimalFloat.eq(normalizedSignedCoefficient, normalizedExponent, signedCoefficient, exponent)) {

// Prenormalize signed coefficients that are smaller than their
// normalized form at parse time, as this can save runtime gas that would
// be needed to normalize the value at runtime.
// We only do normalization that will scale up, to avoid causing
// unneccessary precision loss.
if (-1e37 < signedCoefficient && signedCoefficient < 1e37) {
(signedCoefficient, exponent) = LibDecimalFloatImplementation.normalize(signedCoefficient, exponent);
}

packedFloat = LibDecimalFloat.pack(signedCoefficient, exponent);

(int256 unpackedSignedCoefficient, int256 unpackedExponent) = LibDecimalFloat.unpack(packedFloat);
if (unpackedSignedCoefficient != signedCoefficient || unpackedExponent != exponent) {
revert DecimalLiteralPrecisionLoss(state.parseErrorOffset(start));
}
packedFloat = LibDecimalFloat.pack(normalizedSignedCoefficient, normalizedExponent);
}

function parseDecimalFloat(ParseState memory state, uint256 start, uint256 end)
Expand Down
32 changes: 16 additions & 16 deletions test/src/lib/op/bitwise/LibOpBitwiseAndNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ contract LibOpBitwiseAndNPTest is OpTest {

/// Test the eval of bitwise AND parsed from a string.
function testOpBitwiseAndNPEvalHappy() external view {
checkHappy("_: bitwise-and(0 0);", 0, "0 0");
checkHappy("_: bitwise-and(0 1e-18);", 0, "0 1");
checkHappy("_: bitwise-and(1e-18 0);", 0, "1 0");
checkHappy("_: bitwise-and(1e-18 1e-18);", 1, "1 1");
checkHappy("_: bitwise-and(0 2e-18);", 0, "0 2");
checkHappy("_: bitwise-and(2e-18 0);", 0, "2 0");
checkHappy("_: bitwise-and(1e-18 2e-18);", 0, "1 2");
checkHappy("_: bitwise-and(2e-18 1e-18);", 0, "2 1");
checkHappy("_: bitwise-and(2e-18 2e-18);", 2, "2 2");
checkHappy("_: bitwise-and(0 3e-18);", 0, "0 3");
checkHappy("_: bitwise-and(3e-18 0);", 0, "3 0");
checkHappy("_: bitwise-and(1e-18 3e-18);", 1, "1 3");
checkHappy("_: bitwise-and(3e-18 1e-18);", 1, "3 1");
checkHappy("_: bitwise-and(2e-18 3e-18);", 2, "2 3");
checkHappy("_: bitwise-and(3e-18 2e-18);", 2, "3 2");
checkHappy("_: bitwise-and(3e-18 3e-18);", 3, "3 3");
checkHappy("_: bitwise-and(0x00 0x00);", 0, "0 0");
checkHappy("_: bitwise-and(0x00 0x01);", 0, "0 1");
checkHappy("_: bitwise-and(0x01 0x00);", 0, "1 0");
checkHappy("_: bitwise-and(0x01 0x01);", 1, "1 1");
checkHappy("_: bitwise-and(0x00 0x02);", 0, "0 2");
checkHappy("_: bitwise-and(0x02 0x00);", 0, "2 0");
checkHappy("_: bitwise-and(0x01 0x02);", 0, "1 2");
checkHappy("_: bitwise-and(0x02 0x01);", 0, "2 1");
checkHappy("_: bitwise-and(0x02 0x02);", 2, "2 2");
checkHappy("_: bitwise-and(0x00 0x03);", 0, "0 3");
checkHappy("_: bitwise-and(0x03 0x00);", 0, "3 0");
checkHappy("_: bitwise-and(0x01 0x03);", 1, "1 3");
checkHappy("_: bitwise-and(0x03 0x01);", 1, "3 1");
checkHappy("_: bitwise-and(0x02 0x03);", 2, "2 3");
checkHappy("_: bitwise-and(0x03 0x02);", 2, "3 2");
checkHappy("_: bitwise-and(0x03 0x03);", 3, "3 3");
}

/// Test that a bitwise OR with bad inputs fails integrity.
Expand Down
32 changes: 16 additions & 16 deletions test/src/lib/op/bitwise/LibOpBitwiseOrNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ contract LibOpBitwiseOrNPTest is OpTest {

/// Test the eval of bitwise OR parsed from a string.
function testOpBitwiseORNPEval() external view {
checkHappy("_: bitwise-or(0 0);", 0, "0 0");
checkHappy("_: bitwise-or(0 1e-18);", 1, "0 1");
checkHappy("_: bitwise-or(1e-18 0);", 1, "1 0");
checkHappy("_: bitwise-or(1e-18 1e-18);", 1, "1 1");
checkHappy("_: bitwise-or(0 2e-18);", 2, "0 2");
checkHappy("_: bitwise-or(2e-18 0);", 2, "2 0");
checkHappy("_: bitwise-or(1e-18 2e-18);", 3, "1 2");
checkHappy("_: bitwise-or(2e-18 1e-18);", 3, "2 1");
checkHappy("_: bitwise-or(2e-18 2e-18);", 2, "2 2");
checkHappy("_: bitwise-or(0 3e-18);", 3, "0 3");
checkHappy("_: bitwise-or(3e-18 0);", 3, "3 0");
checkHappy("_: bitwise-or(1e-18 3e-18);", 3, "1 3");
checkHappy("_: bitwise-or(3e-18 1e-18);", 3, "3 1");
checkHappy("_: bitwise-or(2e-18 3e-18);", 3, "2 3");
checkHappy("_: bitwise-or(3e-18 2e-18);", 3, "3 2");
checkHappy("_: bitwise-or(3e-18 3e-18);", 3, "3 3");
checkHappy("_: bitwise-or(0x00 0x00);", 0, "0 0");
checkHappy("_: bitwise-or(0x00 0x01);", 1, "0 1");
checkHappy("_: bitwise-or(0x01 0x00);", 1, "1 0");
checkHappy("_: bitwise-or(0x01 0x01);", 1, "1 1");
checkHappy("_: bitwise-or(0x00 0x02);", 2, "0 2");
checkHappy("_: bitwise-or(0x02 0x00);", 2, "2 0");
checkHappy("_: bitwise-or(0x01 0x02);", 3, "1 2");
checkHappy("_: bitwise-or(0x02 0x01);", 3, "2 1");
checkHappy("_: bitwise-or(0x02 0x02);", 2, "2 2");
checkHappy("_: bitwise-or(0x00 0x03);", 3, "0 3");
checkHappy("_: bitwise-or(0x03 0x00);", 3, "3 0");
checkHappy("_: bitwise-or(0x01 0x03);", 3, "1 3");
checkHappy("_: bitwise-or(0x03 0x01);", 3, "3 1");
checkHappy("_: bitwise-or(0x02 0x03);", 3, "2 3");
checkHappy("_: bitwise-or(0x03 0x02);", 3, "3 2");
checkHappy("_: bitwise-or(0x03 0x03);", 3, "3 3");
}

/// Test that a bitwise OR with bad inputs fails integrity.
Expand Down
4 changes: 2 additions & 2 deletions test/src/lib/op/bitwise/LibOpCtPopNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ contract LibOpCtPopNPTest is OpTest {
/// Test the eval of a ct pop opcode parsed from a string.
function testOpCtPopNPEval(uint256 x) external view {
uint256[] memory stack = new uint256[](1);
stack[0] = LibCtPop.ctpop(x) * 1e18;
checkHappy(bytes(string.concat("_: bitwise-count-ones(", Strings.toString(x), "e-18);")), stack, "");
stack[0] = LibCtPop.ctpop(x);
checkHappy(bytes(string.concat("_: bitwise-count-ones(", Strings.toHexString(x), ");")), stack, "");
}

/// Test that a bitwise count with bad inputs fails integrity.
Expand Down
26 changes: 13 additions & 13 deletions test/src/lib/op/bitwise/LibOpDecodeBitsNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ contract LibOpDecodeBitsNPTest is OpTest {

/// Test the eval of decoding bits parsed from a string.
function testOpDecodeBitsNPEvalHappy() external view {
checkHappy("_:bitwise-decode<0 1>(0);", 0, "0 1 0");
checkHappy("_:bitwise-decode<0 1>(1e-18);", 1, "0 1 1");
checkHappy("_:bitwise-decode<0 1>(2e-18);", 0, "0 1 2");
checkHappy("_:bitwise-decode<0 1>(3e-18);", 1, "0 1 3");
checkHappy("_:bitwise-decode<0 1>(4e-18);", 0, "0 1 4");
checkHappy("_:bitwise-decode<0 1>(5e-18);", 1, "0 1 5");
checkHappy("_:bitwise-decode<0 1>(6e-18);", 0, "0 1 6");
checkHappy("_:bitwise-decode<0 1>(7e-18);", 1, "0 1 7");
checkHappy("_:bitwise-decode<0 2>(0);", 0, "0 2 0");
checkHappy("_:bitwise-decode<0 2>(1e-18);", 1, "0 2 1");
checkHappy("_:bitwise-decode<0 2>(2e-18);", 2, "0 2 2");
checkHappy("_:bitwise-decode<0 2>(3e-18);", 3, "0 2 3");
checkHappy("_:bitwise-decode<0 2>(4e-18);", 0, "0 2 4");
checkHappy("_:bitwise-decode<0 1>(0x00);", 0, "0 1 0");
checkHappy("_:bitwise-decode<0 1>(0x01);", 1, "0 1 1");
checkHappy("_:bitwise-decode<0 1>(0x02);", 0, "0 1 2");
checkHappy("_:bitwise-decode<0 1>(0x03);", 1, "0 1 3");
checkHappy("_:bitwise-decode<0 1>(0x04);", 0, "0 1 4");
checkHappy("_:bitwise-decode<0 1>(0x05);", 1, "0 1 5");
checkHappy("_:bitwise-decode<0 1>(0x06);", 0, "0 1 6");
checkHappy("_:bitwise-decode<0 1>(0x07);", 1, "0 1 7");
checkHappy("_:bitwise-decode<0 2>(0x00);", 0, "0 2 0");
checkHappy("_:bitwise-decode<0 2>(0x01);", 1, "0 2 1");
checkHappy("_:bitwise-decode<0 2>(0x02);", 2, "0 2 2");
checkHappy("_:bitwise-decode<0 2>(0x03);", 3, "0 2 3");
checkHappy("_:bitwise-decode<0 2>(0x04);", 0, "0 2 4");
checkHappy("_:bitwise-decode<0 2>(uint256-max-value());", 3, "0 2 uint256-max-value");
checkHappy("_:bitwise-decode<0 0xFF>(uint256-max-value());", type(uint256).max >> 1, "0 0xFF uint256-max-value");
checkHappy("_:bitwise-decode<0xFF 1>(uint256-max-value());", 1, "0xFF 1 uint256-max-value");
Expand Down
30 changes: 15 additions & 15 deletions test/src/lib/op/bitwise/LibOpEncodeBitsNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,21 @@ contract LibOpEncodeBitsNPTest is OpTest {

/// Test the eval of encoding bits parsed from a string.
function testOpEncodeBitsNPEvalHappy() external view {
checkHappy("_:bitwise-encode<0 1>(0 0);", 0, "0 0");
checkHappy("_:bitwise-encode<0 1>(0 1e-18);", 0, "0 1");
checkHappy("_:bitwise-encode<0 1>(1e-18 0);", 1, "1 0");
checkHappy("_:bitwise-encode<0 1>(1e-18 1e-18);", 1, "1 1");
checkHappy("_:bitwise-encode<0 1>(0 2e-18);", 2, "0 2");
checkHappy("_:bitwise-encode<0 1>(1e-18 2e-18);", 3, "1 2");
checkHappy("_:bitwise-encode<0 1>(uint256-max-value() 0);", 1, "uint256-max-value 0");
checkHappy("_:bitwise-encode<0 1>(uint256-max-value() 1e-18);", 1, "uint256-max-value 1");
checkHappy("_:bitwise-encode<0 1>(uint256-max-value() 2e-18);", 3, "uint256-max-value 2");
checkHappy("_:bitwise-encode<0 1>(uint256-max-value() 3e-18);", 3, "uint256-max-value 3");
checkHappy("_:bitwise-encode<0 2>(uint256-max-value() 0);", 3, "uint256-max-value 0 0 2");
checkHappy("_:bitwise-encode<1 1>(uint256-max-value() 0);", 2, "uint256-max-value 1 1 1");
checkHappy("_:bitwise-encode<1 1>(uint256-max-value() 1e-18);", 3, "uint256-max-value 1 1 1");
checkHappy("_:bitwise-encode<1 1>(uint256-max-value() 2e-18);", 2, "uint256-max-value 2 1 1");
checkHappy("_:bitwise-encode<0xFF 1>(uint256-max-value() 0);", 1 << 255, "uint256-max-value 2 0xFF 1");
checkHappy("_:bitwise-encode<0 1>(0x00 0x00);", 0, "0 0");
checkHappy("_:bitwise-encode<0 1>(0x00 0x01);", 0, "0 1");
checkHappy("_:bitwise-encode<0 1>(0x01 0x00);", 1, "1 0");
checkHappy("_:bitwise-encode<0 1>(0x01 0x01);", 1, "1 1");
checkHappy("_:bitwise-encode<0 1>(0x00 0x02);", 2, "0 2");
checkHappy("_:bitwise-encode<0 1>(0x01 0x02);", 3, "1 2");
checkHappy("_:bitwise-encode<0 1>(uint256-max-value() 0x00);", 1, "uint256-max-value 0");
checkHappy("_:bitwise-encode<0 1>(uint256-max-value() 0x01);", 1, "uint256-max-value 1");
checkHappy("_:bitwise-encode<0 1>(uint256-max-value() 0x02);", 3, "uint256-max-value 2");
checkHappy("_:bitwise-encode<0 1>(uint256-max-value() 0x03);", 3, "uint256-max-value 3");
checkHappy("_:bitwise-encode<0 2>(uint256-max-value() 0x00);", 3, "uint256-max-value 0 0 2");
checkHappy("_:bitwise-encode<1 1>(uint256-max-value() 0x00);", 2, "uint256-max-value 1 1 1");
checkHappy("_:bitwise-encode<1 1>(uint256-max-value() 0x01);", 3, "uint256-max-value 1 1 1");
checkHappy("_:bitwise-encode<1 1>(uint256-max-value() 0x02);", 2, "uint256-max-value 2 1 1");
checkHappy("_:bitwise-encode<0xFF 1>(uint256-max-value() 0x00);", 1 << 255, "uint256-max-value 2 0xFF 1");
checkHappy(
"_:bitwise-encode<0 0xFF>(uint256-max-value() 0);", type(uint256).max >> 1, "uint256-max-value 2 0xFF 1"
);
Expand Down
32 changes: 16 additions & 16 deletions test/src/lib/op/bitwise/LibOpShiftBitsLeftNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,28 @@ contract LibOpShiftBitsLeftNPTest is OpTest {

/// Test the eval of a shift bits left opcode parsed from a string.
function testOpShiftBitsLeftNPEval() external view {
checkHappy("_: bitwise-shift-left<1>(0);", 0, "1, 0");
checkHappy("_: bitwise-shift-left<2>(0);", 0, "2, 0");
checkHappy("_: bitwise-shift-left<3>(0);", 0, "3, 0");
checkHappy("_: bitwise-shift-left<255>(0);", 0, "255, 0");
checkHappy("_: bitwise-shift-left<1>(0x00);", 0, "1, 0");
checkHappy("_: bitwise-shift-left<2>(0x00);", 0, "2, 0");
checkHappy("_: bitwise-shift-left<3>(0x00);", 0, "3, 0");
checkHappy("_: bitwise-shift-left<255>(0x00);", 0, "255, 0");

checkHappy("_: bitwise-shift-left<1>(1e-18);", 1 << 1, "1, 1");
checkHappy("_: bitwise-shift-left<2>(1e-18);", 1 << 2, "2, 1");
checkHappy("_: bitwise-shift-left<3>(1e-18);", 1 << 3, "3, 1");
checkHappy("_: bitwise-shift-left<255>(1e-18);", 1 << 255, "255, 1");
checkHappy("_: bitwise-shift-left<1>(0x01);", 1 << 1, "1, 1");
checkHappy("_: bitwise-shift-left<2>(0x01);", 1 << 2, "2, 1");
checkHappy("_: bitwise-shift-left<3>(0x01);", 1 << 3, "3, 1");
checkHappy("_: bitwise-shift-left<255>(0x01);", 1 << 255, "255, 1");

checkHappy("_: bitwise-shift-left<1>(2e-18);", 2 << 1, "1, 2");
checkHappy("_: bitwise-shift-left<2>(2e-18);", 2 << 2, "2, 2");
checkHappy("_: bitwise-shift-left<3>(2e-18);", 2 << 3, "3, 2");
checkHappy("_: bitwise-shift-left<1>(0x02);", 2 << 1, "1, 2");
checkHappy("_: bitwise-shift-left<2>(0x02);", 2 << 2, "2, 2");
checkHappy("_: bitwise-shift-left<3>(0x02);", 2 << 3, "3, 2");
// 2 gets shifted out of the 256 bit word, so this is 0.
checkHappy("_: bitwise-shift-left<255>(2e-18);", 0, "255, 2");
checkHappy("_: bitwise-shift-left<255>(0x02);", 0, "255, 2");

checkHappy("_: bitwise-shift-left<1>(3e-18);", 3 << 1, "1, 3");
checkHappy("_: bitwise-shift-left<2>(3e-18);", 3 << 2, "2, 3");
checkHappy("_: bitwise-shift-left<3>(3e-18);", 3 << 3, "3, 3");
checkHappy("_: bitwise-shift-left<1>(0x03);", 3 << 1, "1, 3");
checkHappy("_: bitwise-shift-left<2>(0x03);", 3 << 2, "2, 3");
checkHappy("_: bitwise-shift-left<3>(0x03);", 3 << 3, "3, 3");
// The high bit of 3 gets shifted out of the 256 bit word, so this is the
// same as shifting 1.
checkHappy("_: bitwise-shift-left<255>(3e-18);", 1 << 255, "255, 3");
checkHappy("_: bitwise-shift-left<255>(0x03);", 1 << 255, "255, 3");

checkHappy("_: bitwise-shift-left<1>(uint256-max-value());", type(uint256).max << 1, "1, max");
checkHappy("_: bitwise-shift-left<2>(uint256-max-value());", type(uint256).max << 2, "2, max");
Expand Down
48 changes: 24 additions & 24 deletions test/src/lib/op/bitwise/LibOpShiftBitsRightNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,30 @@ contract LibOpShiftBitsRightNPTest is OpTest {

/// Test the eval of a shift bits right opcode parsed from a string.
function testOpShiftBitsRightNPEval() external view {
checkHappy("_: bitwise-shift-right<1>(0);", 0, "1, 0");
checkHappy("_: bitwise-shift-right<2>(0);", 0, "2, 0");
checkHappy("_: bitwise-shift-right<3>(0);", 0, "3, 0");
checkHappy("_: bitwise-shift-right<255>(0);", 0, "255, 0");

checkHappy("_: bitwise-shift-right<1>(1e-18);", 0, "1, 1");
checkHappy("_: bitwise-shift-right<2>(1e-18);", 0, "2, 1");
checkHappy("_: bitwise-shift-right<3>(1e-18);", 0, "3, 1");
checkHappy("_: bitwise-shift-right<255>(1e-18);", 0, "255, 1");

checkHappy("_: bitwise-shift-right<1>(2e-18);", 1, "1, 2");
checkHappy("_: bitwise-shift-right<2>(2e-18);", 0, "2, 2");
checkHappy("_: bitwise-shift-right<3>(2e-18);", 0, "3, 2");
checkHappy("_: bitwise-shift-right<255>(2e-18);", 0, "255, 2");

checkHappy("_: bitwise-shift-right<1>(3e-18);", 1, "1, 3");
checkHappy("_: bitwise-shift-right<2>(3e-18);", 0, "2, 3");
checkHappy("_: bitwise-shift-right<3>(3e-18);", 0, "3, 3");
checkHappy("_: bitwise-shift-right<255>(3e-18);", 0, "255, 3");

checkHappy("_: bitwise-shift-right<1>(4e-18);", 2, "1, 4");
checkHappy("_: bitwise-shift-right<2>(4e-18);", 1, "2, 4");
checkHappy("_: bitwise-shift-right<3>(4e-18);", 0, "3, 4");
checkHappy("_: bitwise-shift-right<255>(4e-18);", 0, "255, 4");
checkHappy("_: bitwise-shift-right<1>(0x00);", 0, "1, 0");
checkHappy("_: bitwise-shift-right<2>(0x00);", 0, "2, 0");
checkHappy("_: bitwise-shift-right<3>(0x00);", 0, "3, 0");
checkHappy("_: bitwise-shift-right<255>(0x00);", 0, "255, 0");

checkHappy("_: bitwise-shift-right<1>(0x01);", 0, "1, 1");
checkHappy("_: bitwise-shift-right<2>(0x01);", 0, "2, 1");
checkHappy("_: bitwise-shift-right<3>(0x01);", 0, "3, 1");
checkHappy("_: bitwise-shift-right<255>(0x01);", 0, "255, 1");

checkHappy("_: bitwise-shift-right<1>(0x02);", 1, "1, 2");
checkHappy("_: bitwise-shift-right<2>(0x02);", 0, "2, 2");
checkHappy("_: bitwise-shift-right<3>(0x02);", 0, "3, 2");
checkHappy("_: bitwise-shift-right<255>(0x02);", 0, "255, 2");

checkHappy("_: bitwise-shift-right<1>(0x03);", 1, "1, 3");
checkHappy("_: bitwise-shift-right<2>(0x03);", 0, "2, 3");
checkHappy("_: bitwise-shift-right<3>(0x03);", 0, "3, 3");
checkHappy("_: bitwise-shift-right<255>(0x03);", 0, "255, 3");

checkHappy("_: bitwise-shift-right<1>(0x04);", 2, "1, 4");
checkHappy("_: bitwise-shift-right<2>(0x04);", 1, "2, 4");
checkHappy("_: bitwise-shift-right<3>(0x04);", 0, "3, 4");
checkHappy("_: bitwise-shift-right<255>(0x04);", 0, "255, 4");

checkHappy("_: bitwise-shift-right<1>(uint256-max-value());", type(uint256).max >> 1, "1, max");
checkHappy("_: bitwise-shift-right<2>(uint256-max-value());", type(uint256).max >> 2, "2, max");
Expand Down
Loading

0 comments on commit 6262fa7

Please sign in to comment.