diff --git a/tests/LexerTest.php b/tests/LexerTest.php index 85c502740..806b65591 100644 --- a/tests/LexerTest.php +++ b/tests/LexerTest.php @@ -653,4 +653,25 @@ bar yield ['{{ ({ a: 1) }}', '{']; yield ['{{ (([1]) + 3 }}', '(']; } + + /** + * @dataProvider getTemplateForUnexpectedBracketInExpression + */ + public function testUnexpectedBracketInExpression(string $template, string $bracket) + { + $lexer = new Lexer(new Environment(new ArrayLoader())); + + $this->expectException(SyntaxError::class); + $this->expectExceptionMessage(\sprintf('Unexpected "%s" in "index" at line 1.', $bracket)); + + $lexer->tokenize(new Source($template, 'index')); + } + + public static function getTemplateForUnexpectedBracketInExpression() + { + yield ['{{ 1 + 3) }}', ')']; + yield ['{{ obj] }}', ']']; + yield ['{{ { a: 1 }}', '}']; + yield ['{{ ([1] + 3)) }}', ')']; + } }