Extract yul syntax tests: function

This commit is contained in:
Christian Parpart 2020-10-14 12:05:36 +02:00
parent 5b799b01ab
commit 5d40494ed2
9 changed files with 41 additions and 40 deletions

View File

@ -126,46 +126,6 @@ do \
BOOST_AUTO_TEST_SUITE(YulParser)
BOOST_AUTO_TEST_CASE(function_defined_in_init_block)
{
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
BOOST_CHECK(successParse("{ for { } 1 { function f() {} } {} }", dialect));
BOOST_CHECK(successParse("{ for { } 1 {} { function f() {} } }", dialect));
CHECK_ERROR_DIALECT(
"{ for { function f() {} } 1 {} {} }",
SyntaxError,
"Functions cannot be defined inside a for-loop init block.",
dialect
);
}
BOOST_AUTO_TEST_CASE(function_defined_in_init_nested)
{
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
BOOST_CHECK(successParse(
"{ for {"
"for { } 1 { function f() {} } {}"
"} 1 {} {} }", dialect));
CHECK_ERROR_DIALECT(
"{ for { for {function foo() {}} 1 {} {} } 1 {} {} }",
SyntaxError,
"Functions cannot be defined inside a for-loop init block.",
dialect
);
CHECK_ERROR_DIALECT(
"{ for {} 1 {for {function foo() {}} 1 {} {} } {} }",
SyntaxError,
"Functions cannot be defined inside a for-loop init block.",
dialect
);
}
BOOST_AUTO_TEST_CASE(function_shadowing_outside_vars)
{
CHECK_ERROR("{ let x:u256 function f() -> x:u256 {} }", DeclarationError, "already taken in this scope");
BOOST_CHECK(successParse("{ { let x:u256 } function f() -> x:u256 {} }"));
}
BOOST_AUTO_TEST_CASE(builtins_parser)
{
struct SimpleDialect: public Dialect

View File

@ -0,0 +1,3 @@
{
for { } 1:bool { function f() {} } {}
}

View File

@ -0,0 +1,3 @@
{
for { } 1:bool {} { function f() {} }
}

View File

@ -0,0 +1,5 @@
{
for { function f() {} } 1:bool {} {}
}
// ----
// SyntaxError 3441: (9-17): Functions cannot be defined inside a for-loop init block.

View File

@ -0,0 +1,7 @@
{
for {
for {} 1:bool { function f() {} }
{}
} 1:bool {}
{}
}

View File

@ -0,0 +1,5 @@
{
for { for {function foo() {}} 1:bool {} {} } 1:bool {} {}
}
// ----
// SyntaxError 3441: (14-22): Functions cannot be defined inside a for-loop init block.

View File

@ -0,0 +1,8 @@
{
for {}
1:bool
{for {function foo() {}} 1:bool {} {} }
{}
}
// ----
// SyntaxError 3441: (27-35): Functions cannot be defined inside a for-loop init block.

View File

@ -0,0 +1,4 @@
{
{ let x:u256 }
function f() -> x:u256 {}
}

View File

@ -0,0 +1,6 @@
{
let x:u256
function f() -> x:u256 {}
}
// ----
// DeclarationError 1395: (15-40): Variable name x already taken in this scope.