Skip to content

Commit 73c5d99

Browse files
committed
Add basic test for shift opcodes
1 parent 317e017 commit 73c5d99

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/libsolidity/InlineAssembly.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,20 @@ BOOST_AUTO_TEST_CASE(create2)
774774
BOOST_CHECK(successAssemble("{ pop(create2(10, 0x123, 32, 64)) }"));
775775
}
776776

777+
BOOST_AUTO_TEST_CASE(shift)
778+
{
779+
BOOST_CHECK(successAssemble("{ pop(shl(10, 32)) }"));
780+
BOOST_CHECK(successAssemble("{ pop(shr(10, 32)) }"));
781+
BOOST_CHECK(successAssemble("{ pop(sar(10, 32)) }"));
782+
}
783+
784+
BOOST_AUTO_TEST_CASE(shift_constantinople_warning)
785+
{
786+
CHECK_PARSE_WARNING("{ pop(shl(10, 32)) }", Warning, "The \"shl\" instruction is only available after the Constantinople hard fork");
787+
CHECK_PARSE_WARNING("{ pop(shr(10, 32)) }", Warning, "The \"shr\" instruction is only available after the Constantinople hard fork");
788+
CHECK_PARSE_WARNING("{ pop(sar(10, 32)) }", Warning, "The \"sar\" instruction is only available after the Constantinople hard fork");
789+
}
790+
777791
BOOST_AUTO_TEST_CASE(jump_warning)
778792
{
779793
CHECK_PARSE_WARNING("{ 1 jump }", Warning, "Jump instructions");

0 commit comments

Comments
 (0)