From c3fc2da7637eb7f7d0c8930845b373fc0ea5be78 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 3 Dec 2018 18:15:32 +0100 Subject: Tests for parser for builtins. --- test/libyul/Parser.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') 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()); + 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() } -- cgit