mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Extract yul syntax tests: for statement
This commit is contained in:
parent
2accbbe251
commit
c63265ff03
@ -158,145 +158,6 @@ BOOST_AUTO_TEST_CASE(multiple_assignment)
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(break_outside_of_for_loop)
|
||||
{
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ let x if x { break } }",
|
||||
SyntaxError,
|
||||
"Keyword \"break\" needs to be inside a for-loop body.",
|
||||
EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople())
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(continue_outside_of_for_loop)
|
||||
{
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ let x if x { continue } }",
|
||||
SyntaxError,
|
||||
"Keyword \"continue\" needs to be inside a for-loop body.",
|
||||
EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople())
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
BOOST_CHECK(successParse("{ for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1)} {} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_break)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
BOOST_CHECK(successParse("{ for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1)} {break} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_break_init)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0 break} iszero(eq(i, 10)) {i := add(i, 1)} {} }",
|
||||
SyntaxError,
|
||||
"Keyword \"break\" in for-loop init block is not allowed.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_break_post)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1) break} {} }",
|
||||
SyntaxError,
|
||||
"Keyword \"break\" in for-loop post block is not allowed.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_nested_break)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0} iszero(eq(i, 10)) {} { function f() { break } } }",
|
||||
SyntaxError,
|
||||
"Keyword \"break\" needs to be inside a for-loop body.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
BOOST_CHECK(successParse("{ for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1)} {continue} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue_fail_init)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0 continue} iszero(eq(i, 10)) {i := add(i, 1)} {} }",
|
||||
SyntaxError,
|
||||
"Keyword \"continue\" in for-loop init block is not allowed.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue_fail_post)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0} iszero(eq(i, 10)) {i := add(i, 1) continue} {} }",
|
||||
SyntaxError,
|
||||
"Keyword \"continue\" in for-loop post block is not allowed.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_nested_continue)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {let i := 0} iszero(eq(i, 10)) {} { function f() { continue } } }",
|
||||
SyntaxError,
|
||||
"Keyword \"continue\" needs to be inside a for-loop body.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue_nested_init_in_body)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion::constantinople());
|
||||
CHECK_ERROR_DIALECT(
|
||||
"{ for {} 1 {} {let x for { continue } x {} {}} }",
|
||||
SyntaxError,
|
||||
"Keyword \"continue\" in for-loop init block is not allowed.",
|
||||
dialect
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue_nested_body_in_init)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
BOOST_CHECK(successParse("{ for {let x for {} x {} { continue }} 1 {} {} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_break_nested_body_in_init)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
BOOST_CHECK(successParse("{ for {let x for {} x {} { break }} 1 {} {} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_continue_nested_body_in_post)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
BOOST_CHECK(successParse("{ for {} 1 {let x for {} x {} { continue }} {} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement_break_nested_body_in_post)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
BOOST_CHECK(successParse("{ for {} 1 {let x for {} x {} { break }} {} }", dialect));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_defined_in_init_block)
|
||||
{
|
||||
auto const& dialect = EVMDialect::strictAssemblyForEVMObjects(EVMVersion{});
|
||||
|
8
test/libyul/yulSyntaxTests/break_outside_of_for_loop.yul
Normal file
8
test/libyul/yulSyntaxTests/break_outside_of_for_loop.yul
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:bool
|
||||
if x { break }
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 2592: (22-27): Keyword "break" needs to be inside a for-loop body.
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:bool
|
||||
if x { continue }
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 2592: (22-30): Keyword "continue" needs to be inside a for-loop body.
|
7
test/libyul/yulSyntaxTests/for_statement.yul
Normal file
7
test/libyul/yulSyntaxTests/for_statement.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0} x {i := add(i, 1)} {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
10
test/libyul/yulSyntaxTests/for_statement_break.yul
Normal file
10
test/libyul/yulSyntaxTests/for_statement_break.yul
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0} x {i := add(i, 1)}
|
||||
{
|
||||
break
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
8
test/libyul/yulSyntaxTests/for_statement_break_init.yul
Normal file
8
test/libyul/yulSyntaxTests/for_statement_break_init.yul
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0 break} x {i := add(i, 1)} {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 9615: (31-36): Keyword "break" in for-loop init block is not allowed.
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
for {let x:bool for {} x {} { break }} 1:bool {}
|
||||
{}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
for {} 1:bool {let x:bool for {} x {} { break }}
|
||||
{}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
8
test/libyul/yulSyntaxTests/for_statement_break_post.yul
Normal file
8
test/libyul/yulSyntaxTests/for_statement_break_post.yul
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0 } x {i := add(i, 1) break} {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 2461: (51-56): Keyword "break" in for-loop post block is not allowed.
|
10
test/libyul/yulSyntaxTests/for_statement_continue.yul
Normal file
10
test/libyul/yulSyntaxTests/for_statement_continue.yul
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0} x {i := add(i, 1)}
|
||||
{
|
||||
continue
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0 continue} x {i := add(i, 1)}
|
||||
{
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 9615: (31-39): Keyword "continue" in for-loop init block is not allowed.
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0} x {i := add(i, 1) continue} {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 2461: (50-58): Keyword "continue" in for-loop post block is not allowed.
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
for {let x:bool for {} x {} { continue }} 1:bool {}
|
||||
{
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
for {} 1:bool {let x:bool for {} x {} { continue }}
|
||||
{}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
for {} 1 {}
|
||||
{
|
||||
let x:bool
|
||||
for { continue } x {} {}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 9615: (39-47): Keyword "continue" in for-loop init block is not allowed.
|
11
test/libyul/yulSyntaxTests/for_statement_nested_break.yul
Normal file
11
test/libyul/yulSyntaxTests/for_statement_nested_break.yul
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
let x:bool
|
||||
for {let i := 0} x {}
|
||||
{
|
||||
function f() { break }
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 2592: (57-62): Keyword "break" needs to be inside a for-loop body.
|
10
test/libyul/yulSyntaxTests/for_statement_nested_continue.yul
Normal file
10
test/libyul/yulSyntaxTests/for_statement_nested_continue.yul
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
for {let i := 0} iszero(eq(i, 10)) {}
|
||||
{
|
||||
function f() { continue }
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// SyntaxError 2592: (61-69): Keyword "continue" needs to be inside a for-loop body.
|
Loading…
Reference in New Issue
Block a user