File tree 2 files changed +27
-13
lines changed
2 files changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,18 @@ public function getNextToken(): ?TokenInterface
54
54
return new TagPair ($ matches [1 ], $ matches [3 ]);
55
55
}
56
56
57
+ // Match a null move
58
+ if (preg_match ('/^\s*--\s*/ ' , $ this ->buffer , $ matches )) {
59
+ $ this ->buffer = substr ($ this ->buffer , strlen ($ matches [0 ]));
60
+ return new NullMove ();
61
+ }
62
+
63
+ // Match a null move
64
+ if (preg_match ('/^\s*Z0\s*/ ' , $ this ->buffer , $ matches )) {
65
+ $ this ->buffer = substr ($ this ->buffer , strlen ($ matches [0 ]));
66
+ return new NullMove ();
67
+ }
68
+
57
69
// Match an end result:
58
70
if (preg_match ('/^\s*(\*|1-0|0-1|1\/2-1\/2)\s*/ ' , $ this ->buffer , $ matches )) {
59
71
$ this ->buffer = substr ($ this ->buffer , strlen ($ matches [0 ]));
@@ -96,18 +108,6 @@ public function getNextToken(): ?TokenInterface
96
108
return new NumericAnnotationGlyph ((int )trim ($ matches [1 ]));
97
109
}
98
110
99
- // Match a null move
100
- if (preg_match ('/^\s*--\s*/ ' , $ this ->buffer , $ matches )) {
101
- $ this ->buffer = substr ($ this ->buffer , strlen ($ matches [0 ]));
102
- return new NullMove ();
103
- }
104
-
105
- // Match a null move
106
- if (preg_match ('/^\s*Z0\s*/ ' , $ this ->buffer , $ matches )) {
107
- $ this ->buffer = substr ($ this ->buffer , strlen ($ matches [0 ]));
108
- return new NullMove ();
109
- }
110
-
111
111
throw InvalidTokenException::createForBuffer ($ this ->buffer );
112
112
}
113
113
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ public function testMatchEndResultWhiteWins()
126
126
static ::assertEquals ('1-0 ' , $ result ->getResult ());
127
127
}
128
128
129
- public function testMatchNullMove ()
129
+ public function testMatchNullMoveWithDashes ()
130
130
{
131
131
// Arrange
132
132
$ buffer = '-- ' ;
@@ -140,6 +140,20 @@ public function testMatchNullMove()
140
140
static ::assertInstanceOf (NullMove::class, $ result );
141
141
}
142
142
143
+ public function testMatchNullMoveWithZ0 ()
144
+ {
145
+ // Arrange
146
+ $ buffer = 'Z0 ' ;
147
+
148
+ $ lexer = new StringLexer ($ buffer );
149
+
150
+ // Act
151
+ $ result = $ lexer ->getNextToken ();
152
+
153
+ // Assert
154
+ static ::assertInstanceOf (NullMove::class, $ result );
155
+ }
156
+
143
157
public function testMoveNumberWhite ()
144
158
{
145
159
// Arrange
You can’t perform that action at this time.
0 commit comments