mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
InlineAssembly: Extracting tests for if statement
This commit is contained in:
parent
8270af8560
commit
6f872dbebf
@ -270,27 +270,6 @@ BOOST_AUTO_TEST_CASE(variable_use_before_decl)
|
||||
CHECK_PARSE_ERROR("{ let x := mul(2, x) }", DeclarationError, "Variable x used before it was declared.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(if_statement)
|
||||
{
|
||||
BOOST_CHECK(successParse("{ if 42 {} }"));
|
||||
BOOST_CHECK(successParse("{ if 42 { let x := 3 } }"));
|
||||
BOOST_CHECK(successParse("{ function f() -> x {} if f() { pop(f()) } }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(if_statement_scope)
|
||||
{
|
||||
BOOST_CHECK(successParse("{ let x := 2 if 42 { x := 3 } }"));
|
||||
CHECK_PARSE_ERROR("{ if 32 { let x := 3 } x := 2 }", DeclarationError, "Variable not found or variable not lvalue.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(if_statement_invalid)
|
||||
{
|
||||
CHECK_PARSE_ERROR("{ if mload {} }", ParserError, "Expected '(' but got '{'");
|
||||
BOOST_CHECK("{ if calldatasize() {}");
|
||||
CHECK_PARSE_ERROR("{ if mstore(1, 1) {} }", TypeError, "Expected expression to evaluate to one value, but got 0 values instead.");
|
||||
CHECK_PARSE_ERROR("{ if 32 let x := 3 }", ParserError, "Expected '{' but got reserved keyword 'let'");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(switch_statement)
|
||||
{
|
||||
BOOST_CHECK(successParse("{ switch 42 default {} }"));
|
||||
@ -671,12 +650,6 @@ BOOST_AUTO_TEST_CASE(for_statement)
|
||||
BOOST_CHECK(successAssemble("{ let x := calldatasize() for { let i := 0} lt(i, x) { i := add(i, 1) } { mstore(i, 2) } }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(if_statement)
|
||||
{
|
||||
BOOST_CHECK(successAssemble("{ if 1 {} }"));
|
||||
BOOST_CHECK(successAssemble("{ let x := 0 if eq(calldatasize(), 0) { x := 1 } mstore(0, x) }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(large_constant)
|
||||
{
|
||||
auto source = R"({
|
||||
|
8
test/libyul/yulSyntaxTests/if_statement.yul
Normal file
8
test/libyul/yulSyntaxTests/if_statement.yul
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
{ if 42 {} }
|
||||
{ if 42 { let x := 3 } }
|
||||
{ function f() -> x {} if f() { pop(f()) } }
|
||||
{ let x := 0 if eq(calldatasize(), 0) { x := 1 } mstore(0, x) }
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
5
test/libyul/yulSyntaxTests/if_statement_invalid_1.yul
Normal file
5
test/libyul/yulSyntaxTests/if_statement_invalid_1.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
if mload {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (15-16): Expected '(' but got '{'
|
7
test/libyul/yulSyntaxTests/if_statement_invalid_2.yul
Normal file
7
test/libyul/yulSyntaxTests/if_statement_invalid_2.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
if mstore(1, 1) {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
||||
// TypeError 3950: (6-18): Expected expression to evaluate to one value, but got 0 values instead.
|
7
test/libyul/yulSyntaxTests/if_statement_invalid_3.yul
Normal file
7
test/libyul/yulSyntaxTests/if_statement_invalid_3.yul
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
if 32 let x := 3
|
||||
}
|
||||
// ====
|
||||
// dialect: yul
|
||||
// ----
|
||||
// ParserError 2314: (12-15): Expected '{' but got reserved keyword 'let'
|
5
test/libyul/yulSyntaxTests/if_statement_invalid_4.yul
Normal file
5
test/libyul/yulSyntaxTests/if_statement_invalid_4.yul
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
if calldatasize {}
|
||||
}
|
||||
// ----
|
||||
// ParserError 2314: (22-23): Expected '(' but got '{'
|
6
test/libyul/yulSyntaxTests/if_statement_scope_1.yul
Normal file
6
test/libyul/yulSyntaxTests/if_statement_scope_1.yul
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
let x := 2
|
||||
if 42 { x := 3 }
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
8
test/libyul/yulSyntaxTests/if_statement_scope_2.yul
Normal file
8
test/libyul/yulSyntaxTests/if_statement_scope_2.yul
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
if 32 { let x := 3 }
|
||||
x := 2
|
||||
}
|
||||
// ====
|
||||
// dialect: evm
|
||||
// ----
|
||||
// DeclarationError 4634: (25-26): Variable not found or variable not lvalue.
|
Loading…
Reference in New Issue
Block a user