mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 04:27:00 +00:00
Add some tests on balanced brackets
This commit is contained in:
@@ -632,4 +632,25 @@ bar
|
||||
Some regular comment # this is an inline comment
|
||||
#}'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTemplateForUnclosedBracketInExpression
|
||||
*/
|
||||
public function testUnclosedBracketInExpression(string $template, string $bracket)
|
||||
{
|
||||
$lexer = new Lexer(new Environment(new ArrayLoader()));
|
||||
|
||||
$this->expectException(SyntaxError::class);
|
||||
$this->expectExceptionMessage(\sprintf('Unclosed "%s" in "index" at line 1.', $bracket));
|
||||
|
||||
$lexer->tokenize(new Source($template, 'index'));
|
||||
}
|
||||
|
||||
public static function getTemplateForUnclosedBracketInExpression()
|
||||
{
|
||||
yield ['{{ (1 + 3 }}', '('];
|
||||
yield ['{{ obj["a" }}', '['];
|
||||
yield ['{{ ({ a: 1) }}', '{'];
|
||||
yield ['{{ (([1]) + 3 }}', '('];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user