File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ public function getNextToken(): ?TokenInterface
97
97
}
98
98
99
99
// Match a comment:
100
- if (preg_match ('/^\s*\{(.+ ?)\}\s*/s ' , $ this ->buffer , $ matches )) {
100
+ if (preg_match ('/^\s*\{(.* ?)\}\s*/s ' , $ this ->buffer , $ matches )) {
101
101
$ this ->buffer = substr ($ this ->buffer , strlen ($ matches [0 ]));
102
102
return new Comment ($ matches [1 ]);
103
103
}
Original file line number Diff line number Diff line change 9
9
10
10
namespace ChessZebra \PortableGameNotation \Lexer ;
11
11
12
+ use ChessZebra \PortableGameNotation \Token \Comment ;
12
13
use ChessZebra \PortableGameNotation \Token \MoveNumber ;
13
14
use PHPUnit \Framework \TestCase ;
14
15
@@ -27,4 +28,34 @@ public function testConstructor()
27
28
// Assert
28
29
static ::assertInstanceOf (MoveNumber::class, $ result );
29
30
}
31
+
32
+ public function testEmptyComment ()
33
+ {
34
+ // Arrange
35
+ $ buffer = '{} ' ;
36
+
37
+ $ lexer = new StringLexer ($ buffer );
38
+
39
+ // Act
40
+ $ result = $ lexer ->peekNextToken ();
41
+
42
+ // Assert
43
+ static ::assertInstanceOf (Comment::class, $ result );
44
+ static ::assertEquals ('' , $ result ->getComment ());
45
+ }
46
+
47
+ public function testPopulatedComment ()
48
+ {
49
+ // Arrange
50
+ $ buffer = '{ hello world } ' ;
51
+
52
+ $ lexer = new StringLexer ($ buffer );
53
+
54
+ // Act
55
+ $ result = $ lexer ->peekNextToken ();
56
+
57
+ // Assert
58
+ static ::assertInstanceOf (Comment::class, $ result );
59
+ static ::assertEquals (' hello world ' , $ result ->getComment ());
60
+ }
30
61
}
You can’t perform that action at this time.
0 commit comments