aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/ABIDecoderTests.cpp2
-rw-r--r--test/libsolidity/SMTChecker.cpp29
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp63
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp211
-rw-r--r--test/libsolidity/SolidityOptimizer.cpp2
-rw-r--r--test/libsolidity/SolidityParser.cpp642
-rw-r--r--test/libsolidity/SolidityTypes.cpp27
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol9
-rw-r--r--test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol17
-rw-r--r--test/libsolidity/syntaxTests/parsing/arrays_in_events.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol8
-rw-r--r--test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/calling_function.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_multiple.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol13
-rw-r--r--test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol14
-rw-r--r--test/libsolidity/syntaxTests/parsing/declaring_fixed_literal_variables.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/else_if_statement.sol8
-rw-r--r--test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol10
-rw-r--r--test/libsolidity/syntaxTests/parsing/event.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/event_arguments.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/exp_expression.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/external_function.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/fallback_function.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol13
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol13
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol12
-rw-r--r--test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_normal_comments.sol10
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_as_parameter.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol10
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol15
-rw-r--r--test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/if_statement.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/library_simple.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol16
-rw-r--r--test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol10
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol12
-rw-r--r--test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/mapping.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/modifier.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/modifier_arguments.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/modifier_invocation.sol8
-rw-r--r--test/libsolidity/syntaxTests/parsing/multi_arrays.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol28
-rw-r--r--test/libsolidity/syntaxTests/parsing/multiple_modifier_arg_trailing_comma.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol5
-rw-r--r--test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol11
-rw-r--r--test/libsolidity/syntaxTests/parsing/struct_definition.sol7
-rw-r--r--test/libsolidity/syntaxTests/parsing/two_exact_functions.sol9
-rw-r--r--test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol17
-rw-r--r--test/libsolidity/syntaxTests/parsing/while_loop.sol9
-rw-r--r--test/libsolidity/syntaxTests/types/bool_ops.sol53
-rw-r--r--test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/bytes_to_contract.sol4
-rw-r--r--test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol20
-rw-r--r--test/libsolidity/syntaxTests/types/index_access_for_bytes.sol6
-rw-r--r--test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol7
-rw-r--r--test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol7
71 files changed, 703 insertions, 868 deletions
diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp
index beb7b5af..b3ebb7a5 100644
--- a/test/libsolidity/ABIDecoderTests.cpp
+++ b/test/libsolidity/ABIDecoderTests.cpp
@@ -579,7 +579,7 @@ BOOST_AUTO_TEST_CASE(struct_simple)
a = s.a;
b = s.b;
c = s.c;
- d = uint(s.d);
+ d = uint16(s.d);
}
}
)";
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp
index 71fdb906..ec23f452 100644
--- a/test/libsolidity/SMTChecker.cpp
+++ b/test/libsolidity/SMTChecker.cpp
@@ -388,35 +388,6 @@ BOOST_AUTO_TEST_CASE(bool_simple)
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f(bool x) public pure {
- bool y;
- assert(x <= y);
- }
- }
- )";
- CHECK_WARNING(text, "Assertion violation happens here");
- text = R"(
- contract C {
- function f(bool x) public pure {
- bool y;
- assert(x >= y);
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f(bool x) public pure {
- require(x);
- bool y;
- assert(x > y);
- assert(y < x);
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
}
BOOST_AUTO_TEST_CASE(bool_int_mixed)
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index d00b174c..40962294 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -483,6 +483,27 @@ BOOST_AUTO_TEST_CASE(do_while_loop)
testContractAgainstCppOnRange("f(uint256)", do_while_loop_cpp, 0, 5);
}
+BOOST_AUTO_TEST_CASE(do_while_loop_continue)
+{
+ char const* sourceCode = R"(
+ contract test {
+ function f() public pure returns(uint r) {
+ uint i = 0;
+ do
+ {
+ if (i > 0) return 0;
+ i++;
+ continue;
+ } while (false);
+ return 42;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(42));
+}
+
BOOST_AUTO_TEST_CASE(nested_loops)
{
// tests that break and continue statements in nested loops jump to the correct place
@@ -1668,7 +1689,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_smaller_size)
char const* sourceCode = R"(
contract Test {
function bytesToUint(bytes4 s) returns (uint16 h) {
- return uint16(s);
+ return uint16(uint32(s));
}
}
)";
@@ -1684,7 +1705,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_greater_size)
char const* sourceCode = R"(
contract Test {
function bytesToUint(bytes4 s) returns (uint64 h) {
- return uint64(s);
+ return uint64(uint32(s));
}
}
)";
@@ -1731,7 +1752,7 @@ BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_smaller_size)
char const* sourceCode = R"(
contract Test {
function uintToBytes(uint32 h) returns (bytes2 s) {
- return bytes2(h);
+ return bytes2(uint16(h));
}
}
)";
@@ -1747,7 +1768,7 @@ BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_greater_size)
char const* sourceCode = R"(
contract Test {
function UintToBytes(uint16 h) returns (bytes8 s) {
- return bytes8(h);
+ return bytes8(uint64(h));
}
}
)";
@@ -3138,7 +3159,7 @@ BOOST_AUTO_TEST_CASE(event)
function deposit(bytes32 _id, bool _manually) payable {
if (_manually) {
bytes32 s = 0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f;
- log3(bytes32(msg.value), s, bytes32(msg.sender), _id);
+ log3(bytes32(msg.value), s, bytes32(uint256(msg.sender)), _id);
} else {
Deposit(msg.sender, _id, msg.value);
}
@@ -3535,7 +3556,7 @@ BOOST_AUTO_TEST_CASE(event_indexed_string)
event E(string indexed r, uint[4] indexed t);
function deposit() {
bytes(x).length = 90;
- for (uint i = 0; i < 90; i++)
+ for (uint8 i = 0; i < 90; i++)
bytes(x)[i] = byte(i);
y[0] = 4;
y[1] = 5;
@@ -4767,7 +4788,7 @@ BOOST_AUTO_TEST_CASE(array_copy_different_packing)
function test() returns (bytes10 a, bytes10 b, bytes10 c, bytes10 d, bytes10 e) {
data1.length = 9;
for (uint i = 0; i < data1.length; ++i)
- data1[i] = bytes8(i);
+ data1[i] = bytes8(uint64(i));
data2 = data1;
a = data2[1];
b = data2[2];
@@ -4795,7 +4816,7 @@ BOOST_AUTO_TEST_CASE(array_copy_target_simple)
bytes17[10] data2; // 1 per slot, no offset counter
function test() returns (bytes17 a, bytes17 b, bytes17 c, bytes17 d, bytes17 e) {
for (uint i = 0; i < data1.length; ++i)
- data1[i] = bytes8(i);
+ data1[i] = bytes8(uint64(i));
data2[8] = data2[9] = 2;
data2 = data1;
a = data2[1];
@@ -4827,14 +4848,14 @@ BOOST_AUTO_TEST_CASE(array_copy_target_leftover)
uint i;
for (i = 0; i < data2.length; ++i)
data2[i] = 0xffff;
- check = uint(data2[31]) * 0x10000 | uint(data2[14]);
+ check = uint(uint16(data2[31])) * 0x10000 | uint(uint16(data2[14]));
for (i = 0; i < data1.length; ++i)
data1[i] = byte(uint8(1 + i));
data2 = data1;
for (i = 0; i < 16; ++i)
- res1 |= uint(data2[i]) * 0x10000**i;
+ res1 |= uint(uint16(data2[i])) * 0x10000**i;
for (i = 0; i < 16; ++i)
- res2 |= uint(data2[16 + i]) * 0x10000**i;
+ res2 |= uint(uint16(data2[16 + i])) * 0x10000**i;
}
}
)";
@@ -4860,7 +4881,7 @@ BOOST_AUTO_TEST_CASE(array_copy_target_leftover2)
data1[2] = 3;
data1[3] = 4;
for (uint i = 0; i < data2.length; ++i)
- data2[i] = bytes10(0xffff00 | (1 + i));
+ data2[i] = bytes10(uint80(0xffff00 | (1 + i)));
data2 = data1;
r1 = data2[3];
r2 = data2[4];
@@ -5074,7 +5095,7 @@ BOOST_AUTO_TEST_CASE(byte_array_push_transition)
contract c {
bytes data;
function test() returns (uint) {
- for (uint i = 1; i < 40; i++)
+ for (uint8 i = 1; i < 40; i++)
{
data.push(byte(i));
if (data.length != i) return 0x1000 + i;
@@ -5120,11 +5141,11 @@ BOOST_AUTO_TEST_CASE(bytes_index_access)
contract c {
bytes data;
function direct(bytes arg, uint index) external returns (uint) {
- return uint(arg[index]);
+ return uint(uint8(arg[index]));
}
function storageCopyRead(bytes arg, uint index) external returns (uint) {
data = arg;
- return uint(data[index]);
+ return uint(uint8(data[index]));
}
function storageWrite() external returns (uint) {
data.length = 35;
@@ -5135,7 +5156,7 @@ BOOST_AUTO_TEST_CASE(bytes_index_access)
data[31] |= 8;
data[30] = 1;
data[32] = 3;
- return uint(data[30]) * 0x100 | uint(data[31]) * 0x10 | uint(data[32]);
+ return uint(uint8(data[30])) * 0x100 | uint(uint8(data[31])) * 0x10 | uint(uint8(data[32]));
}
}
)";
@@ -5158,7 +5179,7 @@ BOOST_AUTO_TEST_CASE(bytes_delete_element)
function test1() external returns (bool) {
data.length = 100;
for (uint i = 0; i < data.length; i++)
- data[i] = byte(i);
+ data[i] = byte(uint8(i));
delete data[94];
delete data[96];
delete data[98];
@@ -7517,7 +7538,7 @@ BOOST_AUTO_TEST_CASE(short_strings)
if (data1[0] != "1") return 10;
if (data1[4] != "4") return 11;
for (uint i = 0; i < data1.length; i ++)
- data1[i] = byte(i * 3);
+ data1[i] = byte(uint8(i * 3));
if (data1[4] != 4 * 3) return 12;
if (data1[67] != 67 * 3) return 13;
// change length: long -> short
@@ -8333,7 +8354,7 @@ BOOST_AUTO_TEST_CASE(fixed_bytes_index_access)
function g(bytes32 x) returns (uint) {
data = [x[0], x[1], x[2]];
data[0] = "12345";
- return uint(data[0][4]);
+ return uint(uint8(data[0][4]));
}
}
)";
@@ -8391,7 +8412,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_memory_access)
function test() returns (bytes) {
bytes memory x = new bytes(5);
for (uint i = 0; i < x.length; ++i)
- x[i] = byte(i + 1);
+ x[i] = byte(uint8(i + 1));
assembly { mstore(add(x, 32), "12345678901234567890123456789012") }
return x;
}
@@ -8911,7 +8932,7 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types)
function f(bytes2 a, uint16 x) returns (uint) {
if (a != "ab") return 1;
if (x != 0x0102) return 2;
- if (bytes3(x) != 0x0102) return 3;
+ if (bytes3(uint24(x)) != 0x0102) return 3;
return 0;
}
}
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 5af67659..ab7cfb12 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -472,9 +472,9 @@ BOOST_AUTO_TEST_CASE(function_external_types)
BOOST_AUTO_TEST_CASE(enum_external_type)
{
- // bug #1801
SourceUnit const* sourceUnit = nullptr;
char const* text = R"(
+ // test for bug #1801
contract Test {
enum ActionChoices { GoLeft, GoRight, GoStraight, Sit }
function boo(ActionChoices enumArg) external returns (uint ret) {
@@ -977,8 +977,8 @@ BOOST_AUTO_TEST_CASE(private_state_variable)
BOOST_AUTO_TEST_CASE(base_class_state_variable_accessor)
{
- // test for issue #1126 https://github.com/ethereum/cpp-ethereum/issues/1126
char const* text = R"(
+ // test for issue #1126 https://github.com/ethereum/cpp-ethereum/issues/1126
contract Parent {
uint256 public m_aMember;
}
@@ -2086,115 +2086,6 @@ BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_string)
CHECK_ERROR(text, TypeError, "Type literal_string \"abc\" is not implicitly convertible to expected type uint256.");
}
-BOOST_AUTO_TEST_CASE(test_fromElementaryTypeName)
-{
-
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Int, 0, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 8, 0)) == *make_shared<IntegerType>(8, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 16, 0)) == *make_shared<IntegerType>(16, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 24, 0)) == *make_shared<IntegerType>(24, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 32, 0)) == *make_shared<IntegerType>(32, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 40, 0)) == *make_shared<IntegerType>(40, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 48, 0)) == *make_shared<IntegerType>(48, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 56, 0)) == *make_shared<IntegerType>(56, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 64, 0)) == *make_shared<IntegerType>(64, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 72, 0)) == *make_shared<IntegerType>(72, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 80, 0)) == *make_shared<IntegerType>(80, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 88, 0)) == *make_shared<IntegerType>(88, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 96, 0)) == *make_shared<IntegerType>(96, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 104, 0)) == *make_shared<IntegerType>(104, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 112, 0)) == *make_shared<IntegerType>(112, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 120, 0)) == *make_shared<IntegerType>(120, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 128, 0)) == *make_shared<IntegerType>(128, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 136, 0)) == *make_shared<IntegerType>(136, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 144, 0)) == *make_shared<IntegerType>(144, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 152, 0)) == *make_shared<IntegerType>(152, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 160, 0)) == *make_shared<IntegerType>(160, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 168, 0)) == *make_shared<IntegerType>(168, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 176, 0)) == *make_shared<IntegerType>(176, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 184, 0)) == *make_shared<IntegerType>(184, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 192, 0)) == *make_shared<IntegerType>(192, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 200, 0)) == *make_shared<IntegerType>(200, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 208, 0)) == *make_shared<IntegerType>(208, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 216, 0)) == *make_shared<IntegerType>(216, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 224, 0)) == *make_shared<IntegerType>(224, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 232, 0)) == *make_shared<IntegerType>(232, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 240, 0)) == *make_shared<IntegerType>(240, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 248, 0)) == *make_shared<IntegerType>(248, IntegerType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, 256, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Signed));
-
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UInt, 0, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 8, 0)) == *make_shared<IntegerType>(8, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 16, 0)) == *make_shared<IntegerType>(16, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 24, 0)) == *make_shared<IntegerType>(24, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 32, 0)) == *make_shared<IntegerType>(32, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 40, 0)) == *make_shared<IntegerType>(40, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 48, 0)) == *make_shared<IntegerType>(48, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 56, 0)) == *make_shared<IntegerType>(56, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 64, 0)) == *make_shared<IntegerType>(64, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 72, 0)) == *make_shared<IntegerType>(72, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 80, 0)) == *make_shared<IntegerType>(80, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 88, 0)) == *make_shared<IntegerType>(88, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 96, 0)) == *make_shared<IntegerType>(96, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 104, 0)) == *make_shared<IntegerType>(104, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 112, 0)) == *make_shared<IntegerType>(112, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 120, 0)) == *make_shared<IntegerType>(120, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 128, 0)) == *make_shared<IntegerType>(128, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 136, 0)) == *make_shared<IntegerType>(136, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 144, 0)) == *make_shared<IntegerType>(144, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 152, 0)) == *make_shared<IntegerType>(152, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 160, 0)) == *make_shared<IntegerType>(160, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 168, 0)) == *make_shared<IntegerType>(168, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 176, 0)) == *make_shared<IntegerType>(176, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 184, 0)) == *make_shared<IntegerType>(184, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 192, 0)) == *make_shared<IntegerType>(192, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 200, 0)) == *make_shared<IntegerType>(200, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 208, 0)) == *make_shared<IntegerType>(208, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 216, 0)) == *make_shared<IntegerType>(216, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 224, 0)) == *make_shared<IntegerType>(224, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 232, 0)) == *make_shared<IntegerType>(232, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 240, 0)) == *make_shared<IntegerType>(240, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 248, 0)) == *make_shared<IntegerType>(248, IntegerType::Modifier::Unsigned));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, 256, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Unsigned));
-
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Byte, 0, 0)) == *make_shared<FixedBytesType>(1));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 1, 0)) == *make_shared<FixedBytesType>(1));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 2, 0)) == *make_shared<FixedBytesType>(2));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 3, 0)) == *make_shared<FixedBytesType>(3));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 4, 0)) == *make_shared<FixedBytesType>(4));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 5, 0)) == *make_shared<FixedBytesType>(5));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 6, 0)) == *make_shared<FixedBytesType>(6));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 7, 0)) == *make_shared<FixedBytesType>(7));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 8, 0)) == *make_shared<FixedBytesType>(8));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 9, 0)) == *make_shared<FixedBytesType>(9));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 10, 0)) == *make_shared<FixedBytesType>(10));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 11, 0)) == *make_shared<FixedBytesType>(11));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 12, 0)) == *make_shared<FixedBytesType>(12));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 13, 0)) == *make_shared<FixedBytesType>(13));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 14, 0)) == *make_shared<FixedBytesType>(14));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 15, 0)) == *make_shared<FixedBytesType>(15));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 16, 0)) == *make_shared<FixedBytesType>(16));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 17, 0)) == *make_shared<FixedBytesType>(17));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 18, 0)) == *make_shared<FixedBytesType>(18));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 19, 0)) == *make_shared<FixedBytesType>(19));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 20, 0)) == *make_shared<FixedBytesType>(20));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 21, 0)) == *make_shared<FixedBytesType>(21));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 22, 0)) == *make_shared<FixedBytesType>(22));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 23, 0)) == *make_shared<FixedBytesType>(23));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 24, 0)) == *make_shared<FixedBytesType>(24));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 25, 0)) == *make_shared<FixedBytesType>(25));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 26, 0)) == *make_shared<FixedBytesType>(26));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 27, 0)) == *make_shared<FixedBytesType>(27));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 28, 0)) == *make_shared<FixedBytesType>(28));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 29, 0)) == *make_shared<FixedBytesType>(29));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 30, 0)) == *make_shared<FixedBytesType>(30));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 31, 0)) == *make_shared<FixedBytesType>(31));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, 32, 0)) == *make_shared<FixedBytesType>(32));
-
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Fixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Signed));
- BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UFixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Unsigned));
-}
-
BOOST_AUTO_TEST_CASE(test_byte_is_alias_of_byte1)
{
char const* text = R"(
@@ -2275,13 +2166,12 @@ BOOST_AUTO_TEST_CASE(constant_string_literal_disallows_assignment)
contract Test {
string constant x = "abefghijklmnopqabcdefghijklmnopqabcdefghijklmnopqabca";
function f() public {
+ // Even if this is made possible in the future, we should not allow assignment
+ // to elements of constant arrays.
x[0] = "f";
}
}
)";
-
- // Even if this is made possible in the future, we should not allow assignment
- // to elements of constant arrays.
CHECK_ERROR(text, TypeError, "Index access for string is not possible.");
}
@@ -2382,11 +2272,11 @@ BOOST_AUTO_TEST_CASE(overloaded_function_cannot_resolve)
BOOST_AUTO_TEST_CASE(ambiguous_overloaded_function)
{
- // literal 1 can be both converted to uint and uint8, so the call is ambiguous.
char const* sourceCode = R"(
contract test {
function f(uint8 a) public returns (uint) { return a; }
- function f(uint a) public returns (uint) { return 2*a; }
+ function f(uint a) public returns (uint) { return 2 * a; }
+ // literal 1 can be both converted to uint and uint8, so the call is ambiguous.
function g() public returns (uint) { return f(1); }
}
)";
@@ -2809,12 +2699,12 @@ BOOST_AUTO_TEST_CASE(function_argument_storage_to_mem)
BOOST_AUTO_TEST_CASE(mem_array_assignment_changes_base_type)
{
- // Such an assignment is possible in storage, but not in memory
- // (because it would incur an otherwise unnecessary copy).
- // This requirement might be lifted, though.
char const* sourceCode = R"(
contract C {
function f(uint8[] memory x) private {
+ // Such an assignment is possible in storage, but not in memory
+ // (because it would incur an otherwise unnecessary copy).
+ // This requirement might be lifted, though.
uint[] memory y = x;
}
}
@@ -3358,13 +3248,13 @@ BOOST_AUTO_TEST_CASE(using_for_mismatch)
BOOST_AUTO_TEST_CASE(using_for_not_used)
{
- // This is an error because the function is only bound to uint.
- // Had it been bound to *, it would have worked.
char const* text = R"(
library D { function double(uint self) public returns (uint) { return 2; } }
contract C {
using D for uint;
function f(uint16 a) public returns (uint) {
+ // This is an error because the function is only bound to uint.
+ // Had it been bound to *, it would have worked.
return a.double();
}
}
@@ -3386,12 +3276,12 @@ BOOST_AUTO_TEST_CASE(library_memory_struct)
BOOST_AUTO_TEST_CASE(using_for_arbitrary_mismatch)
{
- // Bound to a, but self type does not match.
char const* text = R"(
library D { function double(bytes32 self) public returns (uint) { return 2; } }
contract C {
using D for *;
function f(uint a) public returns (uint) {
+ // Bound to a, but self type does not match.
return a.double();
}
}
@@ -3859,19 +3749,6 @@ BOOST_AUTO_TEST_CASE(conditional_with_all_types)
CHECK_SUCCESS(text);
}
-BOOST_AUTO_TEST_CASE(index_access_for_bytes)
-{
- char const* text = R"(
- contract C {
- bytes20 x;
- function f(bytes16 b) public {
- b[uint(x[2])];
- }
- }
- )";
- CHECK_SUCCESS(text);
-}
-
BOOST_AUTO_TEST_CASE(uint7_and_uintM_as_identifier)
{
char const* text = R"(
@@ -4769,20 +4646,19 @@ BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable)
BOOST_AUTO_TEST_CASE(function_variable_mixin)
{
- // bug #1798 (cpp-ethereum), related to #1286 (solidity)
- char const* text = R"(
- contract attribute {
- bool ok = false;
- }
- contract func {
- function ok() public returns (bool) { return true; }
- }
-
- contract attr_func is attribute, func {
- function checkOk() public returns (bool) { return ok(); }
- }
- )";
- CHECK_ERROR(text, DeclarationError, "Identifier already declared.");
+ char const* text = R"(
+ // bug #1798 (cpp-ethereum), related to #1286 (solidity)
+ contract attribute {
+ bool ok = false;
+ }
+ contract func {
+ function ok() public returns (bool) { return true; }
+ }
+ contract attr_func is attribute, func {
+ function checkOk() public returns (bool) { return ok(); }
+ }
+ )";
+ CHECK_ERROR(text, DeclarationError, "Identifier already declared.");
}
BOOST_AUTO_TEST_CASE(calling_payable)
@@ -5492,14 +5368,15 @@ BOOST_AUTO_TEST_CASE(invalid_address_length_long)
BOOST_AUTO_TEST_CASE(address_test_for_bug_in_implementation)
{
- // A previous implementation claimed the string would be an address
char const* text = R"(
+ // A previous implementation claimed the string would be an address
contract AddrString {
address public test = "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c";
}
)";
CHECK_ERROR(text, TypeError, "is not implicitly convertible to expected type address");
text = R"(
+ // A previous implementation claimed the string would be an address
contract AddrString {
function f() public returns (address) {
return "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c";
@@ -5511,8 +5388,8 @@ BOOST_AUTO_TEST_CASE(address_test_for_bug_in_implementation)
BOOST_AUTO_TEST_CASE(early_exit_on_fatal_errors)
{
- // This tests a crash that occured because we did not stop for fatal errors.
char const* text = R"(
+ // This tests a crash that occured because we did not stop for fatal errors.
contract C {
struct S {
ftring a;
@@ -6059,9 +5936,10 @@ BOOST_AUTO_TEST_CASE(callable_crash)
BOOST_AUTO_TEST_CASE(error_transfer_non_payable_fallback)
{
- // This used to be a test for a.transfer to generate a warning
- // because A's fallback function is not payable.
char const* text = R"(
+ // This used to be a test for a.transfer to generate a warning
+ // because A's fallback function is not payable.
+
contract A {
function() public {}
}
@@ -6082,9 +5960,10 @@ BOOST_AUTO_TEST_CASE(error_transfer_non_payable_fallback)
BOOST_AUTO_TEST_CASE(error_transfer_no_fallback)
{
- // This used to be a test for a.transfer to generate a warning
- // because A does not have a payable fallback function.
- std::string text = R"(
+ char const* text = R"(
+ // This used to be a test for a.transfer to generate a warning
+ // because A does not have a payable fallback function.
+
contract A {}
contract B {
@@ -6103,9 +5982,10 @@ BOOST_AUTO_TEST_CASE(error_transfer_no_fallback)
BOOST_AUTO_TEST_CASE(error_send_non_payable_fallback)
{
- // This used to be a test for a.send to generate a warning
- // because A does not have a payable fallback function.
- std::string text = R"(
+ char const* text = R"(
+ // This used to be a test for a.send to generate a warning
+ // because A does not have a payable fallback function.
+
contract A {
function() public {}
}
@@ -6126,9 +6006,10 @@ BOOST_AUTO_TEST_CASE(error_send_non_payable_fallback)
BOOST_AUTO_TEST_CASE(does_not_error_transfer_payable_fallback)
{
- // This used to be a test for a.transfer to generate a warning
- // because A does not have a payable fallback function.
char const* text = R"(
+ // This used to be a test for a.transfer to generate a warning
+ // because A does not have a payable fallback function.
+
contract A {
function() payable public {}
}
@@ -6428,8 +6309,8 @@ BOOST_AUTO_TEST_CASE(using_this_in_constructor)
BOOST_AUTO_TEST_CASE(do_not_crash_on_not_lvalue)
{
- // This checks for a bug that caused a crash because of continued analysis.
char const* text = R"(
+ // This checks for a bug that caused a crash because of continued analysis.
contract C {
mapping (uint => uint) m;
function f() public {
@@ -6635,8 +6516,8 @@ BOOST_AUTO_TEST_CASE(library_function_without_implementation)
BOOST_AUTO_TEST_CASE(using_for_with_non_library)
{
- // This tests a crash that was resolved by making the first error fatal.
char const* text = R"(
+ // This tests a crash that was resolved by making the first error fatal.
library L {
struct S { uint d; }
using S for S;
@@ -6858,7 +6739,7 @@ BOOST_AUTO_TEST_CASE(array_length_invalid_expression)
BOOST_AUTO_TEST_CASE(warn_about_address_members_on_contract)
{
- std::string text = R"(
+ char const* text = R"(
contract C {
function f() view public {
this.balance;
@@ -6919,7 +6800,7 @@ BOOST_AUTO_TEST_CASE(warn_about_address_members_on_contract)
BOOST_AUTO_TEST_CASE(warn_about_address_members_on_non_this_contract)
{
- std::string text = R"(
+ char const* text = R"(
contract C {
function f() view public {
C c;
diff --git a/test/libsolidity/SolidityOptimizer.cpp b/test/libsolidity/SolidityOptimizer.cpp
index afce1823..3a8585f7 100644
--- a/test/libsolidity/SolidityOptimizer.cpp
+++ b/test/libsolidity/SolidityOptimizer.cpp
@@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(array_copy)
data1[i] = msg.data[i];
data2 = data1;
l = data2.length;
- y = uint(data2[x]);
+ y = uint(uint40(data2[x]));
}
}
)";
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index e80b3394..0797b53b 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -112,52 +112,6 @@ while(0)
BOOST_AUTO_TEST_SUITE(SolidityParser)
-BOOST_AUTO_TEST_CASE(multiple_return_param_trailing_comma)
-{
- char const* text = R"(
- contract test {
- function() returns (uint a, uint b,) {}
- }
- )";
- CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
-}
-
-BOOST_AUTO_TEST_CASE(multiple_modifier_arg_trailing_comma)
-{
- char const* text = R"(
- contract test {
- modifier modTest(uint a, uint b,) { _; }
- function(uint a) {}
- }
- )";
- CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
-}
-
-BOOST_AUTO_TEST_CASE(multiple_event_arg_trailing_comma)
-{
- char const* text = R"(
- contract test {
- event Test(uint a, uint b,);
- function(uint a) {}
- }
- )";
- CHECK_PARSE_ERROR(text, "Unexpected trailing comma in parameter list.");
-}
-
-BOOST_AUTO_TEST_CASE(two_exact_functions)
-{
- char const* text = R"(
- contract test {
- function fun(uint a) returns(uint r) { return a; }
- function fun(uint a) returns(uint r) { return a; }
- }
- )";
- // with support of overloaded functions, during parsing,
- // we can't determine whether they match exactly, however
- // it will throw DeclarationError in following stage.
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(function_natspec_documentation)
{
char const* text = R"(
@@ -334,57 +288,6 @@ BOOST_AUTO_TEST_CASE(natspec_docstring_after_signature)
"Shouldn't get natspec docstring for this function");
}
-BOOST_AUTO_TEST_CASE(struct_definition)
-{
- char const* text = R"(
- contract test {
- uint256 stateVar;
- struct MyStructName {
- address addr;
- uint256 count;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(mapping)
-{
- char const* text = R"(
- contract test {
- mapping(address => bytes32) names;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(mapping_in_struct)
-{
- char const* text = R"(
- contract test {
- struct test_struct {
- address addr;
- uint256 count;
- mapping(bytes32 => test_struct) self_reference;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(mapping_to_mapping_in_struct)
-{
- char const* text = R"(
- contract test {
- struct test_struct {
- address addr;
- mapping (uint64 => mapping (bytes32 => uint)) complex_mapping;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(variable_definition)
{
char const* text = R"(
@@ -440,112 +343,6 @@ BOOST_AUTO_TEST_CASE(complex_expression)
BOOST_CHECK(successParse(text));
}
-BOOST_AUTO_TEST_CASE(exp_expression)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- uint256 x = 3 ** a;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(while_loop)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- while (true) { uint256 x = 1; break; continue; } x = 9;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(for_loop_vardef_initexpr)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- for (uint256 i = 0; i < 10; i++) {
- uint256 x = i; break; continue;
- }
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(for_loop_simple_initexpr)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- uint256 i =0;
- for (i = 0; i < 10; i++) {
- uint256 x = i; break; continue;
- }
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(for_loop_simple_noexpr)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- uint256 i =0;
- for (;;) {
- uint256 x = i; break; continue;
- }
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(for_loop_single_stmt_body)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- uint256 i = 0;
- for (i = 0; i < 10; i++)
- continue;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(if_statement)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) {
- if (a >= 8) { return 2; } else { var b = 7; }
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(else_if_statement)
-{
- char const* text = R"(
- contract test {
- function fun(uint256 a) returns (address b) {
- if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(statement_starting_with_type_conversion)
{
char const* text = R"(
@@ -673,108 +470,6 @@ BOOST_AUTO_TEST_CASE(contract_multiple_inheritance_with_arguments)
BOOST_CHECK(successParse(text));
}
-BOOST_AUTO_TEST_CASE(placeholder_in_function_context)
-{
- char const* text = R"(
- contract c {
- function fun() returns (uint r) {
- var _ = 8;
- return _ + 1;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(modifier)
-{
- char const* text = R"(
- contract c {
- modifier mod { if (msg.sender == 0) _; }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(modifier_arguments)
-{
- char const* text = R"(
- contract c {
- modifier mod(address a) { if (msg.sender == a) _; }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(modifier_invocation)
-{
- char const* text = R"(
- contract c {
- modifier mod1(uint a) { if (msg.sender == a) _; }
- modifier mod2 { if (msg.sender == 2) _; }
- function f() mod1(7) mod2 { }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(fallback_function)
-{
- char const* text = R"(
- contract c {
- function() { }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(event)
-{
- char const* text = R"(
- contract c {
- event e();
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(event_arguments)
-{
- char const* text = R"(
- contract c {
- event e(uint a, bytes32 s);
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(event_arguments_indexed)
-{
- char const* text = R"(
- contract c {
- event e(uint a, bytes32 indexed s, bool indexed b);
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(visibility_specifiers)
-{
- char const* text = R"(
- contract c {
- uint private a;
- uint internal b;
- uint public c;
- uint d;
- function f() {}
- function f_priv() private {}
- function f_public() public {}
- function f_internal() internal {}
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers)
{
char const* text = R"(
@@ -791,108 +486,6 @@ BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers)
CHECK_PARSE_ERROR(text, "Visibility already specified as \"private\".");
}
-BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations)
-{
- char const* text = R"(
- contract c {
- function c ()
- {
- a = 1 wei;
- b = 2 szabo;
- c = 3 finney;
- b = 4 ether;
- }
- uint256 a;
- uint256 b;
- uint256 c;
- uint256 d;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expressions)
-{
- char const* text = R"(
- contract c {
- function c ()
- {
- a = 1 wei * 100 wei + 7 szabo - 3;
- }
- uint256 a;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(enum_valid_declaration)
-{
- char const* text = R"(
- contract c {
- enum validEnum { Value1, Value2, Value3, Value4 }
- function c ()
- {
- a = foo.Value3;
- }
- uint256 a;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(external_function)
-{
- char const* text = R"(
- contract c {
- function x() external {}
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(arrays_in_storage)
-{
- char const* text = R"(
- contract c {
- uint[10] a;
- uint[] a2;
- struct x { uint[2**20] b; y[0] c; }
- struct y { uint d; mapping(uint=>x)[] e; }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(arrays_in_events)
-{
- char const* text = R"(
- contract c {
- event e(uint[10] a, bytes7[8] indexed b, c[3] x);
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(arrays_in_expressions)
-{
- char const* text = R"(
- contract c {
- function f() { c[10] a = 7; uint8[10 * 2] x; }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(multi_arrays)
-{
- char const* text = R"(
- contract c {
- mapping(uint => mapping(uint => int8)[8][][9])[] x;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(keyword_is_reserved)
{
auto keywords = {
@@ -923,39 +516,6 @@ BOOST_AUTO_TEST_CASE(keyword_is_reserved)
}
}
-BOOST_AUTO_TEST_CASE(location_specifiers_for_params)
-{
- char const* text = R"(
- contract Foo {
- function f(uint[] storage constant x, uint[] memory y) { }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(location_specifiers_for_locals)
-{
- char const* text = R"(
- contract Foo {
- function f() {
- uint[] storage x;
- uint[] memory y;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(library_simple)
-{
- char const* text = R"(
- library Lib {
- function f() { }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(member_access_parser_ambiguity)
{
char const* text = R"(
@@ -1000,97 +560,6 @@ BOOST_AUTO_TEST_CASE(complex_import)
BOOST_CHECK(successParse(text));
}
-BOOST_AUTO_TEST_CASE(from_is_not_keyword)
-{
- // "from" is not a keyword although it is used as a keyword in import directives.
- char const* text = R"(
- contract from {
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(inline_array_declaration)
-{
- char const* text = R"(
- contract c {
- uint[] a;
- function f() returns (uint, uint) {
- a = [1,2,3];
- return (a[3], [2,3,4][0]);
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_true_false_literal)
-{
- char const* text = R"(
- contract A {
- function f() {
- uint x = true ? 1 : 0;
- uint y = false ? 0 : 1;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_with_constants)
-{
- char const* text = R"(
- contract A {
- function f() {
- uint x = 3 > 0 ? 3 : 0;
- uint y = (3 > 0) ? 3 : 0;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_with_variables)
-{
- char const* text = R"(
- contract A {
- function f() {
- uint x = 3;
- uint y = 1;
- uint z = (x > y) ? x : y;
- uint w = x > y ? x : y;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_multiple)
-{
- char const* text = R"(
- contract A {
- function f() {
- uint x = 3 < 0 ? 2 > 1 ? 2 : 1 : 7 > 2 ? 7 : 6;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(conditional_with_assignment)
-{
- char const* text = R"(
- contract A {
- function f() {
- uint y = 1;
- uint x = 3 < 0 ? x = 3 : 6;
- true ? x = 3 : 4;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_CASE(recursion_depth1)
{
string text("contract C { bytes");
@@ -1127,117 +596,6 @@ BOOST_AUTO_TEST_CASE(recursion_depth4)
CHECK_PARSE_ERROR(text, "Maximum recursion depth reached during parsing");
}
-BOOST_AUTO_TEST_CASE(declaring_fixed_and_ufixed_variables)
-{
- char const* text = R"(
- contract A {
- fixed40x40 storeMe;
- function f(ufixed x, fixed32x32 y) {
- ufixed8x8 a;
- fixed b;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(declaring_fixed_literal_variables)
-{
- char const* text = R"(
- contract A {
- fixed40x40 pi = 3.14;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(function_type_in_expression)
-{
- char const* text = R"(
- contract test {
- function f(uint x, uint y) returns (uint a) {}
- function g() {
- function (uint, uint) internal returns (uint) f1 = f;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(function_type_as_storage_variable)
-{
- char const* text = R"(
- contract test {
- function (uint, uint) internal returns (uint) f1;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(function_type_as_storage_variable_with_assignment)
-{
- char const* text = R"(
- contract test {
- function f(uint x, uint y) returns (uint a) {}
- function (uint, uint) internal returns (uint) f1 = f;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(function_type_in_struct)
-{
- char const* text = R"(
- contract test {
- struct S {
- function (uint x, uint y) internal returns (uint a) f;
- function (uint, uint) external returns (uint) g;
- uint d;
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(function_type_as_parameter)
-{
- char const* text = R"(
- contract test {
- function f(function(uint) external returns (uint) g) internal returns (uint a) {
- return g(1);
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(calling_function)
-{
- char const* text = R"(
- contract test {
- function f() {
- function() returns(function() returns(function() returns(function() returns(uint)))) x;
- uint y;
- y = x()()()();
- }
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
-BOOST_AUTO_TEST_CASE(mapping_and_array_of_functions)
-{
- char const* text = R"(
- contract test {
- mapping (address => function() internal returns (uint)) a;
- mapping (address => function() external) b;
- mapping (address => function() external[]) c;
- function() external[] d;
- }
- )";
- BOOST_CHECK(successParse(text));
-}
-
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityTypes.cpp b/test/libsolidity/SolidityTypes.cpp
index 738b24bc..e6928bb8 100644
--- a/test/libsolidity/SolidityTypes.cpp
+++ b/test/libsolidity/SolidityTypes.cpp
@@ -36,6 +36,33 @@ namespace test
BOOST_AUTO_TEST_SUITE(SolidityTypes)
+BOOST_AUTO_TEST_CASE(int_types)
+{
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Int, 0, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Signed));
+ for (unsigned i = 8; i <= 256; i += 8)
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::IntM, i, 0)) == *make_shared<IntegerType>(i, IntegerType::Modifier::Signed));
+}
+
+BOOST_AUTO_TEST_CASE(uint_types)
+{
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UInt, 0, 0)) == *make_shared<IntegerType>(256, IntegerType::Modifier::Unsigned));
+ for (unsigned i = 8; i <= 256; i += 8)
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UIntM, i, 0)) == *make_shared<IntegerType>(i, IntegerType::Modifier::Unsigned));
+}
+
+BOOST_AUTO_TEST_CASE(byte_types)
+{
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Byte, 0, 0)) == *make_shared<FixedBytesType>(1));
+ for (unsigned i = 1; i <= 32; i++)
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::BytesM, i, 0)) == *make_shared<FixedBytesType>(i));
+}
+
+BOOST_AUTO_TEST_CASE(fixed_types)
+{
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::Fixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Signed));
+ BOOST_CHECK(*Type::fromElementaryTypeName(ElementaryTypeNameToken(Token::UFixed, 0, 0)) == *make_shared<FixedPointType>(128, 18, FixedPointType::Modifier::Unsigned));
+}
+
BOOST_AUTO_TEST_CASE(storage_layout_simple)
{
MemberList members(MemberList::MemberMap({
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol
index 6520672c..55c5edd3 100644
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_fine.sol
@@ -23,13 +23,8 @@ contract C {
}
function k() internal view returns (S storage c) {
do {
- if (s.f) {
- continue;
- break;
- }
- else {
- c = s;
- }
+ c = s;
+ continue;
} while(false);
}
}
diff --git a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol
index f1a92e9c..7d001c19 100644
--- a/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol
+++ b/test/libsolidity/syntaxTests/controlFlow/storageReturn/dowhile_warn.sol
@@ -21,6 +21,15 @@ contract C {
do {
if (s.f) {
break;
+ }
+ else {
+ c = s;
+ }
+ } while(false);
+ }
+ function i() internal view returns (S storage c) {
+ do {
+ if (s.f) {
continue;
}
else {
@@ -28,8 +37,16 @@ contract C {
}
} while(false);
}
+ function j() internal view returns (S storage c) {
+ do {
+ continue;
+ c = s;
+ } while(false);
+ }
}
// ----
// Warning: (87-98): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
// Warning: (223-234): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
// Warning: (440-451): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
+// Warning: (654-665): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
+// Warning: (871-882): This variable is of storage pointer type and might be returned without assignment. This can cause storage corruption. Assign the variable (potentially from itself) to remove this warning.
diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_events.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_events.sol
new file mode 100644
index 00000000..edbc9665
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/arrays_in_events.sol
@@ -0,0 +1,3 @@
+contract c {
+ event e(uint[10] a, bytes7[8] indexed b, c[3] x);
+}
diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol
new file mode 100644
index 00000000..626e865e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/arrays_in_expressions.sol
@@ -0,0 +1,8 @@
+contract c {
+ function f() { c[10] a = 7; uint8[10 * 2] x; }
+}
+// ----
+// Warning: (32-39): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
+// Warning: (45-60): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
+// TypeError: (32-43): Type int_const 7 is not implicitly convertible to expected type contract c[10] storage pointer.
+// Warning: (45-60): Uninitialized storage pointer. Did you mean '<type> memory x'?
diff --git a/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol
new file mode 100644
index 00000000..9181222e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/arrays_in_storage.sol
@@ -0,0 +1,6 @@
+contract c {
+ uint[10] a;
+ uint[] a2;
+ struct x { uint[2**20] b; y[0] c; }
+ struct y { uint d; mapping(uint=>x)[] e; }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/calling_function.sol b/test/libsolidity/syntaxTests/parsing/calling_function.sol
new file mode 100644
index 00000000..4c4fc1fc
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/calling_function.sol
@@ -0,0 +1,9 @@
+contract test {
+ function f() {
+ function() returns(function() returns(function() returns(function() returns(uint)))) x;
+ uint y;
+ y = x()()()();
+ }
+}
+// ----
+// Warning: (20-175): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol
new file mode 100644
index 00000000..c7d11ed6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/conditional_multiple.sol
@@ -0,0 +1,9 @@
+contract A {
+ function f() {
+ uint x = 3 < 0 ? 2 > 1 ? 2 : 1 : 7 > 2 ? 7 : 6;
+ }
+}
+// ----
+// Warning: (17-93): No visibility specified. Defaulting to "public".
+// Warning: (40-46): Unused local variable.
+// Warning: (17-93): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol
new file mode 100644
index 00000000..90974e96
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/conditional_true_false_literal.sol
@@ -0,0 +1,11 @@
+contract A {
+ function f() {
+ uint x = true ? 1 : 0;
+ uint y = false ? 0 : 1;
+ }
+}
+// ----
+// Warning: (17-100): No visibility specified. Defaulting to "public".
+// Warning: (40-46): Unused local variable.
+// Warning: (71-77): Unused local variable.
+// Warning: (17-100): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol
new file mode 100644
index 00000000..6f8040d6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/conditional_with_assignment.sol
@@ -0,0 +1,11 @@
+contract A {
+ function f() {
+ uint y = 1;
+ uint x = 3 < 0 ? x = 3 : 6;
+ true ? x = 3 : 4;
+ }
+}
+// ----
+// Warning: (17-119): No visibility specified. Defaulting to "public".
+// Warning: (40-46): Unused local variable.
+// Warning: (17-119): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol
new file mode 100644
index 00000000..35da69c6
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/conditional_with_constants.sol
@@ -0,0 +1,11 @@
+contract A {
+ function f() {
+ uint x = 3 > 0 ? 3 : 0;
+ uint y = (3 > 0) ? 3 : 0;
+ }
+}
+// ----
+// Warning: (17-103): No visibility specified. Defaulting to "public".
+// Warning: (40-46): Unused local variable.
+// Warning: (72-78): Unused local variable.
+// Warning: (17-103): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol
new file mode 100644
index 00000000..eb4c7091
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/conditional_with_variables.sol
@@ -0,0 +1,13 @@
+contract A {
+ function f() {
+ uint x = 3;
+ uint y = 1;
+ uint z = (x > y) ? x : y;
+ uint w = x > y ? x : y;
+ }
+}
+// ----
+// Warning: (17-143): No visibility specified. Defaulting to "public".
+// Warning: (80-86): Unused local variable.
+// Warning: (114-120): Unused local variable.
+// Warning: (17-143): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol
new file mode 100644
index 00000000..8be9667a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/declaring_fixed_and_ufixed_variables.sol
@@ -0,0 +1,14 @@
+contract A {
+ fixed40x40 storeMe;
+ function f(ufixed x, fixed32x32 y) {
+ ufixed8x8 a;
+ fixed b;
+ }
+}
+// ----
+// Warning: (41-121): No visibility specified. Defaulting to "public".
+// Warning: (52-60): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (62-74): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (86-97): Unused local variable.
+// Warning: (107-114): Unused local variable.
+// Warning: (41-121): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/declaring_fixed_literal_variables.sol b/test/libsolidity/syntaxTests/parsing/declaring_fixed_literal_variables.sol
new file mode 100644
index 00000000..b0d938a0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/declaring_fixed_literal_variables.sol
@@ -0,0 +1,5 @@
+contract A {
+ fixed40x40 pi = 3.14;
+}
+// ----
+// TypeError: (33-37): Type rational_const 157 / 50 is not implicitly convertible to expected type fixed40x40. Try converting to type ufixed16x2 or use an explicit conversion.
diff --git a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol
new file mode 100644
index 00000000..727e6115
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol
@@ -0,0 +1,8 @@
+contract test {
+ function fun(uint256 a) returns (address b) {
+ if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78;
+ }
+}
+// ----
+// Warning: (20-142): No visibility specified. Defaulting to "public".
+// Warning: (20-142): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol
new file mode 100644
index 00000000..4c4a1217
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/enum_valid_declaration.sol
@@ -0,0 +1,10 @@
+contract c {
+ enum validEnum { Value1, Value2, Value3, Value4 }
+ function c() {
+ a = validEnum.Value3;
+ }
+ validEnum a;
+}
+// ----
+// Warning: (71-121): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// Warning: (71-121): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/event.sol b/test/libsolidity/syntaxTests/parsing/event.sol
new file mode 100644
index 00000000..2aaa873f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/event.sol
@@ -0,0 +1,3 @@
+contract c {
+ event e();
+}
diff --git a/test/libsolidity/syntaxTests/parsing/event_arguments.sol b/test/libsolidity/syntaxTests/parsing/event_arguments.sol
new file mode 100644
index 00000000..3228853a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/event_arguments.sol
@@ -0,0 +1,3 @@
+contract c {
+ event e(uint a, bytes32 s);
+}
diff --git a/test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol b/test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol
new file mode 100644
index 00000000..d603fc08
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/event_arguments_indexed.sol
@@ -0,0 +1,3 @@
+contract c {
+ event e(uint a, bytes32 indexed s, bool indexed b);
+}
diff --git a/test/libsolidity/syntaxTests/parsing/exp_expression.sol b/test/libsolidity/syntaxTests/parsing/exp_expression.sol
new file mode 100644
index 00000000..cdabb996
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/exp_expression.sol
@@ -0,0 +1,9 @@
+contract test {
+ function fun(uint256 a) {
+ uint256 x = 3 ** a;
+ }
+}
+// ----
+// Warning: (20-79): No visibility specified. Defaulting to "public".
+// Warning: (54-63): Unused local variable.
+// Warning: (20-79): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/external_function.sol b/test/libsolidity/syntaxTests/parsing/external_function.sol
new file mode 100644
index 00000000..3aa3ceec
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/external_function.sol
@@ -0,0 +1,5 @@
+contract c {
+ function x() external {}
+}
+// ----
+// Warning: (17-41): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/fallback_function.sol b/test/libsolidity/syntaxTests/parsing/fallback_function.sol
new file mode 100644
index 00000000..de32b030
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/fallback_function.sol
@@ -0,0 +1,5 @@
+contract c {
+ function() { }
+}
+// ----
+// Warning: (17-31): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol
new file mode 100644
index 00000000..bd86f2f5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_initexpr.sol
@@ -0,0 +1,13 @@
+contract test {
+ function fun(uint256 a) {
+ uint256 i =0;
+ for (i = 0; i < 10; i++) {
+ uint256 x = i; break; continue;
+ }
+ }
+}
+// ----
+// Warning: (20-162): No visibility specified. Defaulting to "public".
+// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (115-124): Unused local variable.
+// Warning: (20-162): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol
new file mode 100644
index 00000000..4a27e0fb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_simple_noexpr.sol
@@ -0,0 +1,13 @@
+contract test {
+ function fun(uint256 a) {
+ uint256 i =0;
+ for (;;) {
+ uint256 x = i; break; continue;
+ }
+ }
+ }
+// ----
+// Warning: (24-170): No visibility specified. Defaulting to "public".
+// Warning: (37-46): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (115-124): Unused local variable.
+// Warning: (24-170): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol
new file mode 100644
index 00000000..3df88ef5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_single_stmt_body.sol
@@ -0,0 +1,11 @@
+contract test {
+ function fun(uint256 a) {
+ uint256 i = 0;
+ for (i = 0; i < 10; i++)
+ continue;
+ }
+}
+// ----
+// Warning: (20-129): No visibility specified. Defaulting to "public".
+// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (20-129): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol
new file mode 100644
index 00000000..a7c5e8bb
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/for_loop_vardef_initexpr.sol
@@ -0,0 +1,12 @@
+contract test {
+ function fun(uint256 a) {
+ for (uint256 i = 0; i < 10; i++) {
+ uint256 x = i; break; continue;
+ }
+ }
+}
+// ----
+// Warning: (20-148): No visibility specified. Defaulting to "public".
+// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (101-110): Unused local variable.
+// Warning: (20-148): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol b/test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol
new file mode 100644
index 00000000..38175572
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/from_is_not_keyword.sol
@@ -0,0 +1,3 @@
+// "from" is not a keyword although it is used as a keyword in import directives.
+contract from {
+}
diff --git a/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol
new file mode 100644
index 00000000..c7a023ac
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_normal_comments.sol
@@ -0,0 +1,10 @@
+contract test {
+ uint256 stateVar;
+ // We won't see this comment
+ function functionName(bytes32 input) returns (bytes32 out) {}
+}
+// ----
+// Warning: (75-136): No visibility specified. Defaulting to "public".
+// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (121-132): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (75-136): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_parameter.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_parameter.sol
new file mode 100644
index 00000000..4075d74a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_type_as_parameter.sol
@@ -0,0 +1,5 @@
+contract test {
+ function f(function(uint) external returns (uint) g) internal returns (uint a) {
+ return g(1);
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol
new file mode 100644
index 00000000..e3d41f48
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable.sol
@@ -0,0 +1,3 @@
+contract test {
+ function (uint, uint) internal returns (uint) f1;
+}
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol
new file mode 100644
index 00000000..3b784733
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_type_as_storage_variable_with_assignment.sol
@@ -0,0 +1,10 @@
+contract test {
+ function f(uint x, uint y) returns (uint a) {}
+ function (uint, uint) internal returns (uint) f1 = f;
+}
+// ----
+// Warning: (20-66): No visibility specified. Defaulting to "public".
+// Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (56-62): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (20-66): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol
new file mode 100644
index 00000000..fd6447c7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_type_in_expression.sol
@@ -0,0 +1,15 @@
+contract test {
+ function f(uint x, uint y) returns (uint a) {}
+ function g() {
+ function (uint, uint) internal returns (uint) f1 = f;
+ }
+}
+// ----
+// Warning: (20-66): No visibility specified. Defaulting to "public".
+// Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (56-62): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (71-153): No visibility specified. Defaulting to "public".
+// Warning: (94-142): Unused local variable.
+// Warning: (20-66): Function state mutability can be restricted to pure
+// Warning: (71-153): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol b/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol
new file mode 100644
index 00000000..d3c84678
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/function_type_in_struct.sol
@@ -0,0 +1,11 @@
+contract test {
+ struct S {
+ function (uint x, uint y) internal returns (uint a) f;
+ function (uint, uint) external returns (uint) g;
+ uint d;
+ }
+}
+// ----
+// Warning: (49-55): Naming function type parameters is deprecated.
+// Warning: (57-63): Naming function type parameters is deprecated.
+// Warning: (83-89): Naming function type return parameters is deprecated.
diff --git a/test/libsolidity/syntaxTests/parsing/if_statement.sol b/test/libsolidity/syntaxTests/parsing/if_statement.sol
new file mode 100644
index 00000000..0819cb9f
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/if_statement.sol
@@ -0,0 +1,11 @@
+contract test {
+ function fun(uint256 a) returns (uint) {
+ if (a >= 8) { return 2; } else { var b = 7; }
+ }
+}
+// ----
+// Warning: (102-107): Use of the "var" keyword is deprecated.
+// Warning: (102-111): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (20-120): No visibility specified. Defaulting to "public".
+// Warning: (102-107): Unused local variable.
+// Warning: (20-120): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol
new file mode 100644
index 00000000..f42f8f16
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/inline_array_declaration.sol
@@ -0,0 +1,9 @@
+contract c {
+ uint[] a;
+ function f() returns (uint, uint) {
+ a = [1,2,3];
+ return (a[3], [2,3,4][0]);
+ }
+}
+// ----
+// Warning: (31-128): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/library_simple.sol b/test/libsolidity/syntaxTests/parsing/library_simple.sol
new file mode 100644
index 00000000..fcf2638e
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/library_simple.sol
@@ -0,0 +1,6 @@
+library Lib {
+ function f() { }
+}
+// ----
+// Warning: (18-34): No visibility specified. Defaulting to "public".
+// Warning: (18-34): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol
new file mode 100644
index 00000000..452b52c7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations.sol
@@ -0,0 +1,16 @@
+contract c {
+ function f()
+ {
+ a = 1 wei;
+ b = 2 szabo;
+ c = 3 finney;
+ b = 4 ether;
+ }
+ uint256 a;
+ uint256 b;
+ uint256 c;
+ uint256 d;
+}
+// ----
+// Warning: (163-172): This declaration shadows an existing declaration.
+// Warning: (17-128): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol
new file mode 100644
index 00000000..d2cdc875
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/literal_constants_with_ether_subdenominations_in_expressions.sol
@@ -0,0 +1,10 @@
+contract c {
+ function c ()
+ {
+ a = 1 wei * 100 wei + 7 szabo - 3;
+ }
+ uint256 a;
+}
+// ----
+// Warning: (17-86): Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
+// Warning: (17-86): No visibility specified. Defaulting to "public".
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol
new file mode 100644
index 00000000..5d6c8dc5
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_locals.sol
@@ -0,0 +1,12 @@
+contract Foo {
+ function f() {
+ uint[] storage x;
+ uint[] memory y;
+ }
+}
+// ----
+// Warning: (42-58): Uninitialized storage pointer.
+// Warning: (19-90): No visibility specified. Defaulting to "public".
+// Warning: (42-58): Unused local variable.
+// Warning: (68-83): Unused local variable.
+// Warning: (19-90): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol
new file mode 100644
index 00000000..e021182a
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/location_specifiers_for_params.sol
@@ -0,0 +1,5 @@
+contract Foo {
+ function f(uint[] storage constant x, uint[] memory y) internal { }
+}
+// ----
+// TypeError: (30-55): Storage location has to be "memory" (or unspecified) for constants.
diff --git a/test/libsolidity/syntaxTests/parsing/mapping.sol b/test/libsolidity/syntaxTests/parsing/mapping.sol
new file mode 100644
index 00000000..d6bf3f14
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/mapping.sol
@@ -0,0 +1,3 @@
+contract test {
+ mapping(address => bytes32) names;
+}
diff --git a/test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol b/test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol
new file mode 100644
index 00000000..b7cf34e4
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/mapping_and_array_of_functions.sol
@@ -0,0 +1,6 @@
+contract test {
+ mapping (address => function() internal returns (uint)) a;
+ mapping (address => function() external) b;
+ mapping (address => function() external[]) c;
+ function() external[] d;
+}
diff --git a/test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol b/test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol
new file mode 100644
index 00000000..980d5750
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/mapping_in_struct.sol
@@ -0,0 +1,7 @@
+contract test {
+ struct test_struct {
+ address addr;
+ uint256 count;
+ mapping(bytes32 => test_struct) self_reference;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol b/test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol
new file mode 100644
index 00000000..c06220b7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/mapping_to_mapping_in_struct.sol
@@ -0,0 +1,6 @@
+contract test {
+ struct test_struct {
+ address addr;
+ mapping (uint64 => mapping (bytes32 => uint)) complex_mapping;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/modifier.sol b/test/libsolidity/syntaxTests/parsing/modifier.sol
new file mode 100644
index 00000000..3e659dcf
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/modifier.sol
@@ -0,0 +1,3 @@
+contract c {
+ modifier mod { if (msg.sender == 0) _; }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/modifier_arguments.sol b/test/libsolidity/syntaxTests/parsing/modifier_arguments.sol
new file mode 100644
index 00000000..27b5b13b
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/modifier_arguments.sol
@@ -0,0 +1,3 @@
+contract c {
+ modifier mod(address a) { if (msg.sender == a) _; }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol
new file mode 100644
index 00000000..cb2f2985
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/modifier_invocation.sol
@@ -0,0 +1,8 @@
+contract c {
+ modifier mod1(uint a) { if (msg.sender == address(a)) _; }
+ modifier mod2 { if (msg.sender == address(2)) _; }
+ function f() mod1(7) mod2 { }
+}
+// ----
+// Warning: (135-164): No visibility specified. Defaulting to "public".
+// Warning: (135-164): Function state mutability can be restricted to view
diff --git a/test/libsolidity/syntaxTests/parsing/multi_arrays.sol b/test/libsolidity/syntaxTests/parsing/multi_arrays.sol
new file mode 100644
index 00000000..ef20ecee
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/multi_arrays.sol
@@ -0,0 +1,3 @@
+contract c {
+ mapping(uint => mapping(uint => int8)[8][][9])[] x;
+}
diff --git a/test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol
new file mode 100644
index 00000000..bfbe7e5c
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/multiple_event_arg_trailing_comma.sol
@@ -0,0 +1,6 @@
+contract test {
+ event Test(uint a, uint b,);
+ function(uint a) {}
+}
+// ----
+// ParserError: (45-46): Unexpected trailing comma in parameter list.
diff --git a/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol
new file mode 100644
index 00000000..95a4d1e7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/multiple_functions_natspec_documentation.sol
@@ -0,0 +1,28 @@
+contract test {
+ uint256 stateVar;
+ /// This is test function 1
+ function functionName1(bytes32 input) returns (bytes32 out) {}
+ /// This is test function 2
+ function functionName2(bytes32 input) returns (bytes32 out) {}
+ // nothing to see here
+ function functionName3(bytes32 input) returns (bytes32 out) {}
+ /// This is test function 4
+ function functionName4(bytes32 input) returns (bytes32 out) {}
+}
+// ----
+// Warning: (74-136): No visibility specified. Defaulting to "public".
+// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (121-132): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (173-235): No visibility specified. Defaulting to "public".
+// Warning: (196-209): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (220-231): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (267-329): No visibility specified. Defaulting to "public".
+// Warning: (290-303): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (314-325): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (366-428): No visibility specified. Defaulting to "public".
+// Warning: (389-402): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (413-424): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (74-136): Function state mutability can be restricted to pure
+// Warning: (173-235): Function state mutability can be restricted to pure
+// Warning: (267-329): Function state mutability can be restricted to pure
+// Warning: (366-428): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/multiple_modifier_arg_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/multiple_modifier_arg_trailing_comma.sol
new file mode 100644
index 00000000..eb206fb7
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/multiple_modifier_arg_trailing_comma.sol
@@ -0,0 +1,6 @@
+contract test {
+ modifier modTest(uint a, uint b,) { _; }
+ function(uint a) {}
+}
+// ----
+// ParserError: (51-52): Unexpected trailing comma in parameter list.
diff --git a/test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol b/test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol
new file mode 100644
index 00000000..2dd8f196
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/multiple_return_param_trailing_comma.sol
@@ -0,0 +1,5 @@
+contract test {
+ function() returns (uint a, uint b,) {}
+}
+// ----
+// ParserError: (54-55): Unexpected trailing comma in parameter list.
diff --git a/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol
new file mode 100644
index 00000000..72546dc0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/placeholder_in_function_context.sol
@@ -0,0 +1,11 @@
+contract c {
+ function fun() returns (uint r) {
+ var _ = 8;
+ return _ + 1;
+ }
+}
+// ----
+// Warning: (59-64): Use of the "var" keyword is deprecated.
+// Warning: (59-68): The type of this variable was inferred as uint8, which can hold values between 0 and 255. This is probably not desired. Use an explicit type to silence this warning.
+// Warning: (17-97): No visibility specified. Defaulting to "public".
+// Warning: (17-97): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/struct_definition.sol b/test/libsolidity/syntaxTests/parsing/struct_definition.sol
new file mode 100644
index 00000000..0c859e5d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/struct_definition.sol
@@ -0,0 +1,7 @@
+contract test {
+ uint256 stateVar;
+ struct MyStructName {
+ address addr;
+ uint256 count;
+ }
+}
diff --git a/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol b/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol
new file mode 100644
index 00000000..0b3dda56
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/two_exact_functions.sol
@@ -0,0 +1,9 @@
+// with support of overloaded functions, during parsing,
+// we can't determine whether they match exactly, however
+// it will throw DeclarationError in following stage.
+contract test {
+ function fun(uint a) returns(uint r) { return a; }
+ function fun(uint a) returns(uint r) { return a; }
+}
+// ----
+// DeclarationError: (189-239): Function with same name and arguments defined twice.
diff --git a/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol
new file mode 100644
index 00000000..4706a26d
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/visibility_specifiers.sol
@@ -0,0 +1,17 @@
+contract c {
+ uint private a;
+ uint internal b;
+ uint public c;
+ uint d;
+ function f() {}
+ function f_priv() private {}
+ function f_public() public {}
+ function f_internal() internal {}
+}
+// ----
+// Warning: (58-71): This declaration shadows an existing declaration.
+// Warning: (89-104): No visibility specified. Defaulting to "public".
+// Warning: (89-104): Function state mutability can be restricted to pure
+// Warning: (109-137): Function state mutability can be restricted to pure
+// Warning: (142-171): Function state mutability can be restricted to pure
+// Warning: (176-209): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/while_loop.sol b/test/libsolidity/syntaxTests/parsing/while_loop.sol
new file mode 100644
index 00000000..129b52e1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/parsing/while_loop.sol
@@ -0,0 +1,9 @@
+contract test {
+ function fun(uint256 a) {
+ while (true) { uint256 x = 1; break; continue; } x = 9;
+ }
+}
+// ----
+// Warning: (20-115): No visibility specified. Defaulting to "public".
+// Warning: (33-42): Unused function parameter. Remove or comment out the variable name to silence this warning.
+// Warning: (20-115): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/types/bool_ops.sol b/test/libsolidity/syntaxTests/types/bool_ops.sol
new file mode 100644
index 00000000..91033906
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/bool_ops.sol
@@ -0,0 +1,53 @@
+contract C {
+ function f(bool a, bool b) public pure {
+ bool c;
+ // OK
+ c = !a;
+ c = !b;
+ c = a == b;
+ c = a != b;
+ c = a || b;
+ c = a && b;
+
+ // Not OK
+ c = a > b;
+ c = a < b;
+ c = a >= b;
+ c = a <= b;
+ c = a & b;
+ c = a | b;
+ c = a ^ b;
+ c = ~a;
+ c = ~b;
+ c = a + b;
+ c = a - b;
+ c = -a;
+ c = -b;
+ c = a * b;
+ c = a / b;
+ c = a ** b;
+ c = a % b;
+ c = a << b;
+ c = a >> b;
+ }
+}
+// ----
+// TypeError: (231-236): Operator > not compatible with types bool and bool
+// TypeError: (250-255): Operator < not compatible with types bool and bool
+// TypeError: (269-275): Operator >= not compatible with types bool and bool
+// TypeError: (289-295): Operator <= not compatible with types bool and bool
+// TypeError: (309-314): Operator & not compatible with types bool and bool
+// TypeError: (328-333): Operator | not compatible with types bool and bool
+// TypeError: (347-352): Operator ^ not compatible with types bool and bool
+// TypeError: (366-368): Unary operator ~ cannot be applied to type bool
+// TypeError: (382-384): Unary operator ~ cannot be applied to type bool
+// TypeError: (398-403): Operator + not compatible with types bool and bool
+// TypeError: (417-422): Operator - not compatible with types bool and bool
+// TypeError: (436-438): Unary operator - cannot be applied to type bool
+// TypeError: (452-454): Unary operator - cannot be applied to type bool
+// TypeError: (468-473): Operator * not compatible with types bool and bool
+// TypeError: (487-492): Operator / not compatible with types bool and bool
+// TypeError: (506-512): Operator ** not compatible with types bool and bool
+// TypeError: (526-531): Operator % not compatible with types bool and bool
+// TypeError: (545-551): Operator << not compatible with types bool and bool
+// TypeError: (565-571): Operator >> not compatible with types bool and bool
diff --git a/test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol b/test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol
new file mode 100644
index 00000000..58828a62
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/bytes1_to_uint256.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure returns(uint256) {
+ return uint256(bytes1(''));
+ }
+}
+// ----
+// TypeError: (76-95): Explicit type conversion not allowed from "bytes1" to "uint256".
diff --git a/test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol b/test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol
new file mode 100644
index 00000000..77e813ab
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/bytes32_to_uint32.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure returns(uint32) {
+ return uint32(bytes32(''));
+ }
+}
+// ----
+// TypeError: (75-94): Explicit type conversion not allowed from "bytes32" to "uint32".
diff --git a/test/libsolidity/syntaxTests/types/bytes_to_contract.sol b/test/libsolidity/syntaxTests/types/bytes_to_contract.sol
index 2a3219ec..820dbf9b 100644
--- a/test/libsolidity/syntaxTests/types/bytes_to_contract.sol
+++ b/test/libsolidity/syntaxTests/types/bytes_to_contract.sol
@@ -1,7 +1,7 @@
contract C {
function f() public pure {
- C(bytes20(0x1234));
+ C(bytes20(uint160(0x1234)));
}
}
// ----
-// TypeError: (64-82): Explicit type conversion not allowed from "bytes20" to "contract C".
+// TypeError: (64-91): Explicit type conversion not allowed from "bytes20" to "contract C".
diff --git a/test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol b/test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol
new file mode 100644
index 00000000..2963cfd2
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/bytes_to_uint_same_size.sol
@@ -0,0 +1,20 @@
+contract C {
+ function f() public pure returns (uint256) {
+ return uint256(bytes32(uint256(0)));
+ }
+ function g() public pure returns (uint128) {
+ return uint128(bytes16(uint128(0)));
+ }
+ function h() public pure returns (uint64) {
+ return uint64(bytes8(uint64(0)));
+ }
+ function i() public pure returns (uint32) {
+ return uint32(bytes4(uint32(0)));
+ }
+ function j() public pure returns (uint16) {
+ return uint16(bytes2(uint16(0)));
+ }
+ function k() public pure returns (uint8) {
+ return uint8(bytes1(uint8(0)));
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/index_access_for_bytes.sol b/test/libsolidity/syntaxTests/types/index_access_for_bytes.sol
new file mode 100644
index 00000000..f31b4cc0
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/index_access_for_bytes.sol
@@ -0,0 +1,6 @@
+contract C {
+ bytes20 x;
+ function f(bytes16 b) public view {
+ b[uint8(x[2])];
+ }
+}
diff --git a/test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol b/test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol
new file mode 100644
index 00000000..f70c89ed
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/uint256_to_bytes1.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure returns(bytes1) {
+ return bytes1(uint256(0));
+ }
+}
+// ----
+// TypeError: (75-93): Explicit type conversion not allowed from "uint256" to "bytes1".
diff --git a/test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol b/test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol
new file mode 100644
index 00000000..4153c5c3
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/uint32_to_bytes32.sol
@@ -0,0 +1,7 @@
+contract C {
+ function f() public pure returns(bytes32) {
+ return bytes32(uint32(0));
+ }
+}
+// ----
+// TypeError: (76-94): Explicit type conversion not allowed from "uint32" to "bytes32".