diff options
author | chriseth <chris@ethereum.org> | 2018-12-04 01:15:32 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-12-04 21:49:16 +0800 |
commit | c3fc2da7637eb7f7d0c8930845b373fc0ea5be78 (patch) | |
tree | d4343042d933d2fb9127fda43b155a5d1e2bb95d /test | |
parent | 961026347d9749c7c679be503363391c7bb14673 (diff) | |
download | dexon-solidity-c3fc2da7637eb7f7d0c8930845b373fc0ea5be78.tar.gz dexon-solidity-c3fc2da7637eb7f7d0c8930845b373fc0ea5be78.tar.zst dexon-solidity-c3fc2da7637eb7f7d0c8930845b373fc0ea5be78.zip |
Tests for parser for builtins.
Diffstat (limited to 'test')
-rw-r--r-- | test/libyul/Parser.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp index 95ae8959..fe66847f 100644 --- a/test/libyul/Parser.cpp +++ b/test/libyul/Parser.cpp @@ -302,6 +302,23 @@ BOOST_AUTO_TEST_CASE(if_statement_invalid) BOOST_CHECK(successParse("{ if 42:u256 { } }")); } +BOOST_AUTO_TEST_CASE(builtins_parser) +{ + struct SimpleBuiltins: public Builtins + { + BuiltinFunction const* query(YulString _name) const override + { + return _name == YulString{"builtin"} ? &f : nullptr; + } + BuiltinFunction f; + }; + + Dialect dialect(AsmFlavour::Strict, make_shared<SimpleBuiltins>()); + CHECK_ERROR_DIALECT("{ let builtin := 6 }", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect); + CHECK_ERROR_DIALECT("{ function builtin() {} }", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect); + CHECK_ERROR_DIALECT("{ builtin := 6 }", ParserError, "Cannot assign to builtin function \"builtin\".", dialect); +} + BOOST_AUTO_TEST_SUITE_END() } |