aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/StandardCompiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/StandardCompiler.cpp')
-rw-r--r--test/libsolidity/StandardCompiler.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index 8da536d8..404f709d 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -89,7 +89,7 @@ Json::Value compile(string const& _input)
StandardCompiler compiler;
string output = compiler.compile(_input);
Json::Value ret;
- BOOST_REQUIRE(Json::Reader().parse(output, ret, false));
+ BOOST_REQUIRE(jsonParseStrict(output, ret));
return ret;
}
@@ -110,11 +110,11 @@ BOOST_AUTO_TEST_CASE(assume_object_input)
/// Use the string interface of StandardCompiler to trigger these
result = compile("");
- BOOST_CHECK(containsError(result, "JSONError", "* Line 1, Column 1\n Syntax error: value, object or array expected.\n"));
+ BOOST_CHECK(containsError(result, "JSONError", "* Line 1, Column 1\n Syntax error: value, object or array expected.\n* Line 1, Column 1\n A valid JSON document must be either an array or an object value.\n"));
result = compile("invalid");
- BOOST_CHECK(containsError(result, "JSONError", "* Line 1, Column 1\n Syntax error: value, object or array expected.\n"));
+ BOOST_CHECK(containsError(result, "JSONError", "* Line 1, Column 1\n Syntax error: value, object or array expected.\n* Line 1, Column 2\n Extra non-whitespace after JSON value.\n"));
result = compile("\"invalid\"");
- BOOST_CHECK(containsError(result, "JSONError", "Input is not a JSON object."));
+ BOOST_CHECK(containsError(result, "JSONError", "* Line 1, Column 1\n A valid JSON document must be either an array or an object value.\n"));
BOOST_CHECK(!containsError(result, "JSONError", "* Line 1, Column 1\n Syntax error: value, object or array expected.\n"));
result = compile("{}");
BOOST_CHECK(!containsError(result, "JSONError", "* Line 1, Column 1\n Syntax error: value, object or array expected.\n"));
@@ -190,6 +190,25 @@ BOOST_AUTO_TEST_CASE(sources_is_array)
BOOST_CHECK(containsError(result, "JSONError", "\"sources\" is not a JSON object."));
}
+BOOST_AUTO_TEST_CASE(unexpected_trailing_test)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "sources": {
+ "A": {
+ "content": "contract A { function f() {} }"
+ }
+ }
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsError(result, "JSONError", "* Line 10, Column 2\n Extra non-whitespace after JSON value.\n"));
+}
+
+
BOOST_AUTO_TEST_CASE(smoke_test)
{
char const* input = R"(