@@ -485,28 +485,58 @@ public class LexerTests: XCTestCase {
485
485
}
486
486
487
487
func testNotARegex( ) {
488
- var data =
489
- """
490
- min(reduced.count / 2, chunkSize / 2)
491
- """
492
- let lexemes = data. withUTF8 { buf in
493
- Lexer . lex ( buf)
488
+ do {
489
+ var data =
490
+ """
491
+ min(reduced.count / 2, chunkSize / 2)
492
+ """
493
+ let lexemes = data. withUTF8 { buf in
494
+ Lexer . lex ( buf)
495
+ }
496
+ AssertEqualTokens ( lexemes, [
497
+ lexeme ( . identifier, " min " ) ,
498
+ lexeme ( . leftParen, " ( " ) ,
499
+ lexeme ( . identifier, " reduced " ) ,
500
+ lexeme ( . period, " . " ) ,
501
+ lexeme ( . identifier, " count " , trailing: 1 ) ,
502
+ lexeme ( . spacedBinaryOperator, " / " , trailing: 1 ) ,
503
+ lexeme ( . integerLiteral, " 2 " ) ,
504
+ lexeme ( . comma, " , " , trailing: 1 ) ,
505
+ lexeme ( . identifier, " chunkSize " , trailing: 1 ) ,
506
+ lexeme ( . spacedBinaryOperator, " / " , trailing: 1 ) ,
507
+ lexeme ( . integerLiteral, " 2 " ) ,
508
+ lexeme ( . rightParen, " ) " ) ,
509
+ lexeme ( . eof, " " ) ,
510
+ ] )
511
+ }
512
+
513
+ do {
514
+ var data =
515
+ """
516
+ var x: Int {
517
+ return 0 /
518
+ x
519
+ }
520
+
521
+ ///
522
+ """
523
+ let lexemes = data. withUTF8 { buf in
524
+ Lexer . lex ( buf)
525
+ }
526
+ AssertEqualTokens ( lexemes, [
527
+ lexeme ( . varKeyword, " var " , trailing: 1 ) ,
528
+ lexeme ( . identifier, " x " ) ,
529
+ lexeme ( . colon, " : " , trailing: 1 ) ,
530
+ lexeme ( . identifier, " Int " , trailing: 1 ) ,
531
+ lexeme ( . leftBrace, " { " ) ,
532
+ lexeme ( . returnKeyword, " \n return " , leading: 3 , trailing: 1 ) ,
533
+ lexeme ( . integerLiteral, " 0 " , trailing: 1 ) ,
534
+ lexeme ( . spacedBinaryOperator, " / " , trailing: 0 ) ,
535
+ lexeme ( . identifier, " \n x " , leading: 10 ) ,
536
+ lexeme ( . rightBrace, " \n } " , leading: 1 ) ,
537
+ lexeme ( . eof, " \n \n /// " , leading: 5 ) ,
538
+ ] )
494
539
}
495
- AssertEqualTokens ( lexemes, [
496
- lexeme ( . identifier, " min " ) ,
497
- lexeme ( . leftParen, " ( " ) ,
498
- lexeme ( . identifier, " reduced " ) ,
499
- lexeme ( . period, " . " ) ,
500
- lexeme ( . identifier, " count " , trailing: 1 ) ,
501
- lexeme ( . spacedBinaryOperator, " / " , trailing: 1 ) ,
502
- lexeme ( . integerLiteral, " 2 " ) ,
503
- lexeme ( . comma, " , " , trailing: 1 ) ,
504
- lexeme ( . identifier, " chunkSize " , trailing: 1 ) ,
505
- lexeme ( . spacedBinaryOperator, " / " , trailing: 1 ) ,
506
- lexeme ( . integerLiteral, " 2 " ) ,
507
- lexeme ( . rightParen, " ) " ) ,
508
- lexeme ( . eof, " " ) ,
509
- ] )
510
540
}
511
541
512
542
func testUnicodeReplcementsInStream( ) {
0 commit comments