Skip to content

Commit 7b6184a

Browse files
committed
Fix test builtins & add simple smoke test.
1 parent 15decd2 commit 7b6184a

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

test/libsolidity/SemanticTest.cpp

Lines changed: 10 additions & 0 deletions
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,14 @@ SemanticTest::SemanticTest(
122124
}
123125
}
124126

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

test/libsolidity/SemanticTest.h

Lines changed: 1 addition & 0 deletions
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;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
contract SmokeTest {
2+
}
3+
// ====
4+
// compileViaYul: also
5+
// ----
6+
// constructor()
7+
// smoke_test -> 0x1234

test/libsolidity/util/TestFileParser.cpp

Lines changed: 2 additions & 0 deletions
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)