mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
InlineAssembly: Extracting tests for for-statements.
This commit is contained in:
parent
671b1c950e
commit
f2117b87f7
@ -203,41 +203,6 @@ BOOST_AUTO_TEST_CASE(constants)
|
||||
BOOST_CHECK(successParse("{ pop(mul(7, 8)) }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement)
|
||||
{
|
||||
BOOST_CHECK(successParse("{ for {} 1 {} {} }"));
|
||||
BOOST_CHECK(successParse("{ for { let i := 1 } lt(i, 5) { i := add(i, 1) } {} }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_invalid_expression)
|
||||
{
|
||||
CHECK_PARSE_ERROR("{ for {} {} {} {} }", ParserError, "Literal or identifier expected.");
|
||||
CHECK_PARSE_ERROR("{ for 1 1 {} {} }", ParserError, "Expected '{' but got 'Number'");
|
||||
CHECK_PARSE_ERROR("{ for {} 1 1 {} }", ParserError, "Expected '{' but got 'Number'");
|
||||
CHECK_PARSE_ERROR("{ for {} 1 {} 1 }", ParserError, "Expected '{' but got 'Number'");
|
||||
CHECK_PARSE_ERROR("{ for {} mload {} {} }", ParserError, "Expected '(' but got '{'");
|
||||
CHECK_PARSE_ERROR("{ for {} mstore(1, 1) {} {} }", TypeError, "Expected expression to evaluate to one value, but got 0 values instead.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_visibility)
|
||||
{
|
||||
BOOST_CHECK(successParse("{ for { let i := 1 } i { pop(i) } { pop(i) } }"));
|
||||
CHECK_PARSE_ERROR("{ for {} i { let i := 1 } {} }", DeclarationError, "Identifier not found");
|
||||
CHECK_PARSE_ERROR("{ for {} 1 { let i := 1 } { pop(i) } }", DeclarationError, "Identifier not found");
|
||||
CHECK_PARSE_ERROR("{ for {} 1 { pop(i) } { let i := 1 } }", DeclarationError, "Identifier not found");
|
||||
CHECK_PARSE_ERROR("{ for { pop(i) } 1 { let i := 1 } {} }", DeclarationError, "Identifier not found");
|
||||
CHECK_PARSE_ERROR("{ for { pop(i) } 1 { } { let i := 1 } }", DeclarationError, "Identifier not found");
|
||||
CHECK_PARSE_ERROR("{ for {} i {} { let i := 1 } }", DeclarationError, "Identifier not found");
|
||||
CHECK_PARSE_ERROR("{ for {} 1 { pop(i) } { let i := 1 } }", DeclarationError, "Identifier not found");
|
||||
CHECK_PARSE_ERROR("{ for { let x := 1 } 1 { let x := 1 } {} }", DeclarationError, "Variable name x already taken in this scope");
|
||||
CHECK_PARSE_ERROR("{ for { let x := 1 } 1 {} { let x := 1 } }", DeclarationError, "Variable name x already taken in this scope");
|
||||
CHECK_PARSE_ERROR("{ let x := 1 for { let x := 1 } 1 {} {} }", DeclarationError, "Variable name x already taken in this scope");
|
||||
CHECK_PARSE_ERROR("{ let x := 1 for {} 1 { let x := 1 } {} }", DeclarationError, "Variable name x already taken in this scope");
|
||||
CHECK_PARSE_ERROR("{ let x := 1 for {} 1 {} { let x := 1 } }", DeclarationError, "Variable name x already taken in this scope");
|
||||
// Check that body and post are not sub-scopes of each other.
|
||||
BOOST_CHECK(successParse("{ for {} 1 { let x := 1 } { let x := 1 } }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(blocks)
|
||||
{
|
||||
BOOST_CHECK(successParse("{ let x := 7 { let y := 3 } { let z := 2 } }"));
|
||||
@ -512,12 +477,6 @@ BOOST_AUTO_TEST_CASE(embedded_functions)
|
||||
BOOST_CHECK(successAssemble("{ function f(r, s) -> x { function g(a) -> b { } x := g(2) } let x := f(2, 3) }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_statement)
|
||||
{
|
||||
BOOST_CHECK(successAssemble("{ for {} 1 {} {} }"));
|
||||
BOOST_CHECK(successAssemble("{ let x := calldatasize() for { let i := 0} lt(i, x) { i := add(i, 1) } { mstore(i, 2) } }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(large_constant)
|
||||
{
|
||||
auto source = R"({
|
||||
|
5
test/libyul/yulSyntaxTests/for_expr_invalid_1.yul
Normal file
5
test/libyul/yulSyntaxTests/for_expr_invalid_1.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
for {} {} {} {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 1856: (10-11): Literal or identifier expected.
|
5
test/libyul/yulSyntaxTests/for_expr_invalid_2.yul
Normal file
5
test/libyul/yulSyntaxTests/for_expr_invalid_2.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
for 1 1 {} {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (7-8): Expected '{' but got 'Number'
|
5
test/libyul/yulSyntaxTests/for_expr_invalid_3.yul
Normal file
5
test/libyul/yulSyntaxTests/for_expr_invalid_3.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
for {} 1 1 {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (12-13): Expected '{' but got 'Number'
|
5
test/libyul/yulSyntaxTests/for_expr_invalid_4.yul
Normal file
5
test/libyul/yulSyntaxTests/for_expr_invalid_4.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
for {} 1 {} 1
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (15-16): Expected '{' but got 'Number'
|
5
test/libyul/yulSyntaxTests/for_expr_invalid_5.yul
Normal file
5
test/libyul/yulSyntaxTests/for_expr_invalid_5.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
for {} mload {} {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (16-17): Expected '(' but got '{'
|
7
test/libyul/yulSyntaxTests/for_expr_invalid_6.yul
Normal file
7
test/libyul/yulSyntaxTests/for_expr_invalid_6.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
for {} mstore(1, 1) {} {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
||||
// TypeError 3950: (10-22): Expected expression to evaluate to one value, but got 0 values instead.
|
10
test/libyul/yulSyntaxTests/for_statement_2.yul
Normal file
10
test/libyul/yulSyntaxTests/for_statement_2.yul
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
|
||||
{ for {} 1 {} {} }
|
||||
{ for { let i := 1 } lt(i, 5) { i := add(i, 1) } {} }
|
||||
{ for {} 1 {} {} }
|
||||
{ let x := calldatasize() for { let i := 0} lt(i, x) { i := add(i, 1) } { mstore(i, 2) } }
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
5
test/libyul/yulSyntaxTests/for_visibility_1.yul
Normal file
5
test/libyul/yulSyntaxTests/for_visibility_1.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
for { let i := 1 } i { pop(i) } { pop(i) }
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
7
test/libyul/yulSyntaxTests/for_visibility_2.yul
Normal file
7
test/libyul/yulSyntaxTests/for_visibility_2.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
for {} i { let i := 1 } {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
||||
// DeclarationError 8198: (10-11): Identifier not found.
|
7
test/libyul/yulSyntaxTests/for_visibility_3.yul
Normal file
7
test/libyul/yulSyntaxTests/for_visibility_3.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
for {} 1 { let i := 1 } { pop(i) }
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
||||
// DeclarationError 8198: (33-34): Identifier not found.
|
7
test/libyul/yulSyntaxTests/for_visibility_4.yul
Normal file
7
test/libyul/yulSyntaxTests/for_visibility_4.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
for {} 1 { pop(i) } { let i := 1 }
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
||||
// DeclarationError 8198: (18-19): Identifier not found.
|
7
test/libyul/yulSyntaxTests/for_visibility_5.yul
Normal file
7
test/libyul/yulSyntaxTests/for_visibility_5.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
for { pop(i) } 1 { let i := 1 } {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
||||
// DeclarationError 8198: (13-14): Identifier not found.
|
7
test/libyul/yulSyntaxTests/for_visibility_6.yul
Normal file
7
test/libyul/yulSyntaxTests/for_visibility_6.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
for { pop(i) } 1 { } { let i := 1 }
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
||||
// DeclarationError 8198: (13-14): Identifier not found.
|
7
test/libyul/yulSyntaxTests/for_visibility_7.yul
Normal file
7
test/libyul/yulSyntaxTests/for_visibility_7.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
for {} i {} { let i := 1 }
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
||||
// DeclarationError 8198: (10-11): Identifier not found.
|
7
test/libyul/yulSyntaxTests/for_visibility_8.yul
Normal file
7
test/libyul/yulSyntaxTests/for_visibility_8.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
for {} 1 { pop(i) } { let i := 1 }
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
||||
// DeclarationError 8198: (18-19): Identifier not found.
|
7
test/libyul/yulSyntaxTests/for_visibility_9.yul
Normal file
7
test/libyul/yulSyntaxTests/for_visibility_9.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
for { let x := 1 } 1 { let x := 1 } {}
|
||||
}
|
||||
// ====
|
||||
// dialect: yul
|
||||
// ----
|
||||
// DeclarationError 1395: (26-36): Variable name x already taken in this scope.
|
7
test/libyul/yulSyntaxTests/for_visibility_A.yul
Normal file
7
test/libyul/yulSyntaxTests/for_visibility_A.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
for { let x := 1 } 1 {} { let x := 1 }
|
||||
}
|
||||
// ====
|
||||
// dialect: yul
|
||||
// ----
|
||||
// DeclarationError 1395: (29-39): Variable name x already taken in this scope.
|
5
test/libyul/yulSyntaxTests/for_visibility_B.yul
Normal file
5
test/libyul/yulSyntaxTests/for_visibility_B.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
let x := 1 for { let x := 1 } 1 {} {}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 1395: (20-30): Variable name x already taken in this scope.
|
5
test/libyul/yulSyntaxTests/for_visibility_C.yul
Normal file
5
test/libyul/yulSyntaxTests/for_visibility_C.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
let x := 1 for {} 1 { let x := 1 } {}
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 1395: (25-35): Variable name x already taken in this scope.
|
5
test/libyul/yulSyntaxTests/for_visibility_D.yul
Normal file
5
test/libyul/yulSyntaxTests/for_visibility_D.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
let x := 1 for {} 1 {} { let x := 1 }
|
||||
}
|
||||
// ----
|
||||
// DeclarationError 1395: (28-38): Variable name x already taken in this scope.
|
6
test/libyul/yulSyntaxTests/for_visibility_E.yul
Normal file
6
test/libyul/yulSyntaxTests/for_visibility_E.yul
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
// Check that body and post are not sub-scopes of each other.
|
||||
for {} 1 { let x := 1 } { let x := 1 }
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
Loading…
Reference in New Issue
Block a user