From eb530aa217387092a84057b550c7665a4acf72b6 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 27 Jan 2017 21:24:58 +0000 Subject: Add tests for invalid instruction --- test/libsolidity/InlineAssembly.cpp | 5 +++++ test/libsolidity/SolidityEndToEndTest.cpp | 15 +++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'test/libsolidity') diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index c051a982..cf0343a9 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -182,6 +182,11 @@ BOOST_AUTO_TEST_CASE(error_tag) BOOST_CHECK(successAssemble("{ invalidJumpLabel }")); } +BOOST_AUTO_TEST_CASE(designated_invalid_instruction) +{ + BOOST_CHECK(successAssemble("{ invalid }")); +} + BOOST_AUTO_TEST_CASE(inline_assembly_shadowed_instruction_declaration) { // Error message: "Cannot use instruction names for identifier names." diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 646017fb..4075a016 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -9043,6 +9043,21 @@ BOOST_AUTO_TEST_CASE(recursive_structs) BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(1))); } +BOOST_AUTO_TEST_CASE(invalid_instruction) +{ + char const* sourceCode = R"( + contract C { + function f() { + assembly { + invalid + } + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("f()") == encodeArgs()); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit