Skip to content

Commit

Permalink
Add test cases for built-in function-like macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Muqsit committed Nov 6, 2022
1 parent 8ab40a5 commit 6e83af5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/muqsit/arithmexp/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6e83af5

Please sign in to comment.