mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6534 from ethereum/reuseLiteralContent-6472
Re-produce the original 'useLiteralContent' setting
This commit is contained in:
commit
922ab0d72d
@ -11,6 +11,7 @@ Language Features:
|
||||
|
||||
Compiler Features:
|
||||
* ABI Decoder: Raise a runtime error on dirty inputs when using the experimental decoder.
|
||||
* Standartd JSON Interface: Metadata settings now re-produce the original 'useLiteralContent' setting from the compilation input.
|
||||
* SMTChecker: Support arithmetic compound assignment operators.
|
||||
* SMTChecker: Support unary increment and decrement for array and mapping access.
|
||||
* SMTChecker: Show unsupported warning for inline assembly blocks.
|
||||
|
@ -92,7 +92,9 @@ explanatory purposes.
|
||||
// Required for Solidity: Addresses for libraries used
|
||||
libraries: {
|
||||
"MyLib": "0x123123..."
|
||||
}
|
||||
},
|
||||
// Reflects the setting used in the input json, defaults to false
|
||||
"useLiteralContent": false
|
||||
},
|
||||
// Required: Generated information about the contract.
|
||||
output:
|
||||
|
@ -1067,6 +1067,7 @@ string CompilerStack::createMetadata(Contract const& _contract) const
|
||||
meta["settings"]["optimizer"]["details"] = std::move(details);
|
||||
}
|
||||
|
||||
meta["settings"]["useLiteralContent"] = m_metadataLiteralSources;
|
||||
meta["settings"]["evmVersion"] = m_evmVersion.name();
|
||||
meta["settings"]["compilationTarget"][_contract.contract->sourceUnitName()] =
|
||||
_contract.contract->annotation().canonicalName;
|
||||
|
@ -177,6 +177,37 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
|
||||
BOOST_CHECK(metadata["sources"].isMember("C"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(metadata_useLiteralContent)
|
||||
{
|
||||
// Check that the metadata contains "useLiteralContent"
|
||||
char const* sourceCode = R"(
|
||||
pragma solidity >=0.0;
|
||||
contract test {
|
||||
}
|
||||
)";
|
||||
|
||||
auto check = [](char const* _src, bool _check)
|
||||
{
|
||||
CompilerStack compilerStack;
|
||||
compilerStack.setSources({{"", std::string(_src)}});
|
||||
compilerStack.setEVMVersion(dev::test::Options::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
|
||||
compilerStack.useMetadataLiteralSources(_check);
|
||||
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
|
||||
string metadata_str = compilerStack.metadata("test");
|
||||
Json::Value metadata;
|
||||
jsonParse(metadata_str, metadata);
|
||||
BOOST_CHECK(metadata.isMember("settings"));
|
||||
BOOST_CHECK(metadata["settings"].isMember("useLiteralContent"));
|
||||
BOOST_CHECK(_check == metadata["settings"]["useLiteralContent"].asBool());
|
||||
BOOST_CHECK(dev::test::isValidMetadata(metadata_str));
|
||||
|
||||
};
|
||||
|
||||
check(sourceCode, true);
|
||||
check(sourceCode, false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user