mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Extract yul syntax tests: if statement
This commit is contained in:
parent
bc97c3e1ce
commit
2accbbe251
@ -158,13 +158,6 @@ BOOST_AUTO_TEST_CASE(multiple_assignment)
|
|||||||
BOOST_CHECK(successParse(text));
|
BOOST_CHECK(successParse(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(if_statement)
|
|
||||||
{
|
|
||||||
BOOST_CHECK(successParse("{ if true:bool {} }"));
|
|
||||||
BOOST_CHECK(successParse("{ if false:bool { let x:u256 := 3:u256 } }"));
|
|
||||||
BOOST_CHECK(successParse("{ function f() -> x:bool {} if f() { let b:bool := f() } }"));
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(break_outside_of_for_loop)
|
BOOST_AUTO_TEST_CASE(break_outside_of_for_loop)
|
||||||
{
|
{
|
||||||
CHECK_ERROR_DIALECT(
|
CHECK_ERROR_DIALECT(
|
||||||
@ -338,13 +331,6 @@ BOOST_AUTO_TEST_CASE(function_defined_in_init_nested)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(if_statement_invalid)
|
|
||||||
{
|
|
||||||
CHECK_ERROR("{ if let x:u256 {} }", ParserError, "Literal or identifier expected.");
|
|
||||||
CHECK_ERROR("{ if true:bool let x:u256 := 3:u256 }", ParserError, "Expected '{' but got reserved keyword 'let'");
|
|
||||||
CHECK_ERROR("{ if 42:u256 { } }", TypeError, "Expected a value of boolean type");
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(switch_duplicate_case)
|
BOOST_AUTO_TEST_CASE(switch_duplicate_case)
|
||||||
{
|
{
|
||||||
CHECK_ERROR("{ switch 0:u256 case 0:u256 {} case 0x0:u256 {} }", DeclarationError, "Duplicate case defined.");
|
CHECK_ERROR("{ switch 0:u256 case 0:u256 {} case 0x0:u256 {} }", DeclarationError, "Duplicate case defined.");
|
||||||
|
6
test/libyul/yulSyntaxTests/if_statement_1.yul
Normal file
6
test/libyul/yulSyntaxTests/if_statement_1.yul
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
if true:bool {}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// dialect: evmTyped
|
||||||
|
// ----
|
9
test/libyul/yulSyntaxTests/if_statement_2.yul
Normal file
9
test/libyul/yulSyntaxTests/if_statement_2.yul
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
if false:bool
|
||||||
|
{
|
||||||
|
let x:u256 := 3:u256
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// dialect: evmTyped
|
||||||
|
// ----
|
11
test/libyul/yulSyntaxTests/if_statement_3.yul
Normal file
11
test/libyul/yulSyntaxTests/if_statement_3.yul
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
function f() -> x:bool {}
|
||||||
|
|
||||||
|
if f()
|
||||||
|
{
|
||||||
|
let b:bool := f()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// dialect: evmTyped
|
||||||
|
// ----
|
5
test/libyul/yulSyntaxTests/if_statement_fail_1.yul
Normal file
5
test/libyul/yulSyntaxTests/if_statement_fail_1.yul
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{ if let x:u256 {} }
|
||||||
|
// ====
|
||||||
|
// dialect: evmTyped
|
||||||
|
// ----
|
||||||
|
// ParserError 1856: (5-8): Literal or identifier expected.
|
5
test/libyul/yulSyntaxTests/if_statement_fail_2.yul
Normal file
5
test/libyul/yulSyntaxTests/if_statement_fail_2.yul
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{ if true:bool let x:u256 := 3:u256 }
|
||||||
|
// ====
|
||||||
|
// dialect: evmTyped
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (15-18): Expected '{' but got reserved keyword 'let'
|
5
test/libyul/yulSyntaxTests/if_statement_fail_3.yul
Normal file
5
test/libyul/yulSyntaxTests/if_statement_fail_3.yul
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{ if 42:u256 { } }
|
||||||
|
// ====
|
||||||
|
// dialect: evmTyped
|
||||||
|
// ----
|
||||||
|
// TypeError 1733: (5-12): Expected a value of boolean type "bool" but got "u256"
|
Loading…
Reference in New Issue
Block a user