From b86b084bc68e50ba71ba398c3ecb7ad2c28ececb Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Mon, 12 Jun 2017 14:47:28 +0200 Subject: Add a test that fails about an LLL macro with no arguments --- test/liblll/Parser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/liblll/Parser.cpp b/test/liblll/Parser.cpp index 0d5d9ea5..ff73c348 100644 --- a/test/liblll/Parser.cpp +++ b/test/liblll/Parser.cpp @@ -174,6 +174,12 @@ BOOST_AUTO_TEST_CASE(list) BOOST_CHECK(!successParse("()")); } +BOOST_AUTO_TEST_CASE(macro_with_zero_args) +{ + char const* text = "(def 'zeroargs () (asm INVALID))"; + BOOST_CHECK(successParse(text)); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit v1.2.3 From 37a949e634c4d9c47f7dabb579ddcfc23a89b0a6 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Mon, 12 Jun 2017 14:52:04 +0200 Subject: liblll: allow macros with no arguments --- liblll/Parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liblll/Parser.cpp b/liblll/Parser.cpp index 44d2a2ae..a3962df4 100644 --- a/liblll/Parser.cpp +++ b/liblll/Parser.cpp @@ -109,7 +109,7 @@ void dev::eth::parseTreeLLL(string const& _s, sp::utree& o_out) qi::rule mstore = '[' > element > ']' > -qi::lit(":") > element; qi::rule sstore = qi::lit("[[") > element > qi::lit("]]") > -qi::lit(":") > element; qi::rule calldataload = qi::lit("$") > element; - qi::rule list = '(' > +element > ')'; + qi::rule list = '(' > *element > ')'; qi::rule extra = sload[tagNode<2>()] | mload[tagNode<1>()] | sstore[tagNode<4>()] | mstore[tagNode<3>()] | seq[tagNode<5>()] | calldataload[tagNode<6>()]; element = atom | list | extra; -- cgit v1.2.3 From a03913427f08d6c2e185ba7b8e5a0ba7e2e1a25b Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Mon, 12 Jun 2017 14:58:10 +0200 Subject: Add an end-to-end test about LLL macro with zero arguments --- test/liblll/EndToEndTest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/liblll/EndToEndTest.cpp b/test/liblll/EndToEndTest.cpp index c7c1fd3b..c511e6f0 100644 --- a/test/liblll/EndToEndTest.cpp +++ b/test/liblll/EndToEndTest.cpp @@ -279,6 +279,18 @@ BOOST_AUTO_TEST_CASE(assembly_codecopy) BOOST_CHECK(callFallback() == encodeArgs(string("abcdef"))); } +BOOST_AUTO_TEST_CASE(zeroarg_macro) +{ + char const* sourceCode = R"( + (returnlll + (seq + (def 'zeroarg () (asm INVALID)) + (zeroarg))) + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callFallback() == encodeArgs()); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit v1.2.3 From 0909ffc26ee1b616ae2ee9ed44aed64243433f33 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Tue, 13 Jun 2017 12:21:28 +0200 Subject: Fix the expectation about the parse --- test/liblll/Parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/liblll/Parser.cpp b/test/liblll/Parser.cpp index ff73c348..fc977b81 100644 --- a/test/liblll/Parser.cpp +++ b/test/liblll/Parser.cpp @@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(list) BOOST_CHECK_EQUAL(parse(text), R"(( 1234 ))"); BOOST_CHECK(successParse("( 1234 5467 )")); - BOOST_CHECK(!successParse("()")); + BOOST_CHECK(successParse("()")); } BOOST_AUTO_TEST_CASE(macro_with_zero_args) -- cgit v1.2.3 From c4f0608b683d30142161aa3c9850e3a981521b53 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Tue, 13 Jun 2017 12:28:03 +0200 Subject: More informative test --- test/liblll/EndToEndTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/liblll/EndToEndTest.cpp b/test/liblll/EndToEndTest.cpp index c511e6f0..c8e7adf1 100644 --- a/test/liblll/EndToEndTest.cpp +++ b/test/liblll/EndToEndTest.cpp @@ -284,11 +284,11 @@ BOOST_AUTO_TEST_CASE(zeroarg_macro) char const* sourceCode = R"( (returnlll (seq - (def 'zeroarg () (asm INVALID)) + (def 'zeroarg () (seq (mstore 0 0x1234) (return 0 32))) (zeroarg))) )"; compileAndRun(sourceCode); - BOOST_CHECK(callFallback() == encodeArgs()); + BOOST_CHECK(callFallback() == encodeArgs(u256(0x1234))); } BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3