aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-06 22:30:43 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-02-06 22:50:39 +0800
commitd7863e2054fe5617aa1de93bb9410b487d1af5d4 (patch)
tree0697dc081793c8bde71b29c3f9214802682cbc20 /test
parent3960f4184da94ebc469ab4a38f5b30579386520e (diff)
downloaddexon-solidity-d7863e2054fe5617aa1de93bb9410b487d1af5d4.tar.gz
dexon-solidity-d7863e2054fe5617aa1de93bb9410b487d1af5d4.tar.zst
dexon-solidity-d7863e2054fe5617aa1de93bb9410b487d1af5d4.zip
Test about recursively calling functions.
Diffstat (limited to 'test')
-rw-r--r--test/libjulia/Inliner.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/test/libjulia/Inliner.cpp b/test/libjulia/Inliner.cpp
index 93444500..b6a7b921 100644
--- a/test/libjulia/Inliner.cpp
+++ b/test/libjulia/Inliner.cpp
@@ -21,8 +21,8 @@
#include <test/libjulia/Common.h>
-#include <libjulia/optimiser/InlinableFunctionFilter.h>
-#include <libjulia/optimiser/FunctionalInliner.h>
+#include <libjulia/optimiser/ExpressionInliner.h>
+#include <libjulia/optimiser/InlinableExpressionFunctionFinder.h>
#include <libsolidity/inlineasm/AsmPrinter.h>
@@ -43,11 +43,11 @@ string inlinableFunctions(string const& _source)
{
auto ast = disambiguate(_source);
- InlinableFunctionFilter filter;
- filter(ast);
+ InlinableExpressionFunctionFinder funFinder;
+ funFinder(ast);
return boost::algorithm::join(
- filter.inlinableFunctions() | boost::adaptors::map_keys,
+ funFinder.inlinableFunctions() | boost::adaptors::map_keys,
","
);
}
@@ -55,7 +55,7 @@ string inlinableFunctions(string const& _source)
string inlineFunctions(string const& _source, bool _julia = true)
{
auto ast = disambiguate(_source, _julia);
- FunctionalInliner(ast).run();
+ ExpressionInliner(ast).run();
return assembly::AsmPrinter(_julia)(ast);
}
}
@@ -180,6 +180,20 @@ BOOST_AUTO_TEST_CASE(double_calls)
);
}
-// TODO test double recursive calls
+BOOST_AUTO_TEST_CASE(double_recursive_calls)
+{
+ BOOST_CHECK_EQUAL(
+ inlineFunctions(R"({
+ function f(a, r) -> x { x := g(a, g(r, r)) }
+ function g(b, s) -> y { y := f(b, f(s, s)) }
+ let y := g(calldatasize(), 7)
+ })", false),
+ format(R"({
+ function f(a, r) -> x { x := g(a, f(r, f(r, r))) }
+ function g(b, s) -> y { y := f(b, g(s, f(s, f(s, s))))}
+ let y_1 := f(calldatasize(), g(7, f(7, f(7, 7))))
+ })", false)
+ );
+}
BOOST_AUTO_TEST_SUITE_END()