diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2019-01-15 20:40:10 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2019-01-15 23:32:21 +0800 |
commit | 4c8f8e949143d0c680a8257adbcc768d908fae9a (patch) | |
tree | cbaea6e325d355e4050f084936497a0816bb5bcc /test/libyul | |
parent | f9ca5b78fb41c18fe0b538d0be909c9026269fbd (diff) | |
download | dexon-solidity-4c8f8e949143d0c680a8257adbcc768d908fae9a.tar.gz dexon-solidity-4c8f8e949143d0c680a8257adbcc768d908fae9a.tar.zst dexon-solidity-4c8f8e949143d0c680a8257adbcc768d908fae9a.zip |
Disallow mismatching types in switch cases and detect duplicates by value for number literals.
Diffstat (limited to 'test/libyul')
-rw-r--r-- | test/libyul/Parser.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp index 897f18ae..84f5c14b 100644 --- a/test/libyul/Parser.cpp +++ b/test/libyul/Parser.cpp @@ -304,6 +304,19 @@ BOOST_AUTO_TEST_CASE(if_statement_invalid) BOOST_CHECK(successParse("{ if 42:u256 { } }")); } +BOOST_AUTO_TEST_CASE(switch_case_types) +{ + CHECK_ERROR("{ switch 0:u256 case 0:u256 {} case 1:u32 {} }", TypeError, "Switch cases have non-matching types."); + // The following should be an error in the future, but this is not yet detected. + BOOST_CHECK(successParse("{ switch 0:u256 case 0:u32 {} case 1:u32 {} }")); +} + +BOOST_AUTO_TEST_CASE(switch_duplicate_case) +{ + CHECK_ERROR("{ switch 0:u256 case 0:u256 {} case 0x0:u256 {} }", DeclarationError, "Duplicate case defined."); + BOOST_CHECK(successParse("{ switch 0:u256 case 42:u256 {} case 0x42:u256 {} }")); +} + BOOST_AUTO_TEST_CASE(builtins_parser) { struct SimpleDialect: public Dialect |