Fix test builtins & add simple smoke test.

This commit is contained in:
Alexander Arlt 2021-04-23 09:56:19 -05:00
parent dce3006723
commit 8239eaa1b8
4 changed files with 21 additions and 0 deletions

View File

@ -61,6 +61,8 @@ SemanticTest::SemanticTest(
m_enforceGasCost(_enforceGasCost),
m_enforceGasCostMinValue(_enforceGasCostMinValue)
{
initializeBuiltins();
string choice = m_reader.stringSetting("compileViaYul", "default");
if (choice == "also")
{
@ -122,6 +124,15 @@ SemanticTest::SemanticTest(
}
}
void SemanticTest::initializeBuiltins()
{
solAssert(m_builtins.count("smokeTest") == 0, "");
m_builtins["smokeTest"] = [](FunctionCall const&) -> std::optional<bytes>
{
return util::toBigEndian(u256(0x1234));
};
}
TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
{
TestResult result = TestResult::Success;

View File

@ -78,6 +78,7 @@ public:
private:
TestResult runTest(std::ostream& _stream, std::string const& _linePrefix, bool _formatted, bool _compileViaYul, bool _compileToEwasm);
bool checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const;
void initializeBuiltins();
SourceMap m_sources;
std::size_t m_lineOffset;
std::vector<TestFunctionCall> m_tests;

View File

@ -0,0 +1,7 @@
contract SmokeTest {
}
// ====
// compileViaYul: also
// ----
// constructor()
// smokeTest -> 0x1234

View File

@ -127,6 +127,8 @@ vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCall
tie(call.signature, lowLevelCall) = parseFunctionSignature();
if (lowLevelCall)
call.kind = FunctionCall::Kind::LowLevel;
else if (isBuiltinFunction(call.signature))
call.kind = FunctionCall::Kind::Builtin;
if (accept(Token::Comma, true))
call.value = parseFunctionCallValue();