aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/InlineAssembly.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-02-14 22:40:58 +0800
committerchriseth <c@ethdev.com>2017-02-14 22:41:25 +0800
commit58849cb1d52c88daeb15ec34d19ef0dc143c0a33 (patch)
tree204461760f0f020e307bc3b5abc8e7b06da844aa /test/libsolidity/InlineAssembly.cpp
parentca71b7624db6c731670ddf69873dd9f0c8c6ccd2 (diff)
downloaddexon-solidity-58849cb1d52c88daeb15ec34d19ef0dc143c0a33.tar.gz
dexon-solidity-58849cb1d52c88daeb15ec34d19ef0dc143c0a33.tar.zst
dexon-solidity-58849cb1d52c88daeb15ec34d19ef0dc143c0a33.zip
Tests for printing assembly.
Diffstat (limited to 'test/libsolidity/InlineAssembly.cpp')
-rw-r--r--test/libsolidity/InlineAssembly.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp
index 37d17495..437c5866 100644
--- a/test/libsolidity/InlineAssembly.cpp
+++ b/test/libsolidity/InlineAssembly.cpp
@@ -73,11 +73,22 @@ bool successAssemble(string const& _source, bool _allowWarnings = true)
return successParse(_source, true, _allowWarnings);
}
+void parsePrintCompare(string const& _source)
+{
+ assembly::InlineAssemblyStack stack;
+ BOOST_REQUIRE(stack.parse(std::make_shared<Scanner>(CharStream(_source))));
+ BOOST_REQUIRE(stack.errors().empty());
+ BOOST_CHECK_EQUAL(stack.toString(), _source);
+}
+
}
BOOST_AUTO_TEST_SUITE(SolidityInlineAssembly)
+
+BOOST_AUTO_TEST_SUITE(Parsing)
+
BOOST_AUTO_TEST_CASE(smoke_test)
{
BOOST_CHECK(successParse("{ }"));
@@ -148,6 +159,49 @@ BOOST_AUTO_TEST_CASE(blocks)
BOOST_CHECK(successParse("{ let x := 7 { let y := 3 } { let z := 2 } }"));
}
+BOOST_AUTO_TEST_SUITE_END()
+
+BOOST_AUTO_TEST_SUITE(Printing)
+
+BOOST_AUTO_TEST_CASE(print_smoke)
+{
+ parsePrintCompare("{\n}");
+}
+
+BOOST_AUTO_TEST_CASE(print_instructions)
+{
+ parsePrintCompare("{\n 7\n 8\n mul\n dup10\n add\n}");
+}
+
+BOOST_AUTO_TEST_CASE(print_subblock)
+{
+ parsePrintCompare("{\n {\n dup4\n add\n }\n}");
+}
+
+BOOST_AUTO_TEST_CASE(print_functional)
+{
+ parsePrintCompare("{\n mul(sload(0x12), 7)\n}");
+}
+
+BOOST_AUTO_TEST_CASE(print_label)
+{
+ parsePrintCompare("{\n loop:\n jump(loop)\n}");
+}
+
+BOOST_AUTO_TEST_CASE(print_assignments)
+{
+ parsePrintCompare("{\n let x := mul(2, 3)\n 7\n =: x\n x := add(1, 2)\n}");
+}
+
+BOOST_AUTO_TEST_CASE(print_string_literals)
+{
+ parsePrintCompare("{\n \"\\n'\\xab\\x95\\\"\"\n}");
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+BOOST_AUTO_TEST_SUITE(Analysis)
+
BOOST_AUTO_TEST_CASE(string_literals)
{
BOOST_CHECK(successAssemble("{ let x := \"12345678901234567890123456789012\" }"));
@@ -212,6 +266,8 @@ BOOST_AUTO_TEST_CASE(revert)
BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END()
+
}
}
} // end namespaces