diff options
author | Yoichi Hirai <i@yoichihirai.com> | 2016-11-15 22:37:05 +0800 |
---|---|---|
committer | Yoichi Hirai <i@yoichihirai.com> | 2016-11-24 18:31:45 +0800 |
commit | feb10d015f6c8629ec24fcd2617332d67fb7f097 (patch) | |
tree | f8bea1105149470c2ef16f2fb3f32b82520dba6a /test/libsolidity/SolidityEndToEndTest.cpp | |
parent | d4173cd54a7012456267cbabbd6c809f0d6763cb (diff) | |
download | dexon-solidity-feb10d015f6c8629ec24fcd2617332d67fb7f097.tar.gz dexon-solidity-feb10d015f6c8629ec24fcd2617332d67fb7f097.tar.zst dexon-solidity-feb10d015f6c8629ec24fcd2617332d67fb7f097.zip |
test: add a test that stores an invalid enum value
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 8b1c4836..6478ea86 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -4573,6 +4573,35 @@ BOOST_AUTO_TEST_CASE(invalid_enum_logged) BOOST_CHECK(callContractFunction("test_log()") == encodeArgs()); } +BOOST_AUTO_TEST_CASE(invalid_enum_stored) +{ + char const* sourceCode = R"( + contract C { + enum X { A, B } + X public x; + + function test_store() returns (uint) { + X garbled = X.A; + assembly { + garbled := 5 + } + x = garbled; + return 1; + } + function test_store_ok() returns (uint) { + x = X.A; + return 1; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("test_store_ok()") == encodeArgs(u256(1))); + BOOST_CHECK(callContractFunction("x()") == encodeArgs(u256(0))); + + // should throw + BOOST_CHECK(callContractFunction("test_store()") == encodeArgs()); +} + BOOST_AUTO_TEST_CASE(invalid_enum_as_external_ret) { char const* sourceCode = R"( |