Adds support for hex literals in soltest.

This commit is contained in:
Erik Kundt
2019-02-21 17:04:40 +01:00
parent 98012135c6
commit d40928f5fc
7 changed files with 161 additions and 16 deletions
@@ -305,6 +305,38 @@ BOOST_AUTO_TEST_CASE(call_arguments_tuple)
testFunctionCall(calls.at(1), Mode::SingleLine, "f((uint8),uint8)", false);
}
BOOST_AUTO_TEST_CASE(call_arguments_left_aligned)
{
char const* source = R"(
// f(bytes32, bytes32): 0x6161, 0x420000EF -> 1
// g(bytes32, bytes32): 0x0616, 0x0042EF00 -> 1
)";
auto const calls = parse(source);
BOOST_REQUIRE_EQUAL(calls.size(), 2);
testFunctionCall(
calls.at(0),
Mode::SingleLine,
"f(bytes32,bytes32)",
false,
fmt::encodeArgs(
u256("0x6161000000000000000000000000000000000000000000000000000000000000"),
u256("0x420000EF00000000000000000000000000000000000000000000000000000000")
),
fmt::encodeArgs(1)
);
testFunctionCall(
calls.at(1),
Mode::SingleLine,
"g(bytes32,bytes32)",
false,
fmt::encodeArgs(
u256("0x0616000000000000000000000000000000000000000000000000000000000000"),
u256("0x0042EF0000000000000000000000000000000000000000000000000000000000")
),
fmt::encodeArgs(1)
);
}
BOOST_AUTO_TEST_CASE(call_arguments_tuple_of_tuples)
{
char const* source = R"(
@@ -546,6 +578,14 @@ BOOST_AUTO_TEST_CASE(call_ether_type_invalid)
BOOST_REQUIRE_THROW(parse(source), langutil::Error);
}
BOOST_AUTO_TEST_CASE(call_hex_number_invalid)
{
char const* source = R"(
// f(bytes32, bytes32): 0x616, 0x042 -> 1
)";
BOOST_REQUIRE_THROW(parse(source), langutil::Error);
}
BOOST_AUTO_TEST_CASE(call_arguments_colon)
{
char const* source = R"(