Skip to content

Commit

Permalink
Correctly handle unexpected exceptions during tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed May 10, 2016
1 parent a6fc3c8 commit af354d7
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions test/libsolidity/SolidityNameAndTypeResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,20 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false)
return make_pair(sourceUnit, std::make_shared<Error::Type const>(currentError->type()));
}
}
catch (InternalCompilerError const& _e)
{
string message("Internal compiler error");
if (string const* description = boost::get_error_info<errinfo_comment>(_e))
message += ": " + *description;
BOOST_FAIL(message);
}
catch (Error const& _e)
{
return make_pair(sourceUnit, std::make_shared<Error::Type const>(_e.type()));
}
catch (Exception const& /*_exception*/)
catch (...)
{
return make_pair(sourceUnit, nullptr);
BOOST_FAIL("Unexpected exception.");
}
return make_pair(sourceUnit, nullptr);
}
Expand Down Expand Up @@ -3516,6 +3523,19 @@ BOOST_AUTO_TEST_CASE(inline_array_rationals)
BOOST_CHECK(success(text));
}

BOOST_AUTO_TEST_CASE(rational_index_access)
{
char const* text = R"(
contract test {
function f() {
uint[] memory a;
a[.5];
}
}
)";
BOOST_CHECK(!success(text));
}

BOOST_AUTO_TEST_CASE(rational_to_fixed_literal_expression)
{
char const* text = R"(
Expand Down Expand Up @@ -3578,6 +3598,18 @@ BOOST_AUTO_TEST_CASE(var_capable_of_holding_constant_rationals)
BOOST_CHECK(success(text));
}

BOOST_AUTO_TEST_CASE(var_and_rational_with_tuple)
{
char const* text = R"(
contract test {
function f() {
var (a, b) = (.5, 1/3);
}
}
)";
BOOST_CHECK(success(text));
}

BOOST_AUTO_TEST_CASE(var_handle_divided_integers)
{
char const* text = R"(
Expand Down

0 comments on commit af354d7

Please sign in to comment.