aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-12-18 19:40:06 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-12-18 20:17:51 +0800
commitadd4cde68cd9b5c52db8a312a34591a8bb61d8fa (patch)
tree1d30d74edca347bdaf1e428f1b1fa0efb16faf7a /test
parent3d1830f3f27f4b915b27472dcfb326223ef77e50 (diff)
downloaddexon-solidity-add4cde68cd9b5c52db8a312a34591a8bb61d8fa.tar.gz
dexon-solidity-add4cde68cd9b5c52db8a312a34591a8bb61d8fa.tar.zst
dexon-solidity-add4cde68cd9b5c52db8a312a34591a8bb61d8fa.zip
Populate the sourceLocation field properly in standard JSON on errors
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/StandardCompiler.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index 091207e8..dd0478c5 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -234,6 +234,46 @@ BOOST_AUTO_TEST_CASE(basic_compilation)
);
}
+BOOST_AUTO_TEST_CASE(compilation_error)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "outputSelection": {
+ "fileA": {
+ "A": [
+ "abi"
+ ]
+ }
+ }
+ },
+ "sources": {
+ "fileA": {
+ "content": "contract A { function }"
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(result.isMember("errors"));
+ BOOST_CHECK(result["errors"].size() >= 1);
+ for (auto const& error: result["errors"])
+ {
+ BOOST_REQUIRE(error.isObject());
+ BOOST_REQUIRE(error["message"].isString());
+ if (error["message"].asString().find("pre-release compiler") == string::npos)
+ {
+ BOOST_CHECK_EQUAL(
+ dev::jsonCompactPrint(error),
+ "{\"component\":\"general\",\"formattedMessage\":\"fileA:1:23: ParserError: Expected identifier, got 'RBrace'\\n"
+ "contract A { function }\\n ^\\n\",\"message\":\"Expected identifier, got 'RBrace'\","
+ "\"severity\":\"error\",\"sourceLocation\":{\"end\":22,\"file\":\"fileA\",\"start\":22},\"type\":\"ParserError\"}"
+ );
+ }
+ }
+}
+
BOOST_AUTO_TEST_CASE(output_selection_explicit)
{
char const* input = R"(