Extract yul syntax tests: switch statement

This commit is contained in:
Christian Parpart 2020-10-14 11:39:10 +02:00
parent c63265ff03
commit b1b2d3ef62
7 changed files with 51 additions and 18 deletions

View File

@ -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");

View File

@ -0,0 +1,8 @@
{
switch 0:u256
case 42:u256 {}
case 0x42:u256 {}
}
// ====
// dialect: evmTyped
// ----

View File

@ -0,0 +1,8 @@
{
switch 1:u256
case "1":u256 {}
case "2":u256 {}
}
// ====
// dialect: evmTyped
// ----

View File

@ -0,0 +1,9 @@
{
let x:u256
switch x
case "012345678901234567890123456789012":u256 {}
}
// ====
// dialect: evmTyped
// ----
// TypeError 3069: (30-70): String literal too long (33 > 32)

View File

@ -0,0 +1,8 @@
{
let x:u256
switch x
case "01234567890123456789012345678901":u256 {}
}
// ====
// dialect: evmTyped
// ----

View File

@ -0,0 +1,9 @@
{
switch 0:u256
case 0:u256 {}
case 0x0:u256 {}
}
// ====
// dialect: evmTyped
// ----
// DeclarationError 6792: (34-50): Duplicate case defined.

View File

@ -0,0 +1,9 @@
{
switch 0:u256
case 0:u256 {}
case "":u256 {}
}
// ====
// dialect: evmTyped
// ----
// DeclarationError 6792: (34-49): Duplicate case defined.