Skip to content

Commit 8239eaa

Browse files
committed
Fix test builtins & add simple smoke test.
1 parent dce3006 commit 8239eaa

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

test/libsolidity/SemanticTest.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ SemanticTest::SemanticTest(
6161
m_enforceGasCost(_enforceGasCost),
6262
m_enforceGasCostMinValue(_enforceGasCostMinValue)
6363
{
64+
initializeBuiltins();
65+
6466
string choice = m_reader.stringSetting("compileViaYul", "default");
6567
if (choice == "also")
6668
{
@@ -122,6 +124,15 @@ SemanticTest::SemanticTest(
122124
}
123125
}
124126

127+
void SemanticTest::initializeBuiltins()
128+
{
129+
solAssert(m_builtins.count("smokeTest") == 0, "");
130+
m_builtins["smokeTest"] = [](FunctionCall const&) -> std::optional<bytes>
131+
{
132+
return util::toBigEndian(u256(0x1234));
133+
};
134+
}
135+
125136
TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
126137
{
127138
TestResult result = TestResult::Success;

test/libsolidity/SemanticTest.h

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class SemanticTest: public SolidityExecutionFramework, public EVMVersionRestrict
7878
private:
7979
TestResult runTest(std::ostream& _stream, std::string const& _linePrefix, bool _formatted, bool _compileViaYul, bool _compileToEwasm);
8080
bool checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const;
81+
void initializeBuiltins();
8182
SourceMap m_sources;
8283
std::size_t m_lineOffset;
8384
std::vector<TestFunctionCall> m_tests;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
contract SmokeTest {
2+
}
3+
// ====
4+
// compileViaYul: also
5+
// ----
6+
// constructor()
7+
// smokeTest -> 0x1234

test/libsolidity/util/TestFileParser.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCall
127127
tie(call.signature, lowLevelCall) = parseFunctionSignature();
128128
if (lowLevelCall)
129129
call.kind = FunctionCall::Kind::LowLevel;
130+
else if (isBuiltinFunction(call.signature))
131+
call.kind = FunctionCall::Kind::Builtin;
130132

131133
if (accept(Token::Comma, true))
132134
call.value = parseFunctionCallValue();

0 commit comments

Comments
 (0)