@@ -97,4 +97,64 @@ static function (Comment $comment): string {
9797 );
9898 self ::assertSame ($ expectedComments , $ commentsAsText );
9999 }
100+
101+ /**
102+ * @test
103+ */
104+ public function consumeIfComesComsumesMatchingContent (): void
105+ {
106+ $ subject = new ParserState ('abc ' , Settings::create ());
107+
108+ $ subject ->consumeIfComes ('ab ' );
109+
110+ self ::assertSame ('c ' , $ subject ->peek ());
111+ }
112+
113+ /**
114+ * @test
115+ */
116+ public function consumeIfComesDoesNotComsumeNonMatchingContent (): void
117+ {
118+ $ subject = new ParserState ('a ' , Settings::create ());
119+
120+ $ subject ->consumeIfComes ('x ' );
121+
122+ self ::assertSame ('a ' , $ subject ->peek ());
123+ }
124+
125+ /**
126+ * @test
127+ */
128+ public function consumeIfComesReturnsTrueIfContentConsumed (): void
129+ {
130+ $ subject = new ParserState ('abc ' , Settings::create ());
131+
132+ $ result = $ subject ->consumeIfComes ('ab ' );
133+
134+ self ::assertTrue ($ result );
135+ }
136+
137+ /**
138+ * @test
139+ */
140+ public function consumeIfComesReturnsFalseIfContentNotConsumed (): void
141+ {
142+ $ subject = new ParserState ('a ' , Settings::create ());
143+
144+ $ result = $ subject ->consumeIfComes ('x ' );
145+
146+ self ::assertFalse ($ result );
147+ }
148+
149+ /**
150+ * @test
151+ */
152+ public function consumeIfComesUpdatesLineNumber (): void
153+ {
154+ $ subject = new ParserState ("\n" , Settings::create ());
155+
156+ $ subject ->consumeIfComes ("\n" );
157+
158+ self ::assertSame (2 , $ subject ->currentLine ());
159+ }
100160}
0 commit comments