From a7ae7c6d04c77f3cdc51644f929d9dbaaa687220 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 5 Dec 2017 18:41:26 +0100 Subject: Tests for functional inliner. --- test/libjulia/Inliner.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'test/libjulia') 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( -- cgit