diff options
author | chriseth <c@ethdev.com> | 2017-03-07 20:43:51 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-03-07 20:43:51 +0800 |
commit | 774cdb1135dfe3f0ed8646c72326874c63bce645 (patch) | |
tree | b3aba99a90b32e5d95cacf705b53c1ea648041cc | |
parent | 573b885337aca75a025c08eea80bb109041e669e (diff) | |
download | dexon-solidity-774cdb1135dfe3f0ed8646c72326874c63bce645.tar.gz dexon-solidity-774cdb1135dfe3f0ed8646c72326874c63bce645.tar.zst dexon-solidity-774cdb1135dfe3f0ed8646c72326874c63bce645.zip |
Tests for warning about literal constant base in exponentition.
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 3b137572..424274c1 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1658,6 +1658,36 @@ BOOST_AUTO_TEST_CASE(exp_operator_exponent_too_big) CHECK_ERROR(sourceCode, TypeError, ""); } +BOOST_AUTO_TEST_CASE(exp_warn_literal_base) +{ + char const* sourceCode = R"( + contract test { + function f() returns(uint d) { + uint8 x = 100; + return 10**x; + } + } + )"; + CHECK_WARNING(sourceCode, "might overflow"); + sourceCode = R"( + contract test { + function f() returns(uint d) { + uint8 x = 100; + return uint8(10)**x; + } + } + )"; + CHECK_SUCCESS(sourceCode); + sourceCode = R"( + contract test { + function f() returns(uint d) { + return 2**80; + } + } + )"; + CHECK_SUCCESS(sourceCode); +} + BOOST_AUTO_TEST_CASE(enum_member_access) { char const* text = R"( |