From e03d910e4b33055a77aecf79a5f1bfeb00d6e96a Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 26 Nov 2020 23:52:35 +0000 Subject: [PATCH] Support parsing balance in isoltest --- test/libsolidity/SemanticTest.cpp | 2 +- test/libsolidity/util/SoltestTypes.h | 9 ++++++--- test/libsolidity/util/TestFileParser.cpp | 16 ++++++++++++++++ test/libsolidity/util/TestFunctionCall.cpp | 4 ++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 73ca07e39..7657a6c84 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -234,7 +234,7 @@ TestCase::TestResult SemanticTest::runTest(ostream& _stream, string const& _line return TestResult::Failure; } - if (!success && (m_runWithYul || !_compileViaYul)) + if (!success) // && (m_runWithYul || !_compileViaYul)) { AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl; for (auto const& test: m_tests) diff --git a/test/libsolidity/util/SoltestTypes.h b/test/libsolidity/util/SoltestTypes.h index e0f6caa1f..98667ed57 100644 --- a/test/libsolidity/util/SoltestTypes.h +++ b/test/libsolidity/util/SoltestTypes.h @@ -23,7 +23,7 @@ namespace solidity::frontend::test /** * All soltest tokens. */ -#define SOLT_TOKEN_LIST(T, K) \ +#define SOLT_TOKEN_LIST(T, K) \ T(Unknown, "unknown", 0) \ T(Invalid, "invalid", 0) \ T(EOS, "EOS", 0) \ @@ -57,7 +57,8 @@ namespace solidity::frontend::test K(Library, "library", 0) \ K(Right, "right", 0) \ K(Failure, "FAILURE", 0) \ - K(Storage, "storage", 0) \ + K(Storage, "storage", 0) \ + K(Balance, "balance", 0) namespace soltest { @@ -286,7 +287,9 @@ struct FunctionCall /// Marks a library deployment call. Library, /// Check that the storage of the current contract is empty or non-empty. - Storage + Storage, + /// Check balance of current contract. + Balance }; Kind kind = Kind::Regular; /// Marks this function call as "short-handed", meaning diff --git a/test/libsolidity/util/TestFileParser.cpp b/test/libsolidity/util/TestFileParser.cpp index 7654e384d..53f90a1fc 100644 --- a/test/libsolidity/util/TestFileParser.cpp +++ b/test/libsolidity/util/TestFileParser.cpp @@ -100,6 +100,21 @@ vector TestFileParser::parseFunctionCall call.kind = FunctionCall::Kind::Storage; m_scanner.scanNextToken(); } + else if (accept(Token::Balance, true)) + { + // Address is specified + if (accept(Token::HexNumber, true)) + { + } +// expect(Token::Colon); + expect(Token::Arrow); + call.expectations.failure = false; + call.expectations.result.push_back(Parameter()); + // expectation encoded as value + call.value = parseFunctionCallValue(); + call.kind = FunctionCall::Kind::Balance; + m_scanner.scanNextToken(); + } else { bool lowLevelCall = false; @@ -498,6 +513,7 @@ void TestFileParser::Scanner::scanNextToken() if (_literal == "hex") return {Token::Hex, ""}; if (_literal == "FAILURE") return {Token::Failure, ""}; if (_literal == "storage") return {Token::Storage, ""}; + if (_literal == "balance") return {Token::Balance, ""}; return {Token::Identifier, _literal}; }; diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index e13fccf09..24102632c 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -74,6 +74,10 @@ string TestFunctionCall::format( return; } + else if (m_call.kind == FunctionCall::Kind::Balance) + { + + } /// Formats the function signature. This is the same independent from the display-mode. stream << _linePrefix << newline << ws << m_call.signature;