@@ -467,28 +467,40 @@ fn serialize_rgba_two_digit_float_if_roundtrips() {
467467
468468#[ test]
469469fn line_numbers ( ) {
470- let mut input = ParserInput :: new ( "foo bar\n baz\r \n \n \" a\\ \r \n b\" " ) ;
470+ let mut input = ParserInput :: new ( concat ! (
471+ "fo\\ 30\r \n " ,
472+ "0o bar/*\n " ,
473+ "*/baz\r \n " ,
474+ "\n " ,
475+ "url(\r \n " ,
476+ " u \r \n " ,
477+ ")\" a\\ \r \n " ,
478+ "b\" "
479+ ) ) ;
471480 let mut input = Parser :: new ( & mut input) ;
472481 assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 0 , column: 0 } ) ;
473- assert_eq ! ( input. next_including_whitespace( ) , Ok ( & Token :: Ident ( "foo " . into( ) ) ) ) ;
474- assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 0 , column: 3 } ) ;
482+ assert_eq ! ( input. next_including_whitespace( ) , Ok ( & Token :: Ident ( "fo00o " . into( ) ) ) ) ;
483+ assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 2 } ) ;
475484 assert_eq ! ( input. next_including_whitespace( ) , Ok ( & Token :: WhiteSpace ( " " ) ) ) ;
476- assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 0 , column: 4 } ) ;
485+ assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 3 } ) ;
477486 assert_eq ! ( input. next_including_whitespace( ) , Ok ( & Token :: Ident ( "bar" . into( ) ) ) ) ;
478- assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 0 , column: 7 } ) ;
479- assert_eq ! ( input. next_including_whitespace ( ) , Ok ( & Token :: WhiteSpace ( "\n " ) ) ) ;
480- assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 0 } ) ;
487+ assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 6 } ) ;
488+ assert_eq ! ( input. next_including_whitespace_and_comments ( ) , Ok ( & Token :: Comment ( "\n " ) ) ) ;
489+ assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 2 , column: 2 } ) ;
481490 assert_eq ! ( input. next_including_whitespace( ) , Ok ( & Token :: Ident ( "baz" . into( ) ) ) ) ;
482- assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 1 , column: 3 } ) ;
491+ assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 2 , column: 5 } ) ;
483492 let position = input. position ( ) ;
484493
485494 assert_eq ! ( input. next_including_whitespace( ) , Ok ( & Token :: WhiteSpace ( "\r \n \n " ) ) ) ;
486- assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 3 , column: 0 } ) ;
495+ assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 4 , column: 0 } ) ;
496+
497+ assert_eq ! ( input. source_location( position) , SourceLocation { line: 2 , column: 5 } ) ;
487498
488- assert_eq ! ( input. source_location( position) , SourceLocation { line: 1 , column: 3 } ) ;
499+ assert_eq ! ( input. next_including_whitespace( ) , Ok ( & Token :: UnquotedUrl ( "u" . into( ) ) ) ) ;
500+ assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 6 , column: 1 } ) ;
489501
490502 assert_eq ! ( input. next_including_whitespace( ) , Ok ( & Token :: QuotedString ( "ab" . into( ) ) ) ) ;
491- assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 4 , column: 2 } ) ;
503+ assert_eq ! ( input. current_source_location( ) , SourceLocation { line: 7 , column: 2 } ) ;
492504 assert ! ( input. next_including_whitespace( ) . is_err( ) ) ;
493505}
494506
0 commit comments