@@ -424,6 +424,48 @@ public function test_get_token_list_7(): void {
424424 }
425425 }
426426
427+ public function test_get_token_list_with_subsequent_comments (): void {
428+ $ input = <<<EOF
429+ # First comment
430+ # Second comment
431+ a = 1;
432+
433+ # Comment
434+
435+ # Comment
436+
437+ b = 2;
438+
439+ # Comment
440+ # comment with indentation
441+ #### comment
442+
443+ c = 3;
444+ EOF ;
445+
446+ // We are not testing the positions anymore.
447+ $ output = [
448+ new token (token::IDENTIFIER , 'a ' ),
449+ new token (token::OPERATOR , '= ' ),
450+ new token (token::NUMBER , 1 ),
451+ new token (token::END_OF_STATEMENT , '; ' ),
452+ new token (token::IDENTIFIER , 'b ' ),
453+ new token (token::OPERATOR , '= ' ),
454+ new token (token::NUMBER , 2 ),
455+ new token (token::END_OF_STATEMENT , '; ' ),
456+ new token (token::IDENTIFIER , 'c ' ),
457+ new token (token::OPERATOR , '= ' ),
458+ new token (token::NUMBER , 3 ),
459+ new token (token::END_OF_STATEMENT , '; ' ),
460+ ];
461+
462+ $ tokens = (new lexer ($ input ))->get_tokens ();
463+ foreach ($ tokens as $ i => $ token ) {
464+ self ::assertEquals ($ output [$ i ]->type , $ token ->type );
465+ self ::assertEquals ($ output [$ i ]->value , $ token ->value );
466+ }
467+ }
468+
427469 public function test_pi (): void {
428470 $ input = 'π + π(1 + 2) + pi + pi() + pi(2) + pi(1 + 2) ' ;
429471
0 commit comments