aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-05-06 22:49:22 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-05-23 17:24:19 +0800
commitfb46268982f9c19f15e01f0ee50764c58bb351d4 (patch)
treef71af087d97b991da73b7d9e80b471c9ed037968 /test/libsolidity
parent3451a30e5cd6d8bceedba70bf9c5012f263b3ec8 (diff)
downloaddexon-solidity-fb46268982f9c19f15e01f0ee50764c58bb351d4.tar.gz
dexon-solidity-fb46268982f9c19f15e01f0ee50764c58bb351d4.tar.zst
dexon-solidity-fb46268982f9c19f15e01f0ee50764c58bb351d4.zip
Add tests
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/InlineAssembly.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp
index 0729c8db..f155cba7 100644
--- a/test/libsolidity/InlineAssembly.cpp
+++ b/test/libsolidity/InlineAssembly.cpp
@@ -161,6 +161,21 @@ BOOST_AUTO_TEST_CASE(vardecl)
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)
{
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.");
}
+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(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}");
}
+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)
{
parsePrintCompare("{\n \"\\n'\\xab\\x95\\\"\"\n pop\n}");