From ab3db782ae9193839a354a626a7d8ee7bdfad63a Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Tue, 15 Nov 2016 19:07:33 +0100 Subject: test: check the error texts by changing parseAnalyseAndReturnError to return the whole Error, not just the type --- test/libsolidity/SolidityNameAndTypeResolution.cpp | 376 ++++++++++----------- 1 file changed, 188 insertions(+), 188 deletions(-) (limited to 'test/libsolidity') diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index b0e0bbb4..6932f852 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -44,7 +44,7 @@ namespace test namespace { -pair, std::shared_ptr> +pair, std::shared_ptr> parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false, bool _insertVersionPragma = true) { // Silence compiler version warning @@ -61,7 +61,7 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false, SyntaxChecker syntaxChecker(errors); if (!syntaxChecker.checkSyntax(*sourceUnit)) - return make_pair(sourceUnit, std::make_shared(errors[0]->type())); + return make_pair(sourceUnit, errors[0]); std::shared_ptr globalContext = make_shared(); NameAndTypeResolver resolver(globalContext->declarations(), errors); @@ -96,7 +96,7 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false, (_reportWarnings && currentError->type() == Error::Type::Warning) || (!_reportWarnings && currentError->type() != Error::Type::Warning) ) - return make_pair(sourceUnit, std::make_shared(currentError->type())); + return make_pair(sourceUnit, currentError); } } catch (InternalCompilerError const& _e) @@ -108,7 +108,7 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false, } catch (Error const& _e) { - return make_pair(sourceUnit, std::make_shared(_e.type())); + return make_pair(sourceUnit, std::make_shared(_e)); } catch (...) { @@ -130,7 +130,7 @@ bool success(string const& _source) return !parseAnalyseAndReturnError(_source).second; } -Error::Type expectError(std::string const& _source, bool _warning = false) +Error expectError(std::string const& _source, bool _warning = false) { auto sourceAndError = parseAnalyseAndReturnError(_source, _warning); BOOST_REQUIRE(!!sourceAndError.second); @@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(double_stateVariable_declaration) " uint256 variable;\n" " uint128 variable;\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(double_function_declaration) @@ -186,7 +186,7 @@ BOOST_AUTO_TEST_CASE(double_function_declaration) " function fun() { uint x; }\n" " function fun() { uint x; }\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(double_variable_declaration) @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(double_variable_declaration) char const* text = "contract test {\n" " function f() { uint256 x; if (true) { uint256 x; } }\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(name_shadowing) @@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE(undeclared_name) " uint256 variable;\n" " function f(uint256 arg) { f(notfound); }" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(reference_to_later_declaration) @@ -241,7 +241,7 @@ BOOST_AUTO_TEST_CASE(struct_definition_directly_recursive) " MyStructName x;\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(struct_definition_indirectly_recursive) @@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(struct_definition_indirectly_recursive) " MyStructName1 x;\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(struct_definition_not_really_recursive) @@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE(type_checking_return_wrong_number) char const* text = "contract test {\n" " function f() returns (bool r1, bool r2) { return 1 >= 2; }" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(type_checking_return_wrong_type) @@ -311,7 +311,7 @@ BOOST_AUTO_TEST_CASE(type_checking_return_wrong_type) char const* text = "contract test {\n" " function f() returns (uint256 r) { return 1 >= 2; }" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(type_checking_function_call) @@ -336,7 +336,7 @@ BOOST_AUTO_TEST_CASE(type_conversion_for_comparison_invalid) char const* text = "contract test {\n" " function f() { int32(2) == uint64(2); }" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(type_inference_explicit_conversion) @@ -372,7 +372,7 @@ BOOST_AUTO_TEST_CASE(balance_invalid) " address(0).balance = 7;\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(assignment_to_mapping) @@ -387,7 +387,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_mapping) " data.map = a;\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(assignment_to_struct) @@ -411,7 +411,7 @@ BOOST_AUTO_TEST_CASE(returns_in_constructor) " function test() returns (uint a) {\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(forward_function_reference) @@ -499,7 +499,7 @@ BOOST_AUTO_TEST_CASE(create_abstract_contract) function foo() { b = new base();} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(abstract_contract_constructor_args_optional) @@ -543,7 +543,7 @@ BOOST_AUTO_TEST_CASE(redeclare_implemented_abstract_function_as_abstract) contract derived is base { function foo() {} } contract wrong is derived { function foo(); } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(implement_abstract_via_constructor) @@ -667,7 +667,7 @@ BOOST_AUTO_TEST_CASE(function_external_call_not_allowed_conversion) } function g (C c) external {} })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(function_internal_allowed_conversion) @@ -699,7 +699,7 @@ BOOST_AUTO_TEST_CASE(function_internal_not_allowed_conversion) g(a); } })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(hash_collision_in_interface) @@ -710,7 +710,7 @@ BOOST_AUTO_TEST_CASE(hash_collision_in_interface) " function tgeo() {\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(inheritance_basic) @@ -744,7 +744,7 @@ BOOST_AUTO_TEST_CASE(cyclic_inheritance) contract A is B { } contract B is A { } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(legal_override_direct) @@ -772,7 +772,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_visibility) contract B { function f() internal {} } contract C is B { function f() public {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(illegal_override_constness) @@ -781,7 +781,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_constness) contract B { function f() constant {} } contract C is B { function f() {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(complex_inheritance) @@ -851,7 +851,7 @@ BOOST_AUTO_TEST_CASE(implicit_base_to_derived_conversion) function f() { B b = A(1); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(super_excludes_current_contract) @@ -868,7 +868,7 @@ BOOST_AUTO_TEST_CASE(super_excludes_current_contract) } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(function_modifier_invocation) @@ -891,7 +891,7 @@ BOOST_AUTO_TEST_CASE(invalid_function_modifier_type) modifier mod1(uint a) { if (a > 0) _; } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(function_modifier_invocation_parameters) @@ -932,7 +932,7 @@ BOOST_AUTO_TEST_CASE(illegal_modifier_override) contract A { modifier mod(uint a) { _; } } contract B is A { modifier mod(uint8 a) { _; } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(modifier_overrides_function) @@ -941,7 +941,7 @@ BOOST_AUTO_TEST_CASE(modifier_overrides_function) contract A { modifier mod(uint a) { _; } } contract B is A { function mod(uint a) { } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(function_overrides_modifier) @@ -950,7 +950,7 @@ BOOST_AUTO_TEST_CASE(function_overrides_modifier) contract A { function mod(uint a) { } } contract B is A { modifier mod(uint a) { _; } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(modifier_returns_value) @@ -961,7 +961,7 @@ BOOST_AUTO_TEST_CASE(modifier_returns_value) modifier mod(uint a) { _; return 7; } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(state_variable_accessors) @@ -1012,7 +1012,7 @@ BOOST_AUTO_TEST_CASE(function_clash_with_state_variable_accessor) "uint256 foo;\n" " function foo() {}\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(private_state_variable) @@ -1045,7 +1045,7 @@ BOOST_AUTO_TEST_CASE(missing_state_variable) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } @@ -1069,7 +1069,7 @@ BOOST_AUTO_TEST_CASE(struct_accessor_one_array_only) Data public data; } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(base_class_state_variable_internal_member) @@ -1094,7 +1094,7 @@ BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class1) "contract Child is Parent2{\n" " function foo() returns (uint256) { return Parent2.m_aMember1; }\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class2) @@ -1109,7 +1109,7 @@ BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class2) " function foo() returns (uint256) { return Child.m_aMember2; }\n" " uint256 public m_aMember3;\n" "}\n"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(fallback_function) @@ -1131,7 +1131,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_with_arguments) function(uint a) { x = 2; } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(fallback_function_in_library) @@ -1141,7 +1141,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_in_library) function() {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(fallback_function_with_return_parameters) @@ -1151,7 +1151,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_with_return_parameters) function() returns (uint) { } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(fallback_function_with_constant_modifier) @@ -1162,7 +1162,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_with_constant_modifier) function() constant { x = 2; } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(fallback_function_twice) @@ -1174,7 +1174,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_twice) function() { x = 3; } } )"; - BOOST_CHECK(expectError(text) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(fallback_function_inheritance) @@ -1207,7 +1207,7 @@ BOOST_AUTO_TEST_CASE(event_too_many_indexed) contract c { event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d); })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(anonymous_event_four_indexed) @@ -1225,7 +1225,7 @@ BOOST_AUTO_TEST_CASE(anonymous_event_too_many_indexed) contract c { event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d, uint indexed e) anonymous; })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(event_call) @@ -1281,7 +1281,7 @@ BOOST_AUTO_TEST_CASE(access_to_internal_function) contract d { function g() { c(0).f(); } })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(access_to_default_state_variable_visibility) @@ -1293,7 +1293,7 @@ BOOST_AUTO_TEST_CASE(access_to_default_state_variable_visibility) contract d { function g() { c(0).a(); } })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(access_to_internal_state_variable) @@ -1314,7 +1314,7 @@ BOOST_AUTO_TEST_CASE(error_count_in_named_args) " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" " function b() returns (uint r) { r = a({a: 1}); }\n" "}\n"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(empty_in_named_args) @@ -1323,7 +1323,7 @@ BOOST_AUTO_TEST_CASE(empty_in_named_args) " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" " function b() returns (uint r) { r = a({}); }\n" "}\n"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(duplicate_parameter_names_in_named_args) @@ -1332,7 +1332,7 @@ BOOST_AUTO_TEST_CASE(duplicate_parameter_names_in_named_args) " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" " function b() returns (uint r) { r = a({a: 1, a: 2}); }\n" "}\n"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(invalid_parameter_names_in_named_args) @@ -1341,7 +1341,7 @@ BOOST_AUTO_TEST_CASE(invalid_parameter_names_in_named_args) " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" " function b() returns (uint r) { r = a({a: 1, c: 2}); }\n" "}\n"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(empty_name_input_parameter) @@ -1383,13 +1383,13 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter_with_named_one) return 5; } })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(disallow_declaration_of_void_type) { char const* sourceCode = "contract c { function f() { var (x) = f(); } }"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(overflow_caused_by_ether_units) @@ -1412,7 +1412,7 @@ BOOST_AUTO_TEST_CASE(overflow_caused_by_ether_units) } uint256 a; })"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(exp_operator_exponent_too_big) @@ -1421,7 +1421,7 @@ BOOST_AUTO_TEST_CASE(exp_operator_exponent_too_big) contract test { function f() returns(uint d) { return 2 ** 10000000000; } })"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(enum_member_access) @@ -1466,7 +1466,7 @@ BOOST_AUTO_TEST_CASE(enum_invalid_member_access) ActionChoices choices; } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(enum_invalid_direct_member_access) @@ -1481,7 +1481,7 @@ BOOST_AUTO_TEST_CASE(enum_invalid_direct_member_access) ActionChoices choices; } )"; - BOOST_CHECK(expectError(text) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(enum_explicit_conversion_is_okay) @@ -1532,7 +1532,7 @@ BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay) uint64 b; } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(enum_to_enum_conversion_is_not_okay) @@ -1547,7 +1547,7 @@ BOOST_AUTO_TEST_CASE(enum_to_enum_conversion_is_not_okay) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(enum_duplicate_values) @@ -1557,7 +1557,7 @@ BOOST_AUTO_TEST_CASE(enum_duplicate_values) enum ActionChoices { GoLeft, GoRight, GoLeft, Sit } } )"; - BOOST_CHECK(expectError(text) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(enum_name_resolution_under_current_contract_name) @@ -1587,7 +1587,7 @@ BOOST_AUTO_TEST_CASE(private_visibility) function g() { f(); } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(private_visibility_via_explicit_base_access) @@ -1600,7 +1600,7 @@ BOOST_AUTO_TEST_CASE(private_visibility_via_explicit_base_access) function g() { base.f(); } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(external_visibility) @@ -1611,7 +1611,7 @@ BOOST_AUTO_TEST_CASE(external_visibility) function g() { f(); } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(external_base_visibility) @@ -1624,7 +1624,7 @@ BOOST_AUTO_TEST_CASE(external_base_visibility) function g() { base.f(); } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(external_argument_assign) @@ -1634,7 +1634,7 @@ BOOST_AUTO_TEST_CASE(external_argument_assign) function f(uint a) external { a = 1; } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(external_argument_increment) @@ -1644,7 +1644,7 @@ BOOST_AUTO_TEST_CASE(external_argument_increment) function f(uint a) external { a++; } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(external_argument_delete) @@ -1654,7 +1654,7 @@ BOOST_AUTO_TEST_CASE(external_argument_delete) function f(uint a) external { delete a; } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(test_for_bug_override_function_with_bytearray_type) @@ -1676,7 +1676,7 @@ BOOST_AUTO_TEST_CASE(array_with_nonconstant_length) contract c { function f(uint a) { uint8[a] x; } })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(array_copy_with_different_types1) @@ -1687,7 +1687,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types1) uint[] b; function f() { b = a; } })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(array_copy_with_different_types2) @@ -1698,7 +1698,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types2) uint8[] b; function f() { b = a; } })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(array_copy_with_different_types_conversion_possible) @@ -1731,7 +1731,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types_dynamic_static) uint[80] b; function f() { b = a; } })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_int) @@ -1740,7 +1740,7 @@ BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_int) contract c { uint8 a = 1000; })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_string) @@ -1749,7 +1749,7 @@ BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_string) contract c { uint a = "abc"; })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(test_fromElementaryTypeName) @@ -1875,7 +1875,7 @@ BOOST_AUTO_TEST_CASE(assigning_value_to_const_variable) function changeIt() { x = 9; } uint constant x = 56; })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(complex_const_variable) @@ -1885,7 +1885,7 @@ BOOST_AUTO_TEST_CASE(complex_const_variable) contract Foo { mapping(uint => bool) constant mapVar; })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(uninitialized_const_variable) @@ -1894,7 +1894,7 @@ BOOST_AUTO_TEST_CASE(uninitialized_const_variable) contract Foo { uint constant y; })"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(overloaded_function_cannot_resolve) @@ -1906,7 +1906,7 @@ BOOST_AUTO_TEST_CASE(overloaded_function_cannot_resolve) function g() returns(uint) { return f(3, 5); } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(ambiguous_overloaded_function) @@ -1919,7 +1919,7 @@ BOOST_AUTO_TEST_CASE(ambiguous_overloaded_function) function g() returns(uint) { return f(1); } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(assignment_of_nonoverloaded_function) @@ -1942,7 +1942,7 @@ BOOST_AUTO_TEST_CASE(assignment_of_overloaded_function) function g() returns(uint) { var x = f; return x(7); } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(external_types_clash) @@ -1956,7 +1956,7 @@ BOOST_AUTO_TEST_CASE(external_types_clash) function f(uint8 a) { } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(override_changes_return_types) @@ -1969,7 +1969,7 @@ BOOST_AUTO_TEST_CASE(override_changes_return_types) function f(uint a) returns (uint8) { } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(multiple_constructors) @@ -1980,7 +1980,7 @@ BOOST_AUTO_TEST_CASE(multiple_constructors) function test() {} } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(equal_overload) @@ -1991,7 +1991,7 @@ BOOST_AUTO_TEST_CASE(equal_overload) function test(uint a) external {} } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(uninitialized_var) @@ -2001,7 +2001,7 @@ BOOST_AUTO_TEST_CASE(uninitialized_var) function f() returns (uint) { var x; return 2; } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(string) @@ -2023,7 +2023,7 @@ BOOST_AUTO_TEST_CASE(string_index) function f() { var a = s[2]; } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(string_length) @@ -2034,7 +2034,7 @@ BOOST_AUTO_TEST_CASE(string_length) function f() { var a = s.length; } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(negative_integers_to_signed_out_of_bound) @@ -2044,7 +2044,7 @@ BOOST_AUTO_TEST_CASE(negative_integers_to_signed_out_of_bound) int8 public i = -129; } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(negative_integers_to_signed_min) @@ -2064,7 +2064,7 @@ BOOST_AUTO_TEST_CASE(positive_integers_to_signed_out_of_bound) int8 public j = 128; } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(positive_integers_to_signed_out_of_bound_max) @@ -2084,7 +2084,7 @@ BOOST_AUTO_TEST_CASE(negative_integers_to_unsigned) uint8 public x = -1; } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(positive_integers_to_unsigned_out_of_bound) @@ -2094,7 +2094,7 @@ BOOST_AUTO_TEST_CASE(positive_integers_to_unsigned_out_of_bound) uint8 public x = 700; } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(integer_boolean_operators) @@ -2102,15 +2102,15 @@ BOOST_AUTO_TEST_CASE(integer_boolean_operators) char const* sourceCode1 = R"( contract test { function() { uint x = 1; uint y = 2; x || y; } } )"; - BOOST_CHECK(expectError(sourceCode1) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode1).type() == Error::Type::TypeError); char const* sourceCode2 = R"( contract test { function() { uint x = 1; uint y = 2; x && y; } } )"; - BOOST_CHECK(expectError(sourceCode2) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode2).type() == Error::Type::TypeError); char const* sourceCode3 = R"( contract test { function() { uint x = 1; !x; } } )"; - BOOST_CHECK(expectError(sourceCode3) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode3).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(exp_signed_variable) @@ -2118,15 +2118,15 @@ BOOST_AUTO_TEST_CASE(exp_signed_variable) char const* sourceCode1 = R"( contract test { function() { uint x = 3; int y = -4; x ** y; } } )"; - BOOST_CHECK(expectError(sourceCode1) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode1).type() == Error::Type::TypeError); char const* sourceCode2 = R"( contract test { function() { uint x = 3; int y = -4; y ** x; } } )"; - BOOST_CHECK(expectError(sourceCode2) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode2).type() == Error::Type::TypeError); char const* sourceCode3 = R"( contract test { function() { int x = -3; int y = -4; x ** y; } } )"; - BOOST_CHECK(expectError(sourceCode3) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode3).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(reference_compare_operators) @@ -2134,11 +2134,11 @@ BOOST_AUTO_TEST_CASE(reference_compare_operators) char const* sourceCode1 = R"( contract test { bytes a; bytes b; function() { a == b; } } )"; - BOOST_CHECK(expectError(sourceCode1) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode1).type() == Error::Type::TypeError); char const* sourceCode2 = R"( contract test { struct s {uint a;} s x; s y; function() { x == y; } } )"; - BOOST_CHECK(expectError(sourceCode2) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode2).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(overwrite_memory_location_external) @@ -2148,7 +2148,7 @@ BOOST_AUTO_TEST_CASE(overwrite_memory_location_external) function f(uint[] memory a) external {} } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(overwrite_storage_location_external) @@ -2158,7 +2158,7 @@ BOOST_AUTO_TEST_CASE(overwrite_storage_location_external) function f(uint[] storage a) external {} } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(storage_location_local_variables) @@ -2184,7 +2184,7 @@ BOOST_AUTO_TEST_CASE(no_mappings_in_memory_array) } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(assignment_mem_to_local_storage_variable) @@ -2198,7 +2198,7 @@ BOOST_AUTO_TEST_CASE(assignment_mem_to_local_storage_variable) } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(storage_assign_to_different_local_variable) @@ -2215,7 +2215,7 @@ BOOST_AUTO_TEST_CASE(storage_assign_to_different_local_variable) } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers) @@ -2229,7 +2229,7 @@ BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers) } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(assignment_mem_storage_variable_directly) @@ -2256,7 +2256,7 @@ BOOST_AUTO_TEST_CASE(function_argument_mem_to_storage) } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(function_argument_storage_to_mem) @@ -2285,7 +2285,7 @@ BOOST_AUTO_TEST_CASE(mem_array_assignment_changes_base_type) } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) @@ -2300,7 +2300,7 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(memory_arrays_not_resizeable) @@ -2313,7 +2313,7 @@ BOOST_AUTO_TEST_CASE(memory_arrays_not_resizeable) } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(struct_constructor) @@ -2379,7 +2379,7 @@ BOOST_AUTO_TEST_CASE(invalid_integer_literal_exp) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(memory_structs_with_mappings) @@ -2394,7 +2394,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_with_mappings) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(string_bytes_conversion) @@ -2420,7 +2420,7 @@ BOOST_AUTO_TEST_CASE(inheriting_from_library) library Lib {} contract Test is Lib {} )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(inheriting_library) @@ -2429,7 +2429,7 @@ BOOST_AUTO_TEST_CASE(inheriting_library) contract Test {} library Lib is Test {} )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(library_having_variables) @@ -2437,7 +2437,7 @@ BOOST_AUTO_TEST_CASE(library_having_variables) char const* text = R"( library Lib { uint x; } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(valid_library) @@ -2470,7 +2470,7 @@ BOOST_AUTO_TEST_CASE(creating_contract_within_the_contract) function f() { var x = new Test(); } } )"; - BOOST_CHECK(expectError(sourceCode) == Error::Type::TypeError); + BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(array_out_of_bound_access) @@ -2484,7 +2484,7 @@ BOOST_AUTO_TEST_CASE(array_out_of_bound_access) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(literal_string_to_storage_pointer) @@ -2494,7 +2494,7 @@ BOOST_AUTO_TEST_CASE(literal_string_to_storage_pointer) function f() { string x = "abc"; } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(non_initialized_references) @@ -2513,7 +2513,7 @@ BOOST_AUTO_TEST_CASE(non_initialized_references) } )"; - BOOST_CHECK(expectError(text, true) == Error::Type::Warning); + BOOST_CHECK(expectError(text, true).regex_search("Uninitialized storage pointer")); } BOOST_AUTO_TEST_CASE(sha3_with_large_integer_constant) @@ -2524,7 +2524,7 @@ BOOST_AUTO_TEST_CASE(sha3_with_large_integer_constant) function f() { sha3(2**500); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(cyclic_binary_dependency) @@ -2534,7 +2534,7 @@ BOOST_AUTO_TEST_CASE(cyclic_binary_dependency) contract B { function f() { new C(); } } contract C { function f() { new A(); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(cyclic_binary_dependency_via_inheritance) @@ -2544,7 +2544,7 @@ BOOST_AUTO_TEST_CASE(cyclic_binary_dependency_via_inheritance) contract B { function f() { new C(); } } contract C { function f() { new A(); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_fail) @@ -2552,7 +2552,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_fail) char const* text = R"( contract C { function f() { var (x,y); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fine) @@ -2583,7 +2583,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_1) function f() { var (a, b, ) = one(); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_2) { @@ -2593,7 +2593,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_2) function f() { var (a, , ) = one(); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_3) @@ -2604,7 +2604,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_3) function f() { var (, , a) = one(); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_4) @@ -2615,7 +2615,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_4) function f() { var (, a, b) = one(); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(tuples) @@ -2642,7 +2642,7 @@ BOOST_AUTO_TEST_CASE(tuples_empty_components) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_5) @@ -2653,7 +2653,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_5) function f() { var (,) = one(); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_6) @@ -2664,7 +2664,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_6) function f() { var (a, b, c) = two(); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(member_access_parser_ambiguity) @@ -2707,7 +2707,7 @@ BOOST_AUTO_TEST_CASE(using_for_not_library) using D for uint; } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(using_for_function_exists) @@ -2798,7 +2798,7 @@ BOOST_AUTO_TEST_CASE(using_for_mismatch) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(using_for_not_used) @@ -2814,7 +2814,7 @@ BOOST_AUTO_TEST_CASE(using_for_not_used) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(library_memory_struct) @@ -2825,7 +2825,7 @@ BOOST_AUTO_TEST_CASE(library_memory_struct) function f() returns (S ) {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(using_for_arbitrary_mismatch) @@ -2840,7 +2840,7 @@ BOOST_AUTO_TEST_CASE(using_for_arbitrary_mismatch) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(bound_function_in_var) @@ -2886,7 +2886,7 @@ BOOST_AUTO_TEST_CASE(mapping_in_memory_array) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(new_for_non_array) @@ -2898,7 +2898,7 @@ BOOST_AUTO_TEST_CASE(new_for_non_array) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(invalid_args_creating_memory_array) @@ -2910,7 +2910,7 @@ BOOST_AUTO_TEST_CASE(invalid_args_creating_memory_array) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(function_overload_array_type) @@ -3030,7 +3030,7 @@ BOOST_AUTO_TEST_CASE(invalid_types_in_inline_array) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(dynamic_inline_array) @@ -3055,7 +3055,7 @@ BOOST_AUTO_TEST_CASE(lvalues_as_inline_array) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(break_not_in_loop) @@ -3068,7 +3068,7 @@ BOOST_AUTO_TEST_CASE(break_not_in_loop) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::SyntaxError); + BOOST_CHECK(expectError(text).type() == Error::Type::SyntaxError); } BOOST_AUTO_TEST_CASE(continue_not_in_loop) @@ -3081,7 +3081,7 @@ BOOST_AUTO_TEST_CASE(continue_not_in_loop) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::SyntaxError); + BOOST_CHECK(expectError(text).type() == Error::Type::SyntaxError); } BOOST_AUTO_TEST_CASE(continue_not_in_loop_2) @@ -3096,7 +3096,7 @@ BOOST_AUTO_TEST_CASE(continue_not_in_loop_2) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::SyntaxError); + BOOST_CHECK(expectError(text).type() == Error::Type::SyntaxError); } BOOST_AUTO_TEST_CASE(invalid_different_types_for_conditional_expression) @@ -3108,7 +3108,7 @@ BOOST_AUTO_TEST_CASE(invalid_different_types_for_conditional_expression) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(left_value_in_conditional_expression_not_supported_yet) @@ -3122,7 +3122,7 @@ BOOST_AUTO_TEST_CASE(left_value_in_conditional_expression_not_supported_yet) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(conditional_expression_with_different_struct) @@ -3142,7 +3142,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_struct) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(conditional_expression_with_different_function_type) @@ -3157,7 +3157,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_function_type) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(conditional_expression_with_different_enum) @@ -3175,7 +3175,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_enum) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(conditional_expression_with_different_mapping) @@ -3190,7 +3190,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_mapping) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(conditional_with_all_types) @@ -3287,7 +3287,7 @@ BOOST_AUTO_TEST_CASE(constructor_call_invalid_arg_count) } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(index_access_for_bytes) @@ -3909,7 +3909,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_send) } } )"; - BOOST_CHECK(expectError(text, true) == Error::Type::Warning); + BOOST_CHECK(expectError(text, true).regex_search("Return value of low-level calls not used")); } BOOST_AUTO_TEST_CASE(unused_return_value_call) @@ -3921,7 +3921,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_call) } } )"; - BOOST_CHECK(expectError(text, true) == Error::Type::Warning); + BOOST_CHECK(expectError(text, true).regex_search("Return value of low-level calls not used")); } BOOST_AUTO_TEST_CASE(unused_return_value_call_value) @@ -3933,7 +3933,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_call_value) } } )"; - BOOST_CHECK(expectError(text, true) == Error::Type::Warning); + BOOST_CHECK(expectError(text, true).regex_search("Return value of low-level calls not used")); } BOOST_AUTO_TEST_CASE(unused_return_value_callcode) @@ -3945,7 +3945,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_callcode) } } )"; - BOOST_CHECK(expectError(text, true) == Error::Type::Warning); + BOOST_CHECK(expectError(text, true).regex_search("Return value of low-level calls not used")); } BOOST_AUTO_TEST_CASE(unused_return_value_delegatecall) @@ -3957,7 +3957,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_delegatecall) } } )"; - BOOST_CHECK(expectError(text, true) == Error::Type::Warning); + BOOST_CHECK(expectError(text, true).regex_search("Return value of low-level calls not used")); } BOOST_AUTO_TEST_CASE(modifier_without_underscore) @@ -3967,7 +3967,7 @@ BOOST_AUTO_TEST_CASE(modifier_without_underscore) modifier m() {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::SyntaxError); + BOOST_CHECK(expectError(text).type() == Error::Type::SyntaxError); } BOOST_AUTO_TEST_CASE(payable_in_library) @@ -3977,7 +3977,7 @@ BOOST_AUTO_TEST_CASE(payable_in_library) function f() payable {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(payable_external) @@ -3997,7 +3997,7 @@ BOOST_AUTO_TEST_CASE(payable_internal) function f() payable internal {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(payable_private) @@ -4007,7 +4007,7 @@ BOOST_AUTO_TEST_CASE(payable_private) function f() payable private {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(illegal_override_payable) @@ -4016,7 +4016,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_payable) contract B { function f() payable {} } contract C is B { function f() {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable) @@ -4025,7 +4025,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable) contract B { function f() {} } contract C is B { function f() payable {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(payable_constant_conflict) @@ -4033,7 +4033,7 @@ BOOST_AUTO_TEST_CASE(payable_constant_conflict) char const* text = R"( contract C { function f() payable constant {} } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(calling_payable) @@ -4057,7 +4057,7 @@ BOOST_AUTO_TEST_CASE(calling_nonpayable) function f() { (new receiver()).nopay.value(10)(); } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(non_payable_constructor) @@ -4073,7 +4073,7 @@ BOOST_AUTO_TEST_CASE(non_payable_constructor) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma) @@ -4082,7 +4082,7 @@ BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma) auto sourceAndError = parseAnalyseAndReturnError(text, true, false); BOOST_REQUIRE(!!sourceAndError.second); BOOST_REQUIRE(!!sourceAndError.first); - BOOST_CHECK(*sourceAndError.second == Error::Type::Warning); + BOOST_CHECK(sourceAndError.second->regex_search("Source file does not specify required compiler version!")); } BOOST_AUTO_TEST_CASE(unsatisfied_version) @@ -4090,7 +4090,7 @@ BOOST_AUTO_TEST_CASE(unsatisfied_version) char const* text = R"( pragma solidity ^99.99.0; )"; - BOOST_CHECK(expectError(text, true) == Error::Type::SyntaxError); + BOOST_CHECK(expectError(text, true).type() == Error::Type::SyntaxError); } BOOST_AUTO_TEST_CASE(constant_constructor) @@ -4100,7 +4100,7 @@ BOOST_AUTO_TEST_CASE(constant_constructor) function test() constant {} } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(external_constructor) @@ -4110,7 +4110,7 @@ BOOST_AUTO_TEST_CASE(external_constructor) function test() external {} } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(invalid_array_as_statement) @@ -4121,7 +4121,7 @@ BOOST_AUTO_TEST_CASE(invalid_array_as_statement) function test(uint k) { S[k]; } } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(using_directive_for_missing_selftype) @@ -4140,7 +4140,7 @@ BOOST_AUTO_TEST_CASE(using_directive_for_missing_selftype) } } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(function_type) @@ -4188,7 +4188,7 @@ BOOST_AUTO_TEST_CASE(private_function_type) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(public_function_type) @@ -4200,7 +4200,7 @@ BOOST_AUTO_TEST_CASE(public_function_type) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(payable_internal_function_type) @@ -4210,7 +4210,7 @@ BOOST_AUTO_TEST_CASE(payable_internal_function_type) function (uint) internal payable returns (uint) x; } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(call_value_on_non_payable_function_type) @@ -4223,7 +4223,7 @@ BOOST_AUTO_TEST_CASE(call_value_on_non_payable_function_type) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(external_function_type_returning_internal) @@ -4233,7 +4233,7 @@ BOOST_AUTO_TEST_CASE(external_function_type_returning_internal) function() external returns (function () internal) x; } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(external_function_type_taking_internal) @@ -4243,7 +4243,7 @@ BOOST_AUTO_TEST_CASE(external_function_type_taking_internal) function(function () internal) external x; } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(call_value_on_payable_function_type) @@ -4269,7 +4269,7 @@ BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(internal_function_returned_from_public_function) @@ -4281,7 +4281,7 @@ BOOST_AUTO_TEST_CASE(internal_function_returned_from_public_function) } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter_in_library_internal) @@ -4303,7 +4303,7 @@ BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter_in_library_external } } )"; - BOOST_CHECK(expectError(text) == Error::Type::TypeError); + BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(function_type_arrays) @@ -4353,7 +4353,7 @@ BOOST_AUTO_TEST_CASE(delete_function_type_invalid) } } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(delete_external_function_type_invalid) @@ -4365,7 +4365,7 @@ BOOST_AUTO_TEST_CASE(delete_external_function_type_invalid) } } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(invalid_fixed_point_literal) @@ -4377,7 +4377,7 @@ BOOST_AUTO_TEST_CASE(invalid_fixed_point_literal) } } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(shift_constant_left_negative_rvalue) @@ -4387,7 +4387,7 @@ BOOST_AUTO_TEST_CASE(shift_constant_left_negative_rvalue) uint public a = 0x42 << -8; } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(shift_constant_right_negative_rvalue) @@ -4397,7 +4397,7 @@ BOOST_AUTO_TEST_CASE(shift_constant_right_negative_rvalue) uint public a = 0x42 >> -8; } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(shift_constant_left_excessive_rvalue) @@ -4407,7 +4407,7 @@ BOOST_AUTO_TEST_CASE(shift_constant_left_excessive_rvalue) uint public a = 0x42 << 0x100000000; } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(shift_constant_right_excessive_rvalue) @@ -4417,7 +4417,7 @@ BOOST_AUTO_TEST_CASE(shift_constant_right_excessive_rvalue) uint public a = 0x42 >> 0x100000000; } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_positive_stack) @@ -4431,7 +4431,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_positive_stack) } } )"; - BOOST_CHECK(expectError(text, true) == Error::Type::Warning); + BOOST_CHECK(expectError(text, true).regex_search("Inline assembly block is not balanced")); } BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_negative_stack) @@ -4445,7 +4445,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_negative_stack) } } )"; - BOOST_CHECK(expectError(text, true) == Error::Type::Warning); + BOOST_CHECK(expectError(text, true).regex_search("Inline assembly block is not balanced")); } BOOST_AUTO_TEST_CASE(inline_assembly_in_modifier) @@ -4478,7 +4478,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage) } } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(inline_assembly_storage_in_modifiers) @@ -4496,7 +4496,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_in_modifiers) } } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::DeclarationError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::DeclarationError); } BOOST_AUTO_TEST_CASE(invalid_mobile_type) @@ -4509,7 +4509,7 @@ BOOST_AUTO_TEST_CASE(invalid_mobile_type) } } )"; - BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); + BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); } BOOST_AUTO_TEST_SUITE_END() -- cgit From cace51fc470f2ff75e52637e10aa5100f3ca5be6 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Mon, 21 Nov 2016 19:31:31 +0100 Subject: test: wrapping the error message checking in a macro --- test/libsolidity/SolidityNameAndTypeResolution.cpp | 566 +++++++++++---------- 1 file changed, 294 insertions(+), 272 deletions(-) (limited to 'test/libsolidity') diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 6932f852..57ee86d6 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -160,6 +160,28 @@ static FunctionTypePointer retrieveFunctionBySignature( } +#define CHECK_ERROR_OR_WARNING(text, typ, substring, warning) \ +do \ +{ \ + Error err = expectError((text), (warning)); \ + BOOST_CHECK(err.type() == (Error::Type::typ)); \ + BOOST_CHECK(err.regex_search({substring})); \ +} while(0) + +// [checkError(text, type, substring)] asserts that the compilation down to typechecking +// emits an error of type [type] and with a message containing [substring]. +#define CHECK_ERROR(text, type, substring) \ +CHECK_ERROR_OR_WARNING(text, type, substring, false) + +// [checkWarning(text, type, substring)] asserts that the compilation down to typechecking +// emits a warning of type [type] and with a message containing [substring]. +#define CHECK_WARNING(text, substring) \ +CHECK_ERROR_OR_WARNING(text, Warning, substring, true) + +// [checkSuccess(text)] asserts that the compilation down to typechecking succeeds. +#define CHECK_SUCCESS(text) do { BOOST_CHECK(success((text))); } while(0) + + BOOST_AUTO_TEST_SUITE(SolidityNameAndTypeResolution) BOOST_AUTO_TEST_CASE(smoke_test) @@ -168,7 +190,7 @@ BOOST_AUTO_TEST_CASE(smoke_test) " uint256 stateVariable1;\n" " function fun(uint256 arg1) { uint256 y; }" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(double_stateVariable_declaration) @@ -177,7 +199,7 @@ BOOST_AUTO_TEST_CASE(double_stateVariable_declaration) " uint256 variable;\n" " uint128 variable;\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); + CHECK_ERROR(text, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(double_function_declaration) @@ -186,7 +208,7 @@ BOOST_AUTO_TEST_CASE(double_function_declaration) " function fun() { uint x; }\n" " function fun() { uint x; }\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); + CHECK_ERROR(text, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(double_variable_declaration) @@ -194,7 +216,7 @@ BOOST_AUTO_TEST_CASE(double_variable_declaration) char const* text = "contract test {\n" " function f() { uint256 x; if (true) { uint256 x; } }\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); + CHECK_ERROR(text, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(name_shadowing) @@ -203,7 +225,7 @@ BOOST_AUTO_TEST_CASE(name_shadowing) " uint256 variable;\n" " function f() { uint32 variable ; }" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(name_references) @@ -212,7 +234,7 @@ BOOST_AUTO_TEST_CASE(name_references) " uint256 variable;\n" " function f(uint256 arg) returns (uint out) { f(variable); test; out; }" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(undeclared_name) @@ -221,7 +243,7 @@ BOOST_AUTO_TEST_CASE(undeclared_name) " uint256 variable;\n" " function f(uint256 arg) { f(notfound); }" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); + CHECK_ERROR(text, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(reference_to_later_declaration) @@ -230,7 +252,7 @@ BOOST_AUTO_TEST_CASE(reference_to_later_declaration) " function g() { f(); }" " function f() { }" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(struct_definition_directly_recursive) @@ -241,7 +263,7 @@ BOOST_AUTO_TEST_CASE(struct_definition_directly_recursive) " MyStructName x;\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(struct_definition_indirectly_recursive) @@ -256,7 +278,7 @@ BOOST_AUTO_TEST_CASE(struct_definition_indirectly_recursive) " MyStructName1 x;\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(struct_definition_not_really_recursive) @@ -267,7 +289,7 @@ BOOST_AUTO_TEST_CASE(struct_definition_not_really_recursive) struct s2 { s1 x; s1 y; } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(struct_definition_recursion_via_mapping) @@ -279,7 +301,7 @@ BOOST_AUTO_TEST_CASE(struct_definition_recursion_via_mapping) " mapping(uint => MyStructName1) x;\n" " }\n" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(type_inference_smoke_test) @@ -287,7 +309,7 @@ BOOST_AUTO_TEST_CASE(type_inference_smoke_test) char const* text = "contract test {\n" " function f(uint256 arg1, uint32 arg2) returns (bool ret) { var x = arg1 + arg2 == 8; ret = x; }" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(type_checking_return) @@ -295,7 +317,7 @@ BOOST_AUTO_TEST_CASE(type_checking_return) char const* text = "contract test {\n" " function f() returns (bool r) { return 1 >= 2; }" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(type_checking_return_wrong_number) @@ -303,7 +325,7 @@ BOOST_AUTO_TEST_CASE(type_checking_return_wrong_number) char const* text = "contract test {\n" " function f() returns (bool r1, bool r2) { return 1 >= 2; }" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(type_checking_return_wrong_type) @@ -311,7 +333,7 @@ BOOST_AUTO_TEST_CASE(type_checking_return_wrong_type) char const* text = "contract test {\n" " function f() returns (uint256 r) { return 1 >= 2; }" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(type_checking_function_call) @@ -320,7 +342,7 @@ BOOST_AUTO_TEST_CASE(type_checking_function_call) " function f() returns (bool r) { return g(12, true) == 3; }\n" " function g(uint256 a, bool b) returns (uint256 r) { }\n" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(type_conversion_for_comparison) @@ -328,7 +350,7 @@ BOOST_AUTO_TEST_CASE(type_conversion_for_comparison) char const* text = "contract test {\n" " function f() { uint32(2) == int64(2); }" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(type_conversion_for_comparison_invalid) @@ -336,7 +358,7 @@ BOOST_AUTO_TEST_CASE(type_conversion_for_comparison_invalid) char const* text = "contract test {\n" " function f() { int32(2) == uint64(2); }" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(type_inference_explicit_conversion) @@ -344,7 +366,7 @@ BOOST_AUTO_TEST_CASE(type_inference_explicit_conversion) char const* text = "contract test {\n" " function f() returns (int256 r) { var x = int256(uint32(2)); return x; }" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(large_string_literal) @@ -352,7 +374,7 @@ BOOST_AUTO_TEST_CASE(large_string_literal) char const* text = "contract test {\n" " function f() { var x = \"123456789012345678901234567890123\"; }" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(balance) @@ -362,7 +384,7 @@ BOOST_AUTO_TEST_CASE(balance) " uint256 x = address(0).balance;\n" " }\n" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(balance_invalid) @@ -372,7 +394,7 @@ BOOST_AUTO_TEST_CASE(balance_invalid) " address(0).balance = 7;\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(assignment_to_mapping) @@ -387,7 +409,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_mapping) " data.map = a;\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(assignment_to_struct) @@ -402,7 +424,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_struct) " data = a;\n" " }\n" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(returns_in_constructor) @@ -411,7 +433,7 @@ BOOST_AUTO_TEST_CASE(returns_in_constructor) " function test() returns (uint a) {\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(forward_function_reference) @@ -426,7 +448,7 @@ BOOST_AUTO_TEST_CASE(forward_function_reference) " if (First(2).fun() == true) return 1;\n" " }\n" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(comparison_bitop_precedence) @@ -436,7 +458,7 @@ BOOST_AUTO_TEST_CASE(comparison_bitop_precedence) " return 1 & 2 == 8 & 9 && 1 ^ 2 < 4 | 6;\n" " }\n" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(function_no_implementation) @@ -499,7 +521,7 @@ BOOST_AUTO_TEST_CASE(create_abstract_contract) function foo() { b = new base();} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(abstract_contract_constructor_args_optional) @@ -543,7 +565,7 @@ BOOST_AUTO_TEST_CASE(redeclare_implemented_abstract_function_as_abstract) contract derived is base { function foo() {} } contract wrong is derived { function foo(); } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(implement_abstract_via_constructor) @@ -653,7 +675,7 @@ BOOST_AUTO_TEST_CASE(function_external_call_allowed_conversion) } function g (C c) external {} })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(function_external_call_not_allowed_conversion) @@ -667,7 +689,7 @@ BOOST_AUTO_TEST_CASE(function_external_call_not_allowed_conversion) } function g (C c) external {} })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(function_internal_allowed_conversion) @@ -683,7 +705,7 @@ BOOST_AUTO_TEST_CASE(function_internal_allowed_conversion) g(a); } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(function_internal_not_allowed_conversion) @@ -699,7 +721,7 @@ BOOST_AUTO_TEST_CASE(function_internal_not_allowed_conversion) g(a); } })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(hash_collision_in_interface) @@ -710,7 +732,7 @@ BOOST_AUTO_TEST_CASE(hash_collision_in_interface) " function tgeo() {\n" " }\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(inheritance_basic) @@ -722,7 +744,7 @@ BOOST_AUTO_TEST_CASE(inheritance_basic) function f() { baseMember = 7; } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inheritance_diamond_basic) @@ -735,7 +757,7 @@ BOOST_AUTO_TEST_CASE(inheritance_diamond_basic) function g() { f(); rootFunction(); } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(cyclic_inheritance) @@ -744,7 +766,7 @@ BOOST_AUTO_TEST_CASE(cyclic_inheritance) contract A is B { } contract B is A { } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(legal_override_direct) @@ -753,7 +775,7 @@ BOOST_AUTO_TEST_CASE(legal_override_direct) contract B { function f() {} } contract C is B { function f(uint i) {} } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(legal_override_indirect) @@ -763,7 +785,7 @@ BOOST_AUTO_TEST_CASE(legal_override_indirect) contract B { function f() {} } contract C is A, B { } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(illegal_override_visibility) @@ -772,7 +794,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_visibility) contract B { function f() internal {} } contract C is B { function f() public {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(illegal_override_constness) @@ -781,7 +803,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_constness) contract B { function f() constant {} } contract C is B { function f() {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(complex_inheritance) @@ -791,7 +813,7 @@ BOOST_AUTO_TEST_CASE(complex_inheritance) contract B { function f() {} function g() returns (uint8 r) {} } contract C is A, B { } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(constructor_visibility) @@ -801,7 +823,7 @@ BOOST_AUTO_TEST_CASE(constructor_visibility) contract A { function A() { } } contract B is A { function f() { A x = A(0); } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(overriding_constructor) @@ -811,7 +833,7 @@ BOOST_AUTO_TEST_CASE(overriding_constructor) contract A { function A() { } } contract B is A { function A() returns (uint8 r) {} } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(missing_base_constructor_arguments) @@ -820,7 +842,7 @@ BOOST_AUTO_TEST_CASE(missing_base_constructor_arguments) contract A { function A(uint a) { } } contract B is A { } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(base_constructor_arguments_override) @@ -829,7 +851,7 @@ BOOST_AUTO_TEST_CASE(base_constructor_arguments_override) contract A { function A(uint a) { } } contract B is A { } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(implicit_derived_to_base_conversion) @@ -840,7 +862,7 @@ BOOST_AUTO_TEST_CASE(implicit_derived_to_base_conversion) function f() { A a = B(1); } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(implicit_base_to_derived_conversion) @@ -851,7 +873,7 @@ BOOST_AUTO_TEST_CASE(implicit_base_to_derived_conversion) function f() { B b = A(1); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(super_excludes_current_contract) @@ -868,7 +890,7 @@ BOOST_AUTO_TEST_CASE(super_excludes_current_contract) } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(function_modifier_invocation) @@ -880,7 +902,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation) modifier mod2(bytes7 a) { while (a == "1234567") _; } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(invalid_function_modifier_type) @@ -891,7 +913,7 @@ BOOST_AUTO_TEST_CASE(invalid_function_modifier_type) modifier mod1(uint a) { if (a > 0) _; } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(function_modifier_invocation_parameters) @@ -903,7 +925,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation_parameters) modifier mod2(bytes7 a) { while (a == "1234567") _; } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(function_modifier_invocation_local_variables) @@ -914,7 +936,7 @@ BOOST_AUTO_TEST_CASE(function_modifier_invocation_local_variables) modifier mod(uint a) { if (a > 0) _; } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(legal_modifier_override) @@ -923,7 +945,7 @@ BOOST_AUTO_TEST_CASE(legal_modifier_override) contract A { modifier mod(uint a) { _; } } contract B is A { modifier mod(uint a) { _; } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(illegal_modifier_override) @@ -932,7 +954,7 @@ BOOST_AUTO_TEST_CASE(illegal_modifier_override) contract A { modifier mod(uint a) { _; } } contract B is A { modifier mod(uint8 a) { _; } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(modifier_overrides_function) @@ -941,7 +963,7 @@ BOOST_AUTO_TEST_CASE(modifier_overrides_function) contract A { modifier mod(uint a) { _; } } contract B is A { function mod(uint a) { } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(function_overrides_modifier) @@ -950,7 +972,7 @@ BOOST_AUTO_TEST_CASE(function_overrides_modifier) contract A { function mod(uint a) { } } contract B is A { modifier mod(uint a) { _; } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(modifier_returns_value) @@ -961,7 +983,7 @@ BOOST_AUTO_TEST_CASE(modifier_returns_value) modifier mod(uint a) { _; return 7; } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(state_variable_accessors) @@ -1012,7 +1034,7 @@ BOOST_AUTO_TEST_CASE(function_clash_with_state_variable_accessor) "uint256 foo;\n" " function foo() {}\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); + CHECK_ERROR(text, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(private_state_variable) @@ -1045,7 +1067,7 @@ BOOST_AUTO_TEST_CASE(missing_state_variable) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } @@ -1058,7 +1080,7 @@ BOOST_AUTO_TEST_CASE(base_class_state_variable_accessor) "contract Child is Parent{\n" " function foo() returns (uint256) { return Parent.m_aMember; }\n" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(struct_accessor_one_array_only) @@ -1080,7 +1102,7 @@ BOOST_AUTO_TEST_CASE(base_class_state_variable_internal_member) "contract Child is Parent{\n" " function foo() returns (uint256) { return Parent.m_aMember; }\n" "}\n"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class1) @@ -1094,7 +1116,7 @@ BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class1) "contract Child is Parent2{\n" " function foo() returns (uint256) { return Parent2.m_aMember1; }\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class2) @@ -1109,7 +1131,7 @@ BOOST_AUTO_TEST_CASE(state_variable_member_of_wrong_class2) " function foo() returns (uint256) { return Child.m_aMember2; }\n" " uint256 public m_aMember3;\n" "}\n"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(fallback_function) @@ -1120,7 +1142,7 @@ BOOST_AUTO_TEST_CASE(fallback_function) function() { x = 2; } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(fallback_function_with_arguments) @@ -1131,7 +1153,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_with_arguments) function(uint a) { x = 2; } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(fallback_function_in_library) @@ -1141,7 +1163,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_in_library) function() {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(fallback_function_with_return_parameters) @@ -1151,7 +1173,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_with_return_parameters) function() returns (uint) { } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(fallback_function_with_constant_modifier) @@ -1162,7 +1184,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_with_constant_modifier) function() constant { x = 2; } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(fallback_function_twice) @@ -1174,7 +1196,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_twice) function() { x = 3; } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); + CHECK_ERROR(text, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(fallback_function_inheritance) @@ -1188,7 +1210,7 @@ BOOST_AUTO_TEST_CASE(fallback_function_inheritance) function() { x = 2; } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(event) @@ -1198,7 +1220,7 @@ BOOST_AUTO_TEST_CASE(event) event e(uint indexed a, bytes3 indexed s, bool indexed b); function f() { e(2, "abc", true); } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(event_too_many_indexed) @@ -1207,7 +1229,7 @@ BOOST_AUTO_TEST_CASE(event_too_many_indexed) contract c { event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d); })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(anonymous_event_four_indexed) @@ -1216,7 +1238,7 @@ BOOST_AUTO_TEST_CASE(anonymous_event_four_indexed) contract c { event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d) anonymous; })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(anonymous_event_too_many_indexed) @@ -1225,7 +1247,7 @@ BOOST_AUTO_TEST_CASE(anonymous_event_too_many_indexed) contract c { event e(uint indexed a, bytes3 indexed b, bool indexed c, uint indexed d, uint indexed e) anonymous; })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(event_call) @@ -1235,7 +1257,7 @@ BOOST_AUTO_TEST_CASE(event_call) event e(uint a, bytes3 indexed s, bool indexed b); function f() { e(2, "abc", true); } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(event_inheritance) @@ -1247,7 +1269,7 @@ BOOST_AUTO_TEST_CASE(event_inheritance) contract c is base { function f() { e(2, "abc", true); } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(multiple_events_argument_clash) @@ -1257,7 +1279,7 @@ BOOST_AUTO_TEST_CASE(multiple_events_argument_clash) event e1(uint a, uint e1, uint e2); event e2(uint a, uint e1, uint e2); })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(access_to_default_function_visibility) @@ -1269,7 +1291,7 @@ BOOST_AUTO_TEST_CASE(access_to_default_function_visibility) contract d { function g() { c(0).f(); } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(access_to_internal_function) @@ -1281,7 +1303,7 @@ BOOST_AUTO_TEST_CASE(access_to_internal_function) contract d { function g() { c(0).f(); } })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(access_to_default_state_variable_visibility) @@ -1293,7 +1315,7 @@ BOOST_AUTO_TEST_CASE(access_to_default_state_variable_visibility) contract d { function g() { c(0).a(); } })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(access_to_internal_state_variable) @@ -1305,7 +1327,7 @@ BOOST_AUTO_TEST_CASE(access_to_internal_state_variable) contract d { function g() { c(0).a(); } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(error_count_in_named_args) @@ -1314,7 +1336,7 @@ BOOST_AUTO_TEST_CASE(error_count_in_named_args) " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" " function b() returns (uint r) { r = a({a: 1}); }\n" "}\n"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(empty_in_named_args) @@ -1323,7 +1345,7 @@ BOOST_AUTO_TEST_CASE(empty_in_named_args) " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" " function b() returns (uint r) { r = a({}); }\n" "}\n"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(duplicate_parameter_names_in_named_args) @@ -1332,7 +1354,7 @@ BOOST_AUTO_TEST_CASE(duplicate_parameter_names_in_named_args) " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" " function b() returns (uint r) { r = a({a: 1, a: 2}); }\n" "}\n"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(invalid_parameter_names_in_named_args) @@ -1341,7 +1363,7 @@ BOOST_AUTO_TEST_CASE(invalid_parameter_names_in_named_args) " function a(uint a, uint b) returns (uint r) { r = a + b; }\n" " function b() returns (uint r) { r = a({a: 1, c: 2}); }\n" "}\n"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(empty_name_input_parameter) @@ -1351,7 +1373,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter) function f(uint){ } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(empty_name_return_parameter) @@ -1361,7 +1383,7 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter) function f() returns(bool){ } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one) @@ -1372,7 +1394,7 @@ BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one) return k; } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(empty_name_return_parameter_with_named_one) @@ -1383,13 +1405,13 @@ BOOST_AUTO_TEST_CASE(empty_name_return_parameter_with_named_one) return 5; } })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(disallow_declaration_of_void_type) { char const* sourceCode = "contract c { function f() { var (x) = f(); } }"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(overflow_caused_by_ether_units) @@ -1412,7 +1434,7 @@ BOOST_AUTO_TEST_CASE(overflow_caused_by_ether_units) } uint256 a; })"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(exp_operator_exponent_too_big) @@ -1421,7 +1443,7 @@ BOOST_AUTO_TEST_CASE(exp_operator_exponent_too_big) contract test { function f() returns(uint d) { return 2 ** 10000000000; } })"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(enum_member_access) @@ -1436,7 +1458,7 @@ BOOST_AUTO_TEST_CASE(enum_member_access) ActionChoices choices; } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(enum_member_access_accross_contracts) @@ -1451,7 +1473,7 @@ BOOST_AUTO_TEST_CASE(enum_member_access_accross_contracts) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(enum_invalid_member_access) @@ -1466,7 +1488,7 @@ BOOST_AUTO_TEST_CASE(enum_invalid_member_access) ActionChoices choices; } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(enum_invalid_direct_member_access) @@ -1481,7 +1503,7 @@ BOOST_AUTO_TEST_CASE(enum_invalid_direct_member_access) ActionChoices choices; } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); + CHECK_ERROR(text, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(enum_explicit_conversion_is_okay) @@ -1498,7 +1520,7 @@ BOOST_AUTO_TEST_CASE(enum_explicit_conversion_is_okay) uint64 b; } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(int_to_enum_explicit_conversion_is_okay) @@ -1515,7 +1537,7 @@ BOOST_AUTO_TEST_CASE(int_to_enum_explicit_conversion_is_okay) ActionChoices b; } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay) @@ -1532,7 +1554,7 @@ BOOST_AUTO_TEST_CASE(enum_implicit_conversion_is_not_okay) uint64 b; } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(enum_to_enum_conversion_is_not_okay) @@ -1547,7 +1569,7 @@ BOOST_AUTO_TEST_CASE(enum_to_enum_conversion_is_not_okay) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(enum_duplicate_values) @@ -1557,7 +1579,7 @@ BOOST_AUTO_TEST_CASE(enum_duplicate_values) enum ActionChoices { GoLeft, GoRight, GoLeft, Sit } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::DeclarationError); + CHECK_ERROR(text, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(enum_name_resolution_under_current_contract_name) @@ -1574,7 +1596,7 @@ BOOST_AUTO_TEST_CASE(enum_name_resolution_under_current_contract_name) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(private_visibility) @@ -1587,7 +1609,7 @@ BOOST_AUTO_TEST_CASE(private_visibility) function g() { f(); } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::DeclarationError); + CHECK_ERROR(sourceCode, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(private_visibility_via_explicit_base_access) @@ -1600,7 +1622,7 @@ BOOST_AUTO_TEST_CASE(private_visibility_via_explicit_base_access) function g() { base.f(); } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(external_visibility) @@ -1611,7 +1633,7 @@ BOOST_AUTO_TEST_CASE(external_visibility) function g() { f(); } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::DeclarationError); + CHECK_ERROR(sourceCode, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(external_base_visibility) @@ -1624,7 +1646,7 @@ BOOST_AUTO_TEST_CASE(external_base_visibility) function g() { base.f(); } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(external_argument_assign) @@ -1634,7 +1656,7 @@ BOOST_AUTO_TEST_CASE(external_argument_assign) function f(uint a) external { a = 1; } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(external_argument_increment) @@ -1644,7 +1666,7 @@ BOOST_AUTO_TEST_CASE(external_argument_increment) function f(uint a) external { a++; } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(external_argument_delete) @@ -1654,7 +1676,7 @@ BOOST_AUTO_TEST_CASE(external_argument_delete) function f(uint a) external { delete a; } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(test_for_bug_override_function_with_bytearray_type) @@ -1676,7 +1698,7 @@ BOOST_AUTO_TEST_CASE(array_with_nonconstant_length) contract c { function f(uint a) { uint8[a] x; } })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(array_copy_with_different_types1) @@ -1687,7 +1709,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types1) uint[] b; function f() { b = a; } })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(array_copy_with_different_types2) @@ -1698,7 +1720,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types2) uint8[] b; function f() { b = a; } })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(array_copy_with_different_types_conversion_possible) @@ -1709,7 +1731,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types_conversion_possible) uint8[] b; function f() { a = b; } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(array_copy_with_different_types_static_dynamic) @@ -1720,7 +1742,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types_static_dynamic) uint8[80] b; function f() { a = b; } })"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(array_copy_with_different_types_dynamic_static) @@ -1731,7 +1753,7 @@ BOOST_AUTO_TEST_CASE(array_copy_with_different_types_dynamic_static) uint[80] b; function f() { b = a; } })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_int) @@ -1740,7 +1762,7 @@ BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_int) contract c { uint8 a = 1000; })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_string) @@ -1749,7 +1771,7 @@ BOOST_AUTO_TEST_CASE(storage_variable_initialization_with_incorrect_type_string) contract c { uint a = "abc"; })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(test_fromElementaryTypeName) @@ -1875,7 +1897,7 @@ BOOST_AUTO_TEST_CASE(assigning_value_to_const_variable) function changeIt() { x = 9; } uint constant x = 56; })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(complex_const_variable) @@ -1885,7 +1907,7 @@ BOOST_AUTO_TEST_CASE(complex_const_variable) contract Foo { mapping(uint => bool) constant mapVar; })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(uninitialized_const_variable) @@ -1894,7 +1916,7 @@ BOOST_AUTO_TEST_CASE(uninitialized_const_variable) contract Foo { uint constant y; })"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(overloaded_function_cannot_resolve) @@ -1906,7 +1928,7 @@ BOOST_AUTO_TEST_CASE(overloaded_function_cannot_resolve) function g() returns(uint) { return f(3, 5); } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(ambiguous_overloaded_function) @@ -1919,7 +1941,7 @@ BOOST_AUTO_TEST_CASE(ambiguous_overloaded_function) function g() returns(uint) { return f(1); } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(assignment_of_nonoverloaded_function) @@ -1942,7 +1964,7 @@ BOOST_AUTO_TEST_CASE(assignment_of_overloaded_function) function g() returns(uint) { var x = f; return x(7); } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(external_types_clash) @@ -1956,7 +1978,7 @@ BOOST_AUTO_TEST_CASE(external_types_clash) function f(uint8 a) { } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(override_changes_return_types) @@ -1969,7 +1991,7 @@ BOOST_AUTO_TEST_CASE(override_changes_return_types) function f(uint a) returns (uint8) { } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(multiple_constructors) @@ -1980,7 +2002,7 @@ BOOST_AUTO_TEST_CASE(multiple_constructors) function test() {} } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::DeclarationError); + CHECK_ERROR(sourceCode, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(equal_overload) @@ -1991,7 +2013,7 @@ BOOST_AUTO_TEST_CASE(equal_overload) function test(uint a) external {} } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::DeclarationError); + CHECK_ERROR(sourceCode, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(uninitialized_var) @@ -2001,7 +2023,7 @@ BOOST_AUTO_TEST_CASE(uninitialized_var) function f() returns (uint) { var x; return 2; } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(string) @@ -2023,7 +2045,7 @@ BOOST_AUTO_TEST_CASE(string_index) function f() { var a = s[2]; } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(string_length) @@ -2034,7 +2056,7 @@ BOOST_AUTO_TEST_CASE(string_length) function f() { var a = s.length; } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(negative_integers_to_signed_out_of_bound) @@ -2044,7 +2066,7 @@ BOOST_AUTO_TEST_CASE(negative_integers_to_signed_out_of_bound) int8 public i = -129; } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(negative_integers_to_signed_min) @@ -2064,7 +2086,7 @@ BOOST_AUTO_TEST_CASE(positive_integers_to_signed_out_of_bound) int8 public j = 128; } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(positive_integers_to_signed_out_of_bound_max) @@ -2084,7 +2106,7 @@ BOOST_AUTO_TEST_CASE(negative_integers_to_unsigned) uint8 public x = -1; } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(positive_integers_to_unsigned_out_of_bound) @@ -2094,7 +2116,7 @@ BOOST_AUTO_TEST_CASE(positive_integers_to_unsigned_out_of_bound) uint8 public x = 700; } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(integer_boolean_operators) @@ -2148,7 +2170,7 @@ BOOST_AUTO_TEST_CASE(overwrite_memory_location_external) function f(uint[] memory a) external {} } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(overwrite_storage_location_external) @@ -2158,7 +2180,7 @@ BOOST_AUTO_TEST_CASE(overwrite_storage_location_external) function f(uint[] storage a) external {} } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(storage_location_local_variables) @@ -2184,7 +2206,7 @@ BOOST_AUTO_TEST_CASE(no_mappings_in_memory_array) } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(assignment_mem_to_local_storage_variable) @@ -2198,7 +2220,7 @@ BOOST_AUTO_TEST_CASE(assignment_mem_to_local_storage_variable) } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(storage_assign_to_different_local_variable) @@ -2215,7 +2237,7 @@ BOOST_AUTO_TEST_CASE(storage_assign_to_different_local_variable) } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers) @@ -2229,7 +2251,7 @@ BOOST_AUTO_TEST_CASE(no_delete_on_storage_pointers) } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(assignment_mem_storage_variable_directly) @@ -2256,7 +2278,7 @@ BOOST_AUTO_TEST_CASE(function_argument_mem_to_storage) } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(function_argument_storage_to_mem) @@ -2285,7 +2307,7 @@ BOOST_AUTO_TEST_CASE(mem_array_assignment_changes_base_type) } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) @@ -2300,7 +2322,7 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(memory_arrays_not_resizeable) @@ -2313,7 +2335,7 @@ BOOST_AUTO_TEST_CASE(memory_arrays_not_resizeable) } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(struct_constructor) @@ -2367,7 +2389,7 @@ BOOST_AUTO_TEST_CASE(literal_strings) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(invalid_integer_literal_exp) @@ -2379,7 +2401,7 @@ BOOST_AUTO_TEST_CASE(invalid_integer_literal_exp) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(memory_structs_with_mappings) @@ -2394,7 +2416,7 @@ BOOST_AUTO_TEST_CASE(memory_structs_with_mappings) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(string_bytes_conversion) @@ -2411,7 +2433,7 @@ BOOST_AUTO_TEST_CASE(string_bytes_conversion) function m() internal { string(b); } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inheriting_from_library) @@ -2420,7 +2442,7 @@ BOOST_AUTO_TEST_CASE(inheriting_from_library) library Lib {} contract Test is Lib {} )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(inheriting_library) @@ -2429,7 +2451,7 @@ BOOST_AUTO_TEST_CASE(inheriting_library) contract Test {} library Lib is Test {} )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(library_having_variables) @@ -2437,7 +2459,7 @@ BOOST_AUTO_TEST_CASE(library_having_variables) char const* text = R"( library Lib { uint x; } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(valid_library) @@ -2445,7 +2467,7 @@ BOOST_AUTO_TEST_CASE(valid_library) char const* text = R"( library Lib { uint constant x = 9; } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(call_to_library_function) @@ -2460,7 +2482,7 @@ BOOST_AUTO_TEST_CASE(call_to_library_function) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(creating_contract_within_the_contract) @@ -2470,7 +2492,7 @@ BOOST_AUTO_TEST_CASE(creating_contract_within_the_contract) function f() { var x = new Test(); } } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(array_out_of_bound_access) @@ -2484,7 +2506,7 @@ BOOST_AUTO_TEST_CASE(array_out_of_bound_access) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(literal_string_to_storage_pointer) @@ -2494,7 +2516,7 @@ BOOST_AUTO_TEST_CASE(literal_string_to_storage_pointer) function f() { string x = "abc"; } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(non_initialized_references) @@ -2513,7 +2535,7 @@ BOOST_AUTO_TEST_CASE(non_initialized_references) } )"; - BOOST_CHECK(expectError(text, true).regex_search("Uninitialized storage pointer")); + CHECK_WARNING(text, "Uninitialized storage pointer"); } BOOST_AUTO_TEST_CASE(sha3_with_large_integer_constant) @@ -2524,7 +2546,7 @@ BOOST_AUTO_TEST_CASE(sha3_with_large_integer_constant) function f() { sha3(2**500); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(cyclic_binary_dependency) @@ -2534,7 +2556,7 @@ BOOST_AUTO_TEST_CASE(cyclic_binary_dependency) contract B { function f() { new C(); } } contract C { function f() { new A(); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(cyclic_binary_dependency_via_inheritance) @@ -2544,7 +2566,7 @@ BOOST_AUTO_TEST_CASE(cyclic_binary_dependency_via_inheritance) contract B { function f() { new C(); } } contract C { function f() { new A(); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_fail) @@ -2552,7 +2574,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_fail) char const* text = R"( contract C { function f() { var (x,y); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fine) @@ -2572,7 +2594,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fine) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_1) @@ -2583,7 +2605,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_1) function f() { var (a, b, ) = one(); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_2) { @@ -2593,7 +2615,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_2) function f() { var (a, , ) = one(); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_3) @@ -2604,7 +2626,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_3) function f() { var (, , a) = one(); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_4) @@ -2615,7 +2637,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_4) function f() { var (, a, b) = one(); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(tuples) @@ -2630,7 +2652,7 @@ BOOST_AUTO_TEST_CASE(tuples) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(tuples_empty_components) @@ -2642,7 +2664,7 @@ BOOST_AUTO_TEST_CASE(tuples_empty_components) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_5) @@ -2653,7 +2675,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_5) function f() { var (,) = one(); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_6) @@ -2664,7 +2686,7 @@ BOOST_AUTO_TEST_CASE(multi_variable_declaration_wildcards_fail_6) function f() { var (a, b, c) = two(); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(member_access_parser_ambiguity) @@ -2685,7 +2707,7 @@ BOOST_AUTO_TEST_CASE(member_access_parser_ambiguity) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(using_for_library) @@ -2696,7 +2718,7 @@ BOOST_AUTO_TEST_CASE(using_for_library) using D for uint; } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(using_for_not_library) @@ -2707,7 +2729,7 @@ BOOST_AUTO_TEST_CASE(using_for_not_library) using D for uint; } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(using_for_function_exists) @@ -2721,7 +2743,7 @@ BOOST_AUTO_TEST_CASE(using_for_function_exists) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(using_for_function_on_int) @@ -2735,7 +2757,7 @@ BOOST_AUTO_TEST_CASE(using_for_function_on_int) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(using_for_function_on_struct) @@ -2750,7 +2772,7 @@ BOOST_AUTO_TEST_CASE(using_for_function_on_struct) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(using_for_overload) @@ -2769,7 +2791,7 @@ BOOST_AUTO_TEST_CASE(using_for_overload) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(using_for_by_name) @@ -2784,7 +2806,7 @@ BOOST_AUTO_TEST_CASE(using_for_by_name) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(using_for_mismatch) @@ -2798,7 +2820,7 @@ BOOST_AUTO_TEST_CASE(using_for_mismatch) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(using_for_not_used) @@ -2814,7 +2836,7 @@ BOOST_AUTO_TEST_CASE(using_for_not_used) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(library_memory_struct) @@ -2840,7 +2862,7 @@ BOOST_AUTO_TEST_CASE(using_for_arbitrary_mismatch) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(bound_function_in_var) @@ -2856,7 +2878,7 @@ BOOST_AUTO_TEST_CASE(bound_function_in_var) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(create_memory_arrays) @@ -2874,7 +2896,7 @@ BOOST_AUTO_TEST_CASE(create_memory_arrays) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(mapping_in_memory_array) @@ -2886,7 +2908,7 @@ BOOST_AUTO_TEST_CASE(mapping_in_memory_array) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(new_for_non_array) @@ -2898,7 +2920,7 @@ BOOST_AUTO_TEST_CASE(new_for_non_array) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(invalid_args_creating_memory_array) @@ -2910,7 +2932,7 @@ BOOST_AUTO_TEST_CASE(invalid_args_creating_memory_array) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(function_overload_array_type) @@ -2921,7 +2943,7 @@ BOOST_AUTO_TEST_CASE(function_overload_array_type) function f(int[] values); } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing_implicit_conversion) @@ -2937,7 +2959,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing_implicit_conversion) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing_implicit_conversion_strings) @@ -2952,7 +2974,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_and_passing_implicit_conversion_st } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inline_array_declaration_const_int_conversion) @@ -2965,7 +2987,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_const_int_conversion) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inline_array_declaration_const_string_conversion) @@ -2978,7 +3000,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_const_string_conversion) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inline_array_declaration_no_type) @@ -2990,7 +3012,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_no_type) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inline_array_declaration_no_type_strings) @@ -3002,7 +3024,7 @@ BOOST_AUTO_TEST_CASE(inline_array_declaration_no_type_strings) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inline_struct_declaration_arrays) @@ -3018,7 +3040,7 @@ BOOST_AUTO_TEST_CASE(inline_struct_declaration_arrays) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(invalid_types_in_inline_array) @@ -3030,7 +3052,7 @@ BOOST_AUTO_TEST_CASE(invalid_types_in_inline_array) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(dynamic_inline_array) @@ -3042,7 +3064,7 @@ BOOST_AUTO_TEST_CASE(dynamic_inline_array) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(lvalues_as_inline_array) @@ -3055,7 +3077,7 @@ BOOST_AUTO_TEST_CASE(lvalues_as_inline_array) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(break_not_in_loop) @@ -3068,7 +3090,7 @@ BOOST_AUTO_TEST_CASE(break_not_in_loop) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::SyntaxError); + CHECK_ERROR(text, SyntaxError, ""); } BOOST_AUTO_TEST_CASE(continue_not_in_loop) @@ -3081,7 +3103,7 @@ BOOST_AUTO_TEST_CASE(continue_not_in_loop) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::SyntaxError); + CHECK_ERROR(text, SyntaxError, ""); } BOOST_AUTO_TEST_CASE(continue_not_in_loop_2) @@ -3096,7 +3118,7 @@ BOOST_AUTO_TEST_CASE(continue_not_in_loop_2) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::SyntaxError); + CHECK_ERROR(text, SyntaxError, ""); } BOOST_AUTO_TEST_CASE(invalid_different_types_for_conditional_expression) @@ -3108,7 +3130,7 @@ BOOST_AUTO_TEST_CASE(invalid_different_types_for_conditional_expression) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(left_value_in_conditional_expression_not_supported_yet) @@ -3122,7 +3144,7 @@ BOOST_AUTO_TEST_CASE(left_value_in_conditional_expression_not_supported_yet) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(conditional_expression_with_different_struct) @@ -3142,7 +3164,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_struct) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(conditional_expression_with_different_function_type) @@ -3157,7 +3179,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_function_type) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(conditional_expression_with_different_enum) @@ -3175,7 +3197,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_enum) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(conditional_expression_with_different_mapping) @@ -3190,7 +3212,7 @@ BOOST_AUTO_TEST_CASE(conditional_expression_with_different_mapping) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(conditional_with_all_types) @@ -3272,7 +3294,7 @@ BOOST_AUTO_TEST_CASE(conditional_with_all_types) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(constructor_call_invalid_arg_count) @@ -3287,7 +3309,7 @@ BOOST_AUTO_TEST_CASE(constructor_call_invalid_arg_count) } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(index_access_for_bytes) @@ -3300,7 +3322,7 @@ BOOST_AUTO_TEST_CASE(index_access_for_bytes) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(uint7_and_uintM_as_identifier) @@ -3316,7 +3338,7 @@ BOOST_AUTO_TEST_CASE(uint7_and_uintM_as_identifier) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(varM_disqualified_as_keyword) @@ -3354,7 +3376,7 @@ BOOST_AUTO_TEST_CASE(bytes10abc_is_identifier) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(int10abc_is_identifier) @@ -3367,7 +3389,7 @@ BOOST_AUTO_TEST_CASE(int10abc_is_identifier) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(library_functions_do_not_have_value) @@ -3451,7 +3473,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_int_conversion) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(fixed_type_rational_int_conversion) @@ -3464,7 +3486,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_rational_int_conversion) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(fixed_type_rational_fraction_conversion) @@ -3477,7 +3499,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_rational_fraction_conversion) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(invalid_int_implicit_conversion_from_fixed) @@ -3503,7 +3525,7 @@ BOOST_AUTO_TEST_CASE(rational_unary_operation) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(leading_zero_rationals_convert) @@ -3518,7 +3540,7 @@ BOOST_AUTO_TEST_CASE(leading_zero_rationals_convert) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(size_capabilities_of_fixed_point_types) @@ -3535,7 +3557,7 @@ BOOST_AUTO_TEST_CASE(size_capabilities_of_fixed_point_types) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(fixed_type_invalid_implicit_conversion_size) @@ -3574,7 +3596,7 @@ BOOST_AUTO_TEST_CASE(fixed_type_valid_explicit_conversions) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(invalid_array_declaration_with_rational) @@ -3636,7 +3658,7 @@ BOOST_AUTO_TEST_CASE(mapping_with_fixed_literal) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(fixed_points_inside_structs) @@ -3650,7 +3672,7 @@ BOOST_AUTO_TEST_CASE(fixed_points_inside_structs) myStruct a = myStruct(3.125, 3); } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inline_array_fixed_types) @@ -3662,7 +3684,7 @@ BOOST_AUTO_TEST_CASE(inline_array_fixed_types) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inline_array_rationals) @@ -3674,7 +3696,7 @@ BOOST_AUTO_TEST_CASE(inline_array_rationals) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(rational_index_access) @@ -3705,7 +3727,7 @@ BOOST_AUTO_TEST_CASE(rational_to_fixed_literal_expression) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(rational_as_exponent_value) @@ -3749,7 +3771,7 @@ BOOST_AUTO_TEST_CASE(var_capable_of_holding_constant_rationals) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(var_and_rational_with_tuple) @@ -3761,7 +3783,7 @@ BOOST_AUTO_TEST_CASE(var_and_rational_with_tuple) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(var_handle_divided_integers) @@ -3773,7 +3795,7 @@ BOOST_AUTO_TEST_CASE(var_handle_divided_integers) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(rational_bitnot_unary_operation) @@ -3834,7 +3856,7 @@ BOOST_AUTO_TEST_CASE(zero_handling) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(missing_bool_conversion) @@ -3846,7 +3868,7 @@ BOOST_AUTO_TEST_CASE(missing_bool_conversion) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(integer_and_fixed_interaction) @@ -3858,7 +3880,7 @@ BOOST_AUTO_TEST_CASE(integer_and_fixed_interaction) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(signed_rational_modulus) @@ -3872,7 +3894,7 @@ BOOST_AUTO_TEST_CASE(signed_rational_modulus) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(one_divided_by_three_integer_conversion) @@ -3897,7 +3919,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(unused_return_value_send) @@ -3909,7 +3931,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_send) } } )"; - BOOST_CHECK(expectError(text, true).regex_search("Return value of low-level calls not used")); + CHECK_WARNING(text, "Return value of low-level calls not used"); } BOOST_AUTO_TEST_CASE(unused_return_value_call) @@ -3921,7 +3943,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_call) } } )"; - BOOST_CHECK(expectError(text, true).regex_search("Return value of low-level calls not used")); + CHECK_WARNING(text, "Return value of low-level calls not used"); } BOOST_AUTO_TEST_CASE(unused_return_value_call_value) @@ -3933,7 +3955,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_call_value) } } )"; - BOOST_CHECK(expectError(text, true).regex_search("Return value of low-level calls not used")); + CHECK_WARNING(text, "Return value of low-level calls not used"); } BOOST_AUTO_TEST_CASE(unused_return_value_callcode) @@ -3945,7 +3967,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_callcode) } } )"; - BOOST_CHECK(expectError(text, true).regex_search("Return value of low-level calls not used")); + CHECK_WARNING(text, "Return value of low-level calls not used"); } BOOST_AUTO_TEST_CASE(unused_return_value_delegatecall) @@ -3957,7 +3979,7 @@ BOOST_AUTO_TEST_CASE(unused_return_value_delegatecall) } } )"; - BOOST_CHECK(expectError(text, true).regex_search("Return value of low-level calls not used")); + CHECK_WARNING(text, "Return value of low-level calls not used"); } BOOST_AUTO_TEST_CASE(modifier_without_underscore) @@ -3967,7 +3989,7 @@ BOOST_AUTO_TEST_CASE(modifier_without_underscore) modifier m() {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::SyntaxError); + CHECK_ERROR(text, SyntaxError, ""); } BOOST_AUTO_TEST_CASE(payable_in_library) @@ -3977,7 +3999,7 @@ BOOST_AUTO_TEST_CASE(payable_in_library) function f() payable {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(payable_external) @@ -3987,7 +4009,7 @@ BOOST_AUTO_TEST_CASE(payable_external) function f() payable external {} } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(payable_internal) @@ -3997,7 +4019,7 @@ BOOST_AUTO_TEST_CASE(payable_internal) function f() payable internal {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(payable_private) @@ -4007,7 +4029,7 @@ BOOST_AUTO_TEST_CASE(payable_private) function f() payable private {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(illegal_override_payable) @@ -4016,7 +4038,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_payable) contract B { function f() payable {} } contract C is B { function f() {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable) @@ -4025,7 +4047,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable) contract B { function f() {} } contract C is B { function f() payable {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(payable_constant_conflict) @@ -4033,7 +4055,7 @@ BOOST_AUTO_TEST_CASE(payable_constant_conflict) char const* text = R"( contract C { function f() payable constant {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(calling_payable) @@ -4046,7 +4068,7 @@ BOOST_AUTO_TEST_CASE(calling_payable) function g() { r.pay.value(10)(); } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(calling_nonpayable) @@ -4057,7 +4079,7 @@ BOOST_AUTO_TEST_CASE(calling_nonpayable) function f() { (new receiver()).nopay.value(10)(); } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(non_payable_constructor) @@ -4073,7 +4095,7 @@ BOOST_AUTO_TEST_CASE(non_payable_constructor) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma) @@ -4152,7 +4174,7 @@ BOOST_AUTO_TEST_CASE(function_type) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(function_type_parameter) @@ -4164,7 +4186,7 @@ BOOST_AUTO_TEST_CASE(function_type_parameter) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(function_type_returned) @@ -4176,7 +4198,7 @@ BOOST_AUTO_TEST_CASE(function_type_returned) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(private_function_type) @@ -4188,7 +4210,7 @@ BOOST_AUTO_TEST_CASE(private_function_type) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(public_function_type) @@ -4200,7 +4222,7 @@ BOOST_AUTO_TEST_CASE(public_function_type) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(payable_internal_function_type) @@ -4210,7 +4232,7 @@ BOOST_AUTO_TEST_CASE(payable_internal_function_type) function (uint) internal payable returns (uint) x; } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(call_value_on_non_payable_function_type) @@ -4223,7 +4245,7 @@ BOOST_AUTO_TEST_CASE(call_value_on_non_payable_function_type) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(external_function_type_returning_internal) @@ -4233,7 +4255,7 @@ BOOST_AUTO_TEST_CASE(external_function_type_returning_internal) function() external returns (function () internal) x; } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(external_function_type_taking_internal) @@ -4243,7 +4265,7 @@ BOOST_AUTO_TEST_CASE(external_function_type_taking_internal) function(function () internal) external x; } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(call_value_on_payable_function_type) @@ -4256,7 +4278,7 @@ BOOST_AUTO_TEST_CASE(call_value_on_payable_function_type) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter) @@ -4269,7 +4291,7 @@ BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(internal_function_returned_from_public_function) @@ -4281,7 +4303,7 @@ BOOST_AUTO_TEST_CASE(internal_function_returned_from_public_function) } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter_in_library_internal) @@ -4292,7 +4314,7 @@ BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter_in_library_internal } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter_in_library_external) @@ -4303,7 +4325,7 @@ BOOST_AUTO_TEST_CASE(internal_function_as_external_parameter_in_library_external } } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(function_type_arrays) @@ -4320,7 +4342,7 @@ BOOST_AUTO_TEST_CASE(function_type_arrays) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(delete_function_type) @@ -4341,7 +4363,7 @@ BOOST_AUTO_TEST_CASE(delete_function_type) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(delete_function_type_invalid) @@ -4431,7 +4453,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_positive_stack) } } )"; - BOOST_CHECK(expectError(text, true).regex_search("Inline assembly block is not balanced")); + CHECK_WARNING(text, "Inline assembly block is not balanced"); } BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_negative_stack) @@ -4445,7 +4467,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_negative_stack) } } )"; - BOOST_CHECK(expectError(text, true).regex_search("Inline assembly block is not balanced")); + CHECK_WARNING(text, "Inline assembly block is not balanced"); } BOOST_AUTO_TEST_CASE(inline_assembly_in_modifier) @@ -4463,7 +4485,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_in_modifier) } } )"; - BOOST_CHECK(success(text)); + CHECK_SUCCESS(text); } BOOST_AUTO_TEST_CASE(inline_assembly_storage) @@ -4478,7 +4500,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage) } } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::DeclarationError); + CHECK_ERROR(text, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(inline_assembly_storage_in_modifiers) @@ -4496,7 +4518,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_in_modifiers) } } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::DeclarationError); + CHECK_ERROR(text, DeclarationError, ""); } BOOST_AUTO_TEST_CASE(invalid_mobile_type) @@ -4509,7 +4531,7 @@ BOOST_AUTO_TEST_CASE(invalid_mobile_type) } } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_SUITE_END() -- cgit From 2faaddca05549ecf3e716ec83faeffde6e8d4c2f Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Tue, 22 Nov 2016 11:07:23 +0100 Subject: interface: fix the substring search --- test/libsolidity/SolidityNameAndTypeResolution.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/libsolidity') diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 57ee86d6..0022dfb2 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -165,7 +165,7 @@ do \ { \ Error err = expectError((text), (warning)); \ BOOST_CHECK(err.type() == (Error::Type::typ)); \ - BOOST_CHECK(err.regex_search({substring})); \ + BOOST_CHECK(err.searchForSubstring(substring)); \ } while(0) // [checkError(text, type, substring)] asserts that the compilation down to typechecking @@ -4104,7 +4104,7 @@ BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma) auto sourceAndError = parseAnalyseAndReturnError(text, true, false); BOOST_REQUIRE(!!sourceAndError.second); BOOST_REQUIRE(!!sourceAndError.first); - BOOST_CHECK(sourceAndError.second->regex_search("Source file does not specify required compiler version!")); + BOOST_CHECK(sourceAndError.second->searchForSubstring("Source file does not specify required compiler version!")); } BOOST_AUTO_TEST_CASE(unsatisfied_version) -- cgit From 384c4546f172f8a0615036be9555774de6592fbc Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Thu, 24 Nov 2016 16:45:17 +0100 Subject: interface: move searchForSubstring out of Error class into a separate file --- test/libsolidity/ErrorCheck.cpp | 32 ++++++++++++++++++++++ test/libsolidity/ErrorCheck.h | 32 ++++++++++++++++++++++ test/libsolidity/SolidityNameAndTypeResolution.cpp | 5 ++-- 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 test/libsolidity/ErrorCheck.cpp create mode 100644 test/libsolidity/ErrorCheck.h (limited to 'test/libsolidity') diff --git a/test/libsolidity/ErrorCheck.cpp b/test/libsolidity/ErrorCheck.cpp new file mode 100644 index 00000000..6dddda70 --- /dev/null +++ b/test/libsolidity/ErrorCheck.cpp @@ -0,0 +1,32 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +/** @file ErrorCheck.cpp + * @author Yoichi Hirai + * @date 2016 + */ + +#include +#include + +#include + +bool dev::solidity::searchErrorMessage(Error const& _err, std::string const& _substr) +{ + if (const std::string* errorMessage = boost::get_error_info(_err)) + return errorMessage->find(_substr) != std::string::npos; + return _substr.empty(); +} diff --git a/test/libsolidity/ErrorCheck.h b/test/libsolidity/ErrorCheck.h new file mode 100644 index 00000000..a309a9d3 --- /dev/null +++ b/test/libsolidity/ErrorCheck.h @@ -0,0 +1,32 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +/** @file ErrorCheck.h + * @author Yoichi Hirai + * @date 2016 + */ + +#pragma once + +#include + +namespace dev +{ +namespace solidity +{ +bool searchErrorMessage(Error const& _err, std::string const& _substr); +} +} diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 0022dfb2..5671b00b 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -31,6 +31,7 @@ #include #include #include "../TestHelper.h" +#include "ErrorCheck.h" using namespace std; @@ -165,7 +166,7 @@ do \ { \ Error err = expectError((text), (warning)); \ BOOST_CHECK(err.type() == (Error::Type::typ)); \ - BOOST_CHECK(err.searchForSubstring(substring)); \ + BOOST_CHECK(searchErrorMessage(err, substring)); \ } while(0) // [checkError(text, type, substring)] asserts that the compilation down to typechecking @@ -4104,7 +4105,7 @@ BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma) auto sourceAndError = parseAnalyseAndReturnError(text, true, false); BOOST_REQUIRE(!!sourceAndError.second); BOOST_REQUIRE(!!sourceAndError.first); - BOOST_CHECK(sourceAndError.second->searchForSubstring("Source file does not specify required compiler version!")); + BOOST_CHECK(searchErrorMessage(*sourceAndError.second, "Source file does not specify required compiler version!")); } BOOST_AUTO_TEST_CASE(unsatisfied_version) -- cgit From a81f5563022e409d3e54e70177f2073c698c2238 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Thu, 24 Nov 2016 19:22:26 +0100 Subject: test: various fixes --- test/libsolidity/ErrorCheck.cpp | 4 +- test/libsolidity/SolidityNameAndTypeResolution.cpp | 44 +++++++++++----------- 2 files changed, 25 insertions(+), 23 deletions(-) (limited to 'test/libsolidity') diff --git a/test/libsolidity/ErrorCheck.cpp b/test/libsolidity/ErrorCheck.cpp index 6dddda70..75555c9b 100644 --- a/test/libsolidity/ErrorCheck.cpp +++ b/test/libsolidity/ErrorCheck.cpp @@ -24,9 +24,11 @@ #include +using namespace std; + bool dev::solidity::searchErrorMessage(Error const& _err, std::string const& _substr) { - if (const std::string* errorMessage = boost::get_error_info(_err)) + if (string const* errorMessage = boost::get_error_info(_err)) return errorMessage->find(_substr) != std::string::npos; return _substr.empty(); } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 5671b00b..6dc7ac8c 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -62,7 +62,7 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false, SyntaxChecker syntaxChecker(errors); if (!syntaxChecker.checkSyntax(*sourceUnit)) - return make_pair(sourceUnit, errors[0]); + return make_pair(sourceUnit, errors.at(0)); std::shared_ptr globalContext = make_shared(); NameAndTypeResolver resolver(globalContext->declarations(), errors); @@ -1092,7 +1092,7 @@ BOOST_AUTO_TEST_CASE(struct_accessor_one_array_only) Data public data; } )"; - BOOST_CHECK(expectError(sourceCode).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode, TypeError, ""); } BOOST_AUTO_TEST_CASE(base_class_state_variable_internal_member) @@ -2125,15 +2125,15 @@ BOOST_AUTO_TEST_CASE(integer_boolean_operators) char const* sourceCode1 = R"( contract test { function() { uint x = 1; uint y = 2; x || y; } } )"; - BOOST_CHECK(expectError(sourceCode1).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode1, TypeError, ""); char const* sourceCode2 = R"( contract test { function() { uint x = 1; uint y = 2; x && y; } } )"; - BOOST_CHECK(expectError(sourceCode2).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode2, TypeError, ""); char const* sourceCode3 = R"( contract test { function() { uint x = 1; !x; } } )"; - BOOST_CHECK(expectError(sourceCode3).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode3, TypeError, ""); } BOOST_AUTO_TEST_CASE(exp_signed_variable) @@ -2141,15 +2141,15 @@ BOOST_AUTO_TEST_CASE(exp_signed_variable) char const* sourceCode1 = R"( contract test { function() { uint x = 3; int y = -4; x ** y; } } )"; - BOOST_CHECK(expectError(sourceCode1).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode1, TypeError, ""); char const* sourceCode2 = R"( contract test { function() { uint x = 3; int y = -4; y ** x; } } )"; - BOOST_CHECK(expectError(sourceCode2).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode2, TypeError, ""); char const* sourceCode3 = R"( contract test { function() { int x = -3; int y = -4; x ** y; } } )"; - BOOST_CHECK(expectError(sourceCode3).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode3, TypeError, ""); } BOOST_AUTO_TEST_CASE(reference_compare_operators) @@ -2157,11 +2157,11 @@ BOOST_AUTO_TEST_CASE(reference_compare_operators) char const* sourceCode1 = R"( contract test { bytes a; bytes b; function() { a == b; } } )"; - BOOST_CHECK(expectError(sourceCode1).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode1, TypeError, ""); char const* sourceCode2 = R"( contract test { struct s {uint a;} s x; s y; function() { x == y; } } )"; - BOOST_CHECK(expectError(sourceCode2).type() == Error::Type::TypeError); + CHECK_ERROR(sourceCode2, TypeError, ""); } BOOST_AUTO_TEST_CASE(overwrite_memory_location_external) @@ -2848,7 +2848,7 @@ BOOST_AUTO_TEST_CASE(library_memory_struct) function f() returns (S ) {} } )"; - BOOST_CHECK(expectError(text).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(using_for_arbitrary_mismatch) @@ -4123,7 +4123,7 @@ BOOST_AUTO_TEST_CASE(constant_constructor) function test() constant {} } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(external_constructor) @@ -4133,7 +4133,7 @@ BOOST_AUTO_TEST_CASE(external_constructor) function test() external {} } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(invalid_array_as_statement) @@ -4144,7 +4144,7 @@ BOOST_AUTO_TEST_CASE(invalid_array_as_statement) function test(uint k) { S[k]; } } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(using_directive_for_missing_selftype) @@ -4163,7 +4163,7 @@ BOOST_AUTO_TEST_CASE(using_directive_for_missing_selftype) } } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(function_type) @@ -4376,7 +4376,7 @@ BOOST_AUTO_TEST_CASE(delete_function_type_invalid) } } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(delete_external_function_type_invalid) @@ -4388,7 +4388,7 @@ BOOST_AUTO_TEST_CASE(delete_external_function_type_invalid) } } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(invalid_fixed_point_literal) @@ -4400,7 +4400,7 @@ BOOST_AUTO_TEST_CASE(invalid_fixed_point_literal) } } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(shift_constant_left_negative_rvalue) @@ -4410,7 +4410,7 @@ BOOST_AUTO_TEST_CASE(shift_constant_left_negative_rvalue) uint public a = 0x42 << -8; } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(shift_constant_right_negative_rvalue) @@ -4420,7 +4420,7 @@ BOOST_AUTO_TEST_CASE(shift_constant_right_negative_rvalue) uint public a = 0x42 >> -8; } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(shift_constant_left_excessive_rvalue) @@ -4430,7 +4430,7 @@ BOOST_AUTO_TEST_CASE(shift_constant_left_excessive_rvalue) uint public a = 0x42 << 0x100000000; } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(shift_constant_right_excessive_rvalue) @@ -4440,7 +4440,7 @@ BOOST_AUTO_TEST_CASE(shift_constant_right_excessive_rvalue) uint public a = 0x42 >> 0x100000000; } )"; - BOOST_CHECK(expectError(text, false).type() == Error::Type::TypeError); + CHECK_ERROR(text, TypeError, ""); } BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_positive_stack) -- cgit