aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp91
1 files changed, 90 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index da725581..94d3e168 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -3702,6 +3702,50 @@ BOOST_AUTO_TEST_CASE(enum_explicit_overflow)
BOOST_CHECK(callContractFunction("getChoiceExp(uint256)", 0) == encodeArgs(0));
}
+BOOST_AUTO_TEST_CASE(storing_invalid_boolean)
+{
+ char const* sourceCode = R"(
+ contract C {
+ event Ev(bool);
+ bool public perm;
+ function set() returns(uint) {
+ bool tmp;
+ assembly {
+ tmp := 5
+ }
+ perm = tmp;
+ return 1;
+ }
+ function ret() returns(bool) {
+ bool tmp;
+ assembly {
+ tmp := 5
+ }
+ return tmp;
+ }
+ function ev() returns(uint) {
+ bool tmp;
+ assembly {
+ tmp := 5
+ }
+ Ev(tmp);
+ return 1;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("set()") == encodeArgs(1));
+ BOOST_CHECK(callContractFunction("perm()") == encodeArgs(1));
+ BOOST_CHECK(callContractFunction("ret()") == encodeArgs(1));
+ BOOST_CHECK(callContractFunction("ev()") == encodeArgs(1));
+ BOOST_REQUIRE_EQUAL(m_logs.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress);
+ BOOST_CHECK(m_logs[0].data == encodeArgs(1));
+ BOOST_REQUIRE_EQUAL(m_logs[0].topics.size(), 1);
+ BOOST_CHECK_EQUAL(m_logs[0].topics[0], dev::keccak256(string("Ev(bool)")));
+}
+
+
BOOST_AUTO_TEST_CASE(using_contract_enums_with_explicit_contract_name)
{
char const* sourceCode = R"(
@@ -9578,7 +9622,7 @@ BOOST_AUTO_TEST_CASE(scientific_notation)
BOOST_CHECK(callContractFunction("k()") == encodeArgs(u256(-25)));
}
-BOOST_AUTO_TEST_CASE(interface)
+BOOST_AUTO_TEST_CASE(interface_contract)
{
char const* sourceCode = R"(
interface I {
@@ -9652,6 +9696,51 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly)
BOOST_CHECK(callContractFunction("i()") == fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"));
}
+BOOST_AUTO_TEST_CASE(multi_modifiers)
+{
+ // This triggered a bug in some version because the variable in the modifier was not
+ // unregistered correctly.
+ char const* sourceCode = R"(
+ contract C {
+ uint public x;
+ modifier m1 {
+ address a1 = msg.sender;
+ x++;
+ _;
+ }
+ function f1() m1() {
+ x += 7;
+ }
+ function f2() m1() {
+ x += 3;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f1()") == bytes());
+ BOOST_CHECK(callContractFunction("x()") == encodeArgs(u256(8)));
+ BOOST_CHECK(callContractFunction("f2()") == bytes());
+ BOOST_CHECK(callContractFunction("x()") == encodeArgs(u256(12)));
+}
+
+BOOST_AUTO_TEST_CASE(inlineasm_empty_let)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() returns (uint a, uint b) {
+ assembly {
+ let x
+ let y, z
+ a := x
+ b := z
+ }
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0), u256(0)));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}