mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixed problem with var...probably a conversion problem for fixed in size capabilities
adding fixed type tests Removing bitshift and regrouping fixed type tests together
This commit is contained in:
parent
dff1a26f55
commit
91fda50922
@ -469,7 +469,7 @@ bool ConstantNumberType::isValidLiteral(Literal const& _literal)
|
||||
{
|
||||
//problem here. If the first digit is a 0 in the string, it won't
|
||||
//turn it into a integer...Using find if not to count the leading 0s.
|
||||
|
||||
|
||||
auto leadingZeroes = find_if_not(
|
||||
radixPoint + 1,
|
||||
_literal.value().end(),
|
||||
|
@ -153,9 +153,9 @@ tuple<Token::Value, unsigned int, unsigned int> Token::fromIdentifierOrKeyword(s
|
||||
positionM < positionX &&
|
||||
positionX < _literal.end() &&
|
||||
*positionX == 'x' &&
|
||||
all_of(positionX++, _literal.end(), ::isdigit)
|
||||
all_of(++positionX, _literal.end(), ::isdigit)
|
||||
) {
|
||||
int n = parseSize(positionX + 1, _literal.end());
|
||||
int n = parseSize(positionX, _literal.end());
|
||||
if (
|
||||
0 <= m && m <= 256 &&
|
||||
0 <= n && n <= 256 &&
|
||||
|
@ -3222,7 +3222,6 @@ BOOST_AUTO_TEST_CASE(library_functions_do_not_have_value)
|
||||
BOOST_CHECK(!success(text));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_fixed_types_0x7_mxn)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -3544,9 +3543,41 @@ BOOST_AUTO_TEST_CASE(rational_bitand_binary_operation)
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
BOOST_CHECK(success(text));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(invalid_non_mod_8_fixed_types)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function f(){
|
||||
fixed8x10 a = 12345678.1234567890;
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
BOOST_CHECK(!success(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(valid_fixed_types)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function f(){
|
||||
fixed8x8 a = 87654321.12345678;
|
||||
fixed16x16 b = a**2;
|
||||
fixed24x24 c = b**(1.5);
|
||||
fixed32x32 d = b**2;
|
||||
fixed40x40 e = a**5;
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
BOOST_CHECK(success(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(fixed_type_int_conversion)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -3620,6 +3651,19 @@ BOOST_AUTO_TEST_CASE(fixed_type_literal_seconds_and_wei)
|
||||
BOOST_CHECK(!success(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(uint_array_declaration_with_fixed_type)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function f() {
|
||||
uint[fixed(3.56)] a;
|
||||
}
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(!success(text));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(array_declaration_with_fixed_literal)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -3645,18 +3689,41 @@ BOOST_AUTO_TEST_CASE(mapping_with_fixed_literal)
|
||||
BOOST_CHECK(success(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(inline_array_fixed_type)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function f() {
|
||||
fixed[3] memory a = [fixed(3.5), fixed(4.1234), fixed(967.32)];
|
||||
}
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(success(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(inline_array_fixed_literals)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function f() {
|
||||
fixed[3] memory a = [3.5, 4.1234, 967.32];
|
||||
fixed[3] memory a = [3.5, 4.1234, 967.32];
|
||||
}
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(success(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(zero_and_eight_variants_fixed)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract A {
|
||||
fixed8x0 someInt = 4;
|
||||
fixed0x8 half = 0.5;
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK(success(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(size_capabilities_of_fixed_point_types)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -3685,6 +3752,7 @@ BOOST_AUTO_TEST_CASE(var_capable_of_holding_fixed_constants)
|
||||
BOOST_CHECK(success(text));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user