aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-12-06 01:41:26 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-02-06 22:50:39 +0800
commita7ae7c6d04c77f3cdc51644f929d9dbaaa687220 (patch)
tree47c89513bdf1876a014f3027768a023d758db6d6
parente7ef227226fb3548ecea59d44108a5923afeffc6 (diff)
downloaddexon-solidity-a7ae7c6d04c77f3cdc51644f929d9dbaaa687220.tar.gz
dexon-solidity-a7ae7c6d04c77f3cdc51644f929d9dbaaa687220.tar.zst
dexon-solidity-a7ae7c6d04c77f3cdc51644f929d9dbaaa687220.zip
Tests for functional inliner.
-rw-r--r--test/libjulia/Inliner.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/libjulia/Inliner.cpp b/test/libjulia/Inliner.cpp
index 53776acf..93444500 100644
--- a/test/libjulia/Inliner.cpp
+++ b/test/libjulia/Inliner.cpp
@@ -35,7 +35,7 @@ using namespace std;
using namespace dev;
using namespace dev::julia;
using namespace dev::julia::test;
-using namespace dev::solidity::assembly;
+using namespace dev::solidity;
namespace
{
@@ -56,7 +56,7 @@ string inlineFunctions(string const& _source, bool _julia = true)
{
auto ast = disambiguate(_source, _julia);
FunctionalInliner(ast).run();
- return AsmPrinter(_julia)(ast);
+ return assembly::AsmPrinter(_julia)(ast);
}
}
@@ -136,6 +136,26 @@ BOOST_AUTO_TEST_CASE(no_inline_with_mload)
);
}
+BOOST_AUTO_TEST_CASE(no_move_with_side_effects)
+{
+ // The calls to g and h cannot be moved because g and h are not movable. Therefore, the call
+ // to f is not inlined.
+ BOOST_CHECK_EQUAL(
+ inlineFunctions(R"({
+ function f(a, b) -> x { x := add(b, a) }
+ function g() -> y { y := mload(0) mstore(0, 4) }
+ function h() -> z { mstore(0, 4) z := mload(0) }
+ let r := f(g(), h())
+ })", false),
+ format(R"({
+ function f(a, b) -> x { x := add(b, a) }
+ function g() -> y { y := mload(0) mstore(0, 4) }
+ function h() -> z { mstore(0, 4) z := mload(0) }
+ let r := f(g(), h())
+ })", false)
+ );
+}
+
BOOST_AUTO_TEST_CASE(complex_with_evm)
{
BOOST_CHECK_EQUAL(