mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add tests
This commit is contained in:
parent
3451a30e5c
commit
fb46268982
@ -161,6 +161,11 @@ BOOST_AUTO_TEST_CASE(function_calls)
|
|||||||
BOOST_CHECK(successParse("{ function f(a:u256) -> b:u256 {} function g(a:u256, b:u256, c:u256) {} function x() { g(1:u256, 2:u256, f(mul(2:u256, 3:u256))) x() } }"));
|
BOOST_CHECK(successParse("{ function f(a:u256) -> b:u256 {} function g(a:u256, b:u256, c:u256) {} function x() { g(1:u256, 2:u256, f(mul(2:u256, 3:u256))) x() } }"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(tuple_assignment)
|
||||||
|
{
|
||||||
|
BOOST_CHECK(successParse("{ function f() -> a:u256, b:u256, c:u256 {} let x:u256, y:u256, z:u256 := f() }"));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(label)
|
BOOST_AUTO_TEST_CASE(label)
|
||||||
{
|
{
|
||||||
CHECK_ERROR("{ label: }", ParserError, "Labels are not supported.");
|
CHECK_ERROR("{ label: }", ParserError, "Labels are not supported.");
|
||||||
|
@ -161,6 +161,21 @@ BOOST_AUTO_TEST_CASE(vardecl)
|
|||||||
BOOST_CHECK(successParse("{ let x := 7 }"));
|
BOOST_CHECK(successParse("{ let x := 7 }"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(vardecl_name_clashes)
|
||||||
|
{
|
||||||
|
CHECK_PARSE_ERROR("{ let x := 1 let x := 2 }", DeclarationError, "Variable name x already taken in this scope.");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(vardecl_multi)
|
||||||
|
{
|
||||||
|
BOOST_CHECK(successParse("{ function f() -> x, y {} let x, y := f() }"));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(vardecl_multi_conflict)
|
||||||
|
{
|
||||||
|
CHECK_PARSE_ERROR("{ function f() -> x, y {} let x, x := f() }", DeclarationError, "Variable name x already taken in this scope.");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(vardecl_bool)
|
BOOST_AUTO_TEST_CASE(vardecl_bool)
|
||||||
{
|
{
|
||||||
CHECK_PARSE_ERROR("{ let x := true }", ParserError, "True and false are not valid literals.");
|
CHECK_PARSE_ERROR("{ let x := true }", ParserError, "True and false are not valid literals.");
|
||||||
@ -249,6 +264,12 @@ BOOST_AUTO_TEST_CASE(variable_access_cross_functions)
|
|||||||
CHECK_PARSE_ERROR("{ let x := 2 function g() { x pop } }", DeclarationError, "Identifier not found.");
|
CHECK_PARSE_ERROR("{ let x := 2 function g() { x pop } }", DeclarationError, "Identifier not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(invalid_tuple_assignment)
|
||||||
|
{
|
||||||
|
/// The push(42) is added here to silence the unbalanced stack error, so that there's only one error reported.
|
||||||
|
CHECK_PARSE_ERROR("{ 42 let x, y := 1 }", DeclarationError, "Variable count mismatch.");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(Printing)
|
BOOST_AUTO_TEST_SUITE(Printing)
|
||||||
@ -283,6 +304,11 @@ BOOST_AUTO_TEST_CASE(print_assignments)
|
|||||||
parsePrintCompare("{\n let x := mul(2, 3)\n 7\n =: x\n x := add(1, 2)\n}");
|
parsePrintCompare("{\n let x := mul(2, 3)\n 7\n =: x\n x := add(1, 2)\n}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(print_multi_assignments)
|
||||||
|
{
|
||||||
|
parsePrintCompare("{\n function f() -> x, y\n {\n }\n let x, y := f()\n}");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(print_string_literals)
|
BOOST_AUTO_TEST_CASE(print_string_literals)
|
||||||
{
|
{
|
||||||
parsePrintCompare("{\n \"\\n'\\xab\\x95\\\"\"\n pop\n}");
|
parsePrintCompare("{\n \"\\n'\\xab\\x95\\\"\"\n pop\n}");
|
||||||
|
Loading…
Reference in New Issue
Block a user