aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-12-04 18:23:28 +0800
committerchriseth <chris@ethereum.org>2018-12-04 21:50:00 +0800
commit852297fa2f4c4ac0c3aa56011f70c667fafcb1fd (patch)
tree89624148ff8018c19742a737c45ed4a7c3dff573 /test
parentc3fc2da7637eb7f7d0c8930845b373fc0ea5be78 (diff)
downloaddexon-solidity-852297fa2f4c4ac0c3aa56011f70c667fafcb1fd.tar.gz
dexon-solidity-852297fa2f4c4ac0c3aa56011f70c667fafcb1fd.tar.zst
dexon-solidity-852297fa2f4c4ac0c3aa56011f70c667fafcb1fd.zip
Builtin functions for yul analysis.
Diffstat (limited to 'test')
-rw-r--r--test/libyul/Parser.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp
index fe66847f..eb2e735a 100644
--- a/test/libyul/Parser.cpp
+++ b/test/libyul/Parser.cpp
@@ -22,10 +22,12 @@
#include <test/Options.h>
#include <test/libsolidity/ErrorCheck.h>
+#include <test/libyul/Common.h>
#include <libyul/AsmParser.h>
#include <libyul/AsmAnalysis.h>
#include <libyul/AsmAnalysisInfo.h>
+#include <libyul/Dialect.h>
#include <liblangutil/Scanner.h>
#include <liblangutil/ErrorReporter.h>
@@ -319,6 +321,23 @@ BOOST_AUTO_TEST_CASE(builtins_parser)
CHECK_ERROR_DIALECT("{ builtin := 6 }", ParserError, "Cannot assign to builtin function \"builtin\".", dialect);
}
+BOOST_AUTO_TEST_CASE(builtins_analysis)
+{
+ struct SimpleBuiltinsAnalysis: public Builtins
+ {
+ yul::BuiltinFunction const* query(YulString _name) const override
+ {
+ return _name == YulString("builtin") ? &m_builtin : nullptr;
+ }
+ BuiltinFunction m_builtin{YulString{"builtin"}, vector<Type>(2), vector<Type>(3), false};
+ };
+
+ Dialect dialect(AsmFlavour::Strict, make_shared<SimpleBuiltinsAnalysis>());
+ BOOST_CHECK(successParse("{ let a, b, c := builtin(1, 2) }", dialect));
+ CHECK_ERROR_DIALECT("{ let a, b, c := builtin(1) }", TypeError, "Function expects 2 arguments but got 1", dialect);
+ CHECK_ERROR_DIALECT("{ let a, b := builtin(1, 2) }", DeclarationError, "Variable count mismatch: 2 variables and 3 values.", dialect);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}