mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3502 from aarlt/minor_fix_no_input_sources_specified
Minor improvement: Check sources
This commit is contained in:
commit
839acafb95
@ -6,7 +6,7 @@ Features:
|
|||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
* Standard JSON: catch errors properly when invalid "sources" are passed
|
||||||
|
|
||||||
### 0.4.20 (2018-02-14)
|
### 0.4.20 (2018-02-14)
|
||||||
|
|
||||||
|
@ -236,7 +236,11 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input)
|
|||||||
return formatFatalError("JSONError", "Only \"Solidity\" is supported as a language.");
|
return formatFatalError("JSONError", "Only \"Solidity\" is supported as a language.");
|
||||||
|
|
||||||
Json::Value const& sources = _input["sources"];
|
Json::Value const& sources = _input["sources"];
|
||||||
if (!sources)
|
|
||||||
|
if (!sources.isObject() && !sources.isNull())
|
||||||
|
return formatFatalError("JSONError", "\"sources\" is not a JSON object.");
|
||||||
|
|
||||||
|
if (sources.empty())
|
||||||
return formatFatalError("JSONError", "No input sources specified.");
|
return formatFatalError("JSONError", "No input sources specified.");
|
||||||
|
|
||||||
Json::Value errors = Json::arrayValue;
|
Json::Value errors = Json::arrayValue;
|
||||||
|
@ -154,6 +154,42 @@ BOOST_AUTO_TEST_CASE(no_sources)
|
|||||||
BOOST_CHECK(containsError(result, "JSONError", "No input sources specified."));
|
BOOST_CHECK(containsError(result, "JSONError", "No input sources specified."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(no_sources_empty_object)
|
||||||
|
{
|
||||||
|
char const* input = R"(
|
||||||
|
{
|
||||||
|
"language": "Solidity",
|
||||||
|
"sources": {}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
Json::Value result = compile(input);
|
||||||
|
BOOST_CHECK(containsError(result, "JSONError", "No input sources specified."));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(no_sources_empty_array)
|
||||||
|
{
|
||||||
|
char const* input = R"(
|
||||||
|
{
|
||||||
|
"language": "Solidity",
|
||||||
|
"sources": []
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
Json::Value result = compile(input);
|
||||||
|
BOOST_CHECK(containsError(result, "JSONError", "\"sources\" is not a JSON object."));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(sources_is_array)
|
||||||
|
{
|
||||||
|
char const* input = R"(
|
||||||
|
{
|
||||||
|
"language": "Solidity",
|
||||||
|
"sources": ["aa", "bb"]
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
Json::Value result = compile(input);
|
||||||
|
BOOST_CHECK(containsError(result, "JSONError", "\"sources\" is not a JSON object."));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(smoke_test)
|
BOOST_AUTO_TEST_CASE(smoke_test)
|
||||||
{
|
{
|
||||||
char const* input = R"(
|
char const* input = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user