From 15517b571d3ac4ee01af3e2e2f3fff7c5b2296c5 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 13 Oct 2017 02:04:36 +0100 Subject: lll: disallow useless PUSHn in assembly --- test/liblll/Compiler.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/liblll') diff --git a/test/liblll/Compiler.cpp b/test/liblll/Compiler.cpp index 2d66bce1..77d263b8 100644 --- a/test/liblll/Compiler.cpp +++ b/test/liblll/Compiler.cpp @@ -121,6 +121,23 @@ BOOST_AUTO_TEST_CASE(switch_inconsistent_return_count) BOOST_CHECK(!successCompile(sourceCode)); } +BOOST_AUTO_TEST_CASE(disallowed_asm_instructions) +{ + for (unsigned i = 1; i <= 32; i++) + BOOST_CHECK(!successCompile("(asm PUSH" + boost::lexical_cast(i) + ")")); +} + +BOOST_AUTO_TEST_CASE(disallowed_functional_asm_instructions) +{ + for (unsigned i = 1; i <= 32; i++) + BOOST_CHECK(!successCompile("(PUSH" + boost::lexical_cast(i) + ")")); + for (unsigned i = 1; i <= 16; i++) + BOOST_CHECK(!successCompile("(DUP" + boost::lexical_cast(i) + ")")); + for (unsigned i = 1; i <= 16; i++) + BOOST_CHECK(!successCompile("(SWAP" + boost::lexical_cast(i) + ")")); + BOOST_CHECK(!successCompile("(JUMPDEST)")); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit v1.2.3