diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 63499d2d2..a88197493 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -203,37 +203,6 @@ BOOST_AUTO_TEST_CASE(constants) BOOST_CHECK(successParse("{ pop(mul(7, 8)) }")); } -BOOST_AUTO_TEST_CASE(vardecl) -{ - BOOST_CHECK(successParse("{ let x := 7 }")); -} - -BOOST_AUTO_TEST_CASE(vardecl_name_clashes) -{ - CHECK_PARSE_ERROR("{ let x := 1 let x := 2 }", DeclarationError, "Variable name x already taken in this scope."); -} - -BOOST_AUTO_TEST_CASE(vardecl_multi) -{ - BOOST_CHECK(successParse("{ function f() -> x, y {} let x, y := f() }")); -} - -BOOST_AUTO_TEST_CASE(vardecl_multi_conflict) -{ - CHECK_PARSE_ERROR("{ function f() -> x, y {} let x, x := f() }", DeclarationError, "Variable name x already taken in this scope."); -} - -BOOST_AUTO_TEST_CASE(vardecl_bool) -{ - successParse("{ let x := true }"); - successParse("{ let x := false }"); -} - -BOOST_AUTO_TEST_CASE(vardecl_empty) -{ - BOOST_CHECK(successParse("{ let x }")); -} - BOOST_AUTO_TEST_CASE(functional) { BOOST_CHECK(successParse("{ let x := 2 x := add(add(7, mul(6, x)), mul(7, 8)) }")); @@ -259,17 +228,6 @@ BOOST_AUTO_TEST_CASE(functional_assignment_complex) BOOST_CHECK(successParse("{ let x := 2 x := add(add(7, mul(6, x)), mul(7, 8)) }")); } -BOOST_AUTO_TEST_CASE(vardecl_complex) -{ - BOOST_CHECK(successParse("{ let y := 2 let x := add(add(7, mul(6, y)), mul(7, 8)) }")); -} - -BOOST_AUTO_TEST_CASE(variable_use_before_decl) -{ - CHECK_PARSE_ERROR("{ x := 2 let x := 3 }", DeclarationError, "Variable x used before it was declared."); - CHECK_PARSE_ERROR("{ let x := mul(2, x) }", DeclarationError, "Variable x used before it was declared."); -} - BOOST_AUTO_TEST_CASE(for_statement) { BOOST_CHECK(successParse("{ for {} 1 {} {} }")); diff --git a/test/libyul/yulSyntaxTests/vardecl.yul b/test/libyul/yulSyntaxTests/vardecl.yul new file mode 100644 index 000000000..64fd69d6f --- /dev/null +++ b/test/libyul/yulSyntaxTests/vardecl.yul @@ -0,0 +1,5 @@ +{ + let x := 7 +} +// ==== +// dialect: yul diff --git a/test/libyul/yulSyntaxTests/vardecl_bool.yul b/test/libyul/yulSyntaxTests/vardecl_bool.yul new file mode 100644 index 000000000..93ec762b0 --- /dev/null +++ b/test/libyul/yulSyntaxTests/vardecl_bool.yul @@ -0,0 +1,6 @@ +{ + let x := true + let y := false +} +// ==== +// dialect: evm diff --git a/test/libyul/yulSyntaxTests/vardecl_complex.yul b/test/libyul/yulSyntaxTests/vardecl_complex.yul new file mode 100644 index 000000000..117e1d997 --- /dev/null +++ b/test/libyul/yulSyntaxTests/vardecl_complex.yul @@ -0,0 +1,4 @@ +{ + let y := 2 + let x := add(add(7, mul(6, y)), mul(7, 8)) +} diff --git a/test/libyul/yulSyntaxTests/vardecl_empty.yul b/test/libyul/yulSyntaxTests/vardecl_empty.yul new file mode 100644 index 000000000..dc536c67a --- /dev/null +++ b/test/libyul/yulSyntaxTests/vardecl_empty.yul @@ -0,0 +1,3 @@ +{ + let x +} diff --git a/test/libyul/yulSyntaxTests/vardecl_multi.yul b/test/libyul/yulSyntaxTests/vardecl_multi.yul new file mode 100644 index 000000000..abf04b746 --- /dev/null +++ b/test/libyul/yulSyntaxTests/vardecl_multi.yul @@ -0,0 +1,4 @@ +{ + function f() -> x, y {} + let x, y := f() +} diff --git a/test/libyul/yulSyntaxTests/vardecl_multi_conflict.yul b/test/libyul/yulSyntaxTests/vardecl_multi_conflict.yul new file mode 100644 index 000000000..c40c79740 --- /dev/null +++ b/test/libyul/yulSyntaxTests/vardecl_multi_conflict.yul @@ -0,0 +1,6 @@ +{ + function f() -> x, y {} + let x, x := f() +} +// ---- +// DeclarationError 1395: (28-43): Variable name x already taken in this scope. diff --git a/test/libyul/yulSyntaxTests/vardecl_name_clashes.yul b/test/libyul/yulSyntaxTests/vardecl_name_clashes.yul new file mode 100644 index 000000000..2906078cf --- /dev/null +++ b/test/libyul/yulSyntaxTests/vardecl_name_clashes.yul @@ -0,0 +1,6 @@ +{ + let x := 1 + let x := 2 +} +// ---- +// DeclarationError 1395: (15-25): Variable name x already taken in this scope. diff --git a/test/libyul/yulSyntaxTests/variable_use_before_decl_1.yul b/test/libyul/yulSyntaxTests/variable_use_before_decl_1.yul new file mode 100644 index 000000000..76bcd1d0d --- /dev/null +++ b/test/libyul/yulSyntaxTests/variable_use_before_decl_1.yul @@ -0,0 +1,6 @@ +{ + x := 2 + let x := 3 +} +// ---- +// DeclarationError 1133: (3-4): Variable x used before it was declared. diff --git a/test/libyul/yulSyntaxTests/variable_use_before_decl_2.yul b/test/libyul/yulSyntaxTests/variable_use_before_decl_2.yul new file mode 100644 index 000000000..c6612fd8c --- /dev/null +++ b/test/libyul/yulSyntaxTests/variable_use_before_decl_2.yul @@ -0,0 +1,6 @@ +{ + let x := mul(2, x) +} + +// ---- +// DeclarationError 4990: (19-20): Variable x used before it was declared.