Skip to content

Commit b3d02ce

Browse files
committed
minor symfony#58573 [ExpressionLanguage] Cover multiline comments (alexandre-daubois)
This PR was merged into the 7.2 branch. Discussion ---------- [ExpressionLanguage] Cover multiline comments | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Multiline comments case is currently not covered by tests. This PR adds this test case, also with some unicode in the comment. Commits ------- 3a0ba4b [ExpressionLanguage] Cover multiline comments
2 parents 6deaace + 3a0ba4b commit b3d02ce

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Symfony/Component/ExpressionLanguage/Tests/LexerTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,32 @@ public function testTokenize($tokens, $expression)
3535
$this->assertEquals(new TokenStream($tokens, $expression), $this->lexer->tokenize($expression));
3636
}
3737

38+
public function testTokenizeMultilineComment()
39+
{
40+
$expression = <<<EXPRESSION
41+
/**
42+
* This is 2^16, even if we could have
43+
* used the hexadecimal representation 0x10000. Just a
44+
* matter of taste! 🙂
45+
*/
46+
65536 and
47+
/*
48+
This time, only one star to start the comment and that's it.
49+
It is valid too!
50+
*/
51+
65535 /* this is 2^16 - 1 */
52+
EXPRESSION;
53+
54+
$tokens = [
55+
new Token('number', 65536, 128),
56+
new Token('operator', 'and', 134),
57+
new Token('number', 65535, 225),
58+
new Token('end of expression', null, \strlen($expression) + 1),
59+
];
60+
61+
$this->assertEquals(new TokenStream($tokens, str_replace("\n", ' ', $expression)), $this->lexer->tokenize($expression));
62+
}
63+
3864
public function testTokenizeThrowsErrorWithMessage()
3965
{
4066
$this->expectException(SyntaxError::class);

0 commit comments

Comments
 (0)