aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-11-14 23:44:04 +0800
committerYoichi Hirai <i@yoichihirai.com>2016-11-14 23:44:04 +0800
commit454e7618c8ebd35d442c43a66b2f95b36a4cd1d5 (patch)
treec40ed0251866eaf616228c662b6e81f5802823ed /test/libsolidity/SolidityEndToEndTest.cpp
parent68e776338701f6140d0e58470c503fabc35bc5dc (diff)
downloaddexon-solidity-454e7618c8ebd35d442c43a66b2f95b36a4cd1d5.tar.gz
dexon-solidity-454e7618c8ebd35d442c43a66b2f95b36a4cd1d5.tar.zst
dexon-solidity-454e7618c8ebd35d442c43a66b2f95b36a4cd1d5.zip
test: add tests about returning invalid enum values from interface functions
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 5582e4a1..74cf53cf 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -4499,6 +4499,40 @@ BOOST_AUTO_TEST_CASE(external_types_in_calls)
BOOST_CHECK(callContractFunction("t2()") == encodeArgs(u256(9)));
}
+BOOST_AUTO_TEST_CASE(invalid_enum_as_external_ret)
+{
+ char const* sourceCode = R"(
+ contract C {
+ enum X { A, B }
+
+ function test_return() returns (X) {
+ X garbled;
+ assembly {
+ garbled := 5
+ }
+ return garbled;
+ }
+ function test_inline_assignment() returns (X _ret) {
+ assembly {
+ _ret := 5
+ }
+ }
+ function test_assignment() returns (X _ret) {
+ X tmp;
+ assembly {
+ tmp := 5
+ }
+ _ret = tmp;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ // both should throw
+ BOOST_CHECK(callContractFunction("test_return()") == encodeArgs());
+ BOOST_CHECK(callContractFunction("test_inline_assignment()") == encodeArgs());
+ BOOST_CHECK(callContractFunction("test_assignment()") == encodeArgs());
+}
+
BOOST_AUTO_TEST_CASE(proper_order_of_overwriting_of_attributes)
{
// bug #1798