aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/StandardCompiler.cpp
diff options
context:
space:
mode:
authorAlexander Arlt <alexander.arlt@arlt-labs.com>2018-02-07 09:05:20 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-02-21 04:58:26 +0800
commit0f29ac4e563f60be781b31ed9ef2693e1a19dcc8 (patch)
tree888d535ad5698b41f6979622040c3dcce3d300ca /test/libsolidity/StandardCompiler.cpp
parentdcc4083b231e3574a64b5b2a329a7401677610da (diff)
downloaddexon-solidity-0f29ac4e563f60be781b31ed9ef2693e1a19dcc8.tar.gz
dexon-solidity-0f29ac4e563f60be781b31ed9ef2693e1a19dcc8.tar.zst
dexon-solidity-0f29ac4e563f60be781b31ed9ef2693e1a19dcc8.zip
Add new JSON API for better abstraction and for supporting strict JSON parsing
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"(