From 6e83af5bf90e034deac79ffa813a162f302557fb Mon Sep 17 00:00:00 2001 From: Muqsit Date: Sun, 6 Nov 2022 04:36:43 +0000 Subject: [PATCH] Add test cases for built-in function-like macros --- tests/muqsit/arithmexp/ParserTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/muqsit/arithmexp/ParserTest.php b/tests/muqsit/arithmexp/ParserTest.php index dd8444e..5f3b0a0 100644 --- a/tests/muqsit/arithmexp/ParserTest.php +++ b/tests/muqsit/arithmexp/ParserTest.php @@ -114,6 +114,19 @@ public function testMacroArgumentParser() : void{ TestUtil::assertExpressionsEqual($non_macro_parser->parse("fn(x, 4, pi)"), $this->uo_parser->parse("fn(x,,pi)")); } + public function testBuiltInMacros() : void{ + TestUtil::assertParserThrows($this->uo_parser, "max()", ParseException::ERR_UNRESOLVABLE_FCALL, 0, 5); + TestUtil::assertExpressionsEqual($this->uo_parser->parse("max(x)"), $this->uo_parser->parse("x")); + TestUtil::assertExpressionsEqual($this->uo_parser->parse("max(x, y)"), $this->uo_parser->parse("max(x, y)")); + + TestUtil::assertParserThrows($this->uo_parser, "min()", ParseException::ERR_UNRESOLVABLE_FCALL, 0, 5); + TestUtil::assertExpressionsEqual($this->uo_parser->parse("min(x)"), $this->uo_parser->parse("x")); + TestUtil::assertExpressionsEqual($this->uo_parser->parse("min(x, y)"), $this->uo_parser->parse("min(x, y)")); + + TestUtil::assertExpressionsEqual($this->uo_parser->parse("x ** y"), $this->uo_parser->parse("pow(x, y)")); + TestUtil::assertExpressionsEqual($this->uo_parser->parse("x ** 0.5"), $this->uo_parser->parse("sqrt(x)")); + } + public function testMacroArgumentReplacer() : void{ $this->uo_parser->getFunctionRegistry()->registerMacro( "fn",