mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Extract yul syntax tests: switch statement
This commit is contained in:
parent
c63265ff03
commit
b1b2d3ef62
@ -192,24 +192,6 @@ BOOST_AUTO_TEST_CASE(function_defined_in_init_nested)
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(switch_duplicate_case)
|
||||
{
|
||||
CHECK_ERROR("{ switch 0:u256 case 0:u256 {} case 0x0:u256 {} }", DeclarationError, "Duplicate case defined.");
|
||||
BOOST_CHECK(successParse("{ switch 0:u256 case 42:u256 {} case 0x42:u256 {} }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(switch_duplicate_case_different_literal)
|
||||
{
|
||||
CHECK_ERROR("{ switch 0:u256 case 0:u256 {} case \"\":u256 {} }", DeclarationError, "Duplicate case defined.");
|
||||
BOOST_CHECK(successParse("{ switch 1:u256 case \"1\":u256 {} case \"2\":u256 {} }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(switch_case_string_literal_too_long)
|
||||
{
|
||||
BOOST_CHECK(successParse("{let x:u256 switch x case \"01234567890123456789012345678901\":u256 {}}"));
|
||||
CHECK_ERROR("{let x:u256 switch x case \"012345678901234567890123456789012\":u256 {}}", TypeError, "String literal too long (33 > 32)");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_shadowing_outside_vars)
|
||||
{
|
||||
CHECK_ERROR("{ let x:u256 function f() -> x:u256 {} }", DeclarationError, "already taken in this scope");
|
||||
|
8
test/libyul/yulSyntaxTests/switch_case.yul
Normal file
8
test/libyul/yulSyntaxTests/switch_case.yul
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
switch 0:u256
|
||||
case 42:u256 {}
|
||||
case 0x42:u256 {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
switch 1:u256
|
||||
case "1":u256 {}
|
||||
case "2":u256 {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
let x:u256
|
||||
switch x
|
||||
case "012345678901234567890123456789012":u256 {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// TypeError 3069: (30-70): String literal too long (33 > 32)
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
let x:u256
|
||||
switch x
|
||||
case "01234567890123456789012345678901":u256 {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
9
test/libyul/yulSyntaxTests/switch_duplicate_case.yul
Normal file
9
test/libyul/yulSyntaxTests/switch_duplicate_case.yul
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
switch 0:u256
|
||||
case 0:u256 {}
|
||||
case 0x0:u256 {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// DeclarationError 6792: (34-50): Duplicate case defined.
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
switch 0:u256
|
||||
case 0:u256 {}
|
||||
case "":u256 {}
|
||||
}
|
||||
// ====
|
||||
// dialect: evmTyped
|
||||
// ----
|
||||
// DeclarationError 6792: (34-49): Duplicate case defined.
|
Loading…
Reference in New Issue
Block a user