From c4aa1443d4e45929cec30f6a7059bf8929fb55eb Mon Sep 17 00:00:00 2001 From: Muqsit Date: Thu, 20 Oct 2022 05:07:50 +0000 Subject: [PATCH] Add test cases for brackets of different types (address #13) --- tests/muqsit/arithmexp/ParserTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/muqsit/arithmexp/ParserTest.php b/tests/muqsit/arithmexp/ParserTest.php index 173eea2..a3ae056 100644 --- a/tests/muqsit/arithmexp/ParserTest.php +++ b/tests/muqsit/arithmexp/ParserTest.php @@ -46,10 +46,30 @@ public function testNoClosingParenthesis() : void{ TestUtil::assertParserThrows($this->parser, "x + (2 * y + (z / 2) + 5", ParseException::ERR_NO_CLOSING_PAREN, 4, 5); } + public function testNoClosingParenthesisOfDifferingType() : void{ + TestUtil::assertParserThrows($this->parser, "x + [(2 * y + z / 2) + 5", ParseException::ERR_NO_CLOSING_PAREN, 4, 5); + } + + public function testUnexpectedParenthesisOfOpeningType() : void{ + TestUtil::assertParserThrows($this->parser, "x + ([2 * y + z / 2) + 5", ParseException::ERR_UNEXPECTED_PAREN, 19, 20); + } + public function testNoOpeningParenthesis() : void{ TestUtil::assertParserThrows($this->parser, "x + (2 * y + z / 2)) + 5", ParseException::ERR_NO_OPENING_PAREN, 19, 20); } + public function testNoOpeningParenthesisOfDifferingType() : void{ + TestUtil::assertParserThrows($this->parser, "x + (2 * y + z / 2)] + 5", ParseException::ERR_NO_OPENING_PAREN, 19, 20); + } + + public function testUnexpectedParenthesisOfClosingType() : void{ + TestUtil::assertParserThrows($this->parser, "x + (2 * y + z / 2]) + 5", ParseException::ERR_UNEXPECTED_PAREN, 18, 19); + } + + public function testUnexpectedParenthesisTypeInOverlap() : void{ + TestUtil::assertParserThrows($this->parser, "x + (2 * y + z / [2)] + 5", ParseException::ERR_UNEXPECTED_PAREN, 19, 20); + } + public function testNoUnaryOperand() : void{ TestUtil::assertParserThrows($this->parser, "x*+", ParseException::ERR_NO_OPERAND_UNARY, 2, 3); }