Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test builtins & add simple smoke test. #11304

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/libsolidity/SemanticTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ SemanticTest::SemanticTest(
m_enforceGasCost(_enforceGasCost),
m_enforceGasCostMinValue(_enforceGasCostMinValue)
{
initializeBuiltins();

string choice = m_reader.stringSetting("compileViaYul", "default");
if (choice == "also")
{
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/libsolidity/SemanticTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class SemanticTest: public SolidityExecutionFramework, public EVMVersionRestrict
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;
Expand Down
7 changes: 7 additions & 0 deletions test/libsolidity/semanticTests/builtins/smoke_test.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
contract SmokeTest {
}
// ====
// compileViaYul: also
// ----
// constructor()
// smokeTest -> 0x1234
2 changes: 2 additions & 0 deletions test/libsolidity/util/TestFileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down