@@ -467,28 +467,40 @@ fn serialize_rgba_two_digit_float_if_roundtrips() {
467
467
468
468
#[ test]
469
469
fn 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
+ ) ) ;
471
480
let mut input = Parser :: new ( & mut input) ;
472
481
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 } ) ;
475
484
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 } ) ;
477
486
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 } ) ;
481
490
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 } ) ;
483
492
let position = input. position ( ) ;
484
493
485
494
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 } ) ;
487
498
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 } ) ;
489
501
490
502
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 } ) ;
492
504
assert ! ( input. next_including_whitespace( ) . is_err( ) ) ;
493
505
}
494
506
0 commit comments