mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Extract yul syntax tests: function
This commit is contained in:
parent
5b799b01ab
commit
5d40494ed2
@ -126,46 +126,6 @@ do \
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(YulParser)
|
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)
|
BOOST_AUTO_TEST_CASE(builtins_parser)
|
||||||
{
|
{
|
||||||
struct SimpleDialect: public Dialect
|
struct SimpleDialect: public Dialect
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
for { } 1:bool { function f() {} } {}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
for { } 1:bool {} { function f() {} }
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
for { function f() {} } 1:bool {} {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// SyntaxError 3441: (9-17): Functions cannot be defined inside a for-loop init block.
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
for {
|
||||||
|
for {} 1:bool { function f() {} }
|
||||||
|
{}
|
||||||
|
} 1:bool {}
|
||||||
|
{}
|
||||||
|
}
|
@ -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.
|
@ -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.
|
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
{ let x:u256 }
|
||||||
|
function f() -> x:u256 {}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
let x:u256
|
||||||
|
function f() -> x:u256 {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// DeclarationError 1395: (15-40): Variable name x already taken in this scope.
|
Loading…
Reference in New Issue
Block a user