mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix test builtins & add simple smoke test.
This commit is contained in:
parent
dce3006723
commit
8239eaa1b8
@ -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;
|
||||
|
@ -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;
|
||||
|
7
test/libsolidity/semanticTests/builtins/smoke_test.sol
Normal file
7
test/libsolidity/semanticTests/builtins/smoke_test.sol
Normal file
@ -0,0 +1,7 @@
|
||||
contract SmokeTest {
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// constructor()
|
||||
// smokeTest -> 0x1234
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user