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.cpp113
1 files changed, 113 insertions, 0 deletions
diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp
index 4504946b..e48624e5 100644
--- a/test/libsolidity/StandardCompiler.cpp
+++ b/test/libsolidity/StandardCompiler.cpp
@@ -179,6 +179,14 @@ BOOST_AUTO_TEST_CASE(basic_compilation)
"fileA": {
"content": "contract A { }"
}
+ },
+ "settings": {
+ "outputSelection": {
+ "fileA": {
+ "A": [ "abi", "devdoc", "userdoc", "evm.bytecode", "evm.assembly", "evm.gasEstimates", "metadata" ],
+ "": [ "legacyAST" ]
+ }
+ }
}
}
)";
@@ -226,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"(
@@ -403,6 +451,71 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract_with_import)
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[{\"constant\":false,\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]");
}
+BOOST_AUTO_TEST_CASE(filename_with_colon)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "outputSelection": {
+ "http://github.com/ethereum/solidity/std/StandardToken.sol": {
+ "A": [
+ "abi"
+ ]
+ }
+ }
+ },
+ "sources": {
+ "http://github.com/ethereum/solidity/std/StandardToken.sol": {
+ "content": "contract A { }"
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsAtMostWarnings(result));
+ Json::Value contract = getContractResult(result, "http://github.com/ethereum/solidity/std/StandardToken.sol", "A");
+ BOOST_CHECK(contract.isObject());
+ BOOST_CHECK(contract["abi"].isArray());
+ BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]");
+}
+
+BOOST_AUTO_TEST_CASE(library_filename_with_colon)
+{
+ char const* input = R"(
+ {
+ "language": "Solidity",
+ "settings": {
+ "outputSelection": {
+ "fileA": {
+ "A": [
+ "evm.bytecode"
+ ]
+ }
+ }
+ },
+ "sources": {
+ "fileA": {
+ "content": "import \"git:library.sol\"; contract A { function f() returns (uint) { return L.g(); } }"
+ },
+ "git:library.sol": {
+ "content": "library L { function g() returns (uint) { return 1; } }"
+ }
+ }
+ }
+ )";
+ Json::Value result = compile(input);
+ BOOST_CHECK(containsAtMostWarnings(result));
+ Json::Value contract = getContractResult(result, "fileA", "A");
+ BOOST_CHECK(contract.isObject());
+ BOOST_CHECK(contract["evm"]["bytecode"].isObject());
+ BOOST_CHECK(contract["evm"]["bytecode"]["linkReferences"].isObject());
+ BOOST_CHECK(contract["evm"]["bytecode"]["linkReferences"]["git:library.sol"].isObject());
+ BOOST_CHECK(contract["evm"]["bytecode"]["linkReferences"]["git:library.sol"]["L"].isArray());
+ BOOST_CHECK(contract["evm"]["bytecode"]["linkReferences"]["git:library.sol"]["L"][0].isObject());
+}
+
+
BOOST_AUTO_TEST_SUITE_END()
}