| Index: pkg/front_end/test/scanner_fasta_test.dart
|
| diff --git a/pkg/front_end/test/scanner_fasta_test.dart b/pkg/front_end/test/scanner_fasta_test.dart
|
| index ee1d36af75d35984cb46a4ede4b215ad84245188..b247bab8bf7f023cdea4ec4c6db3f68c9cacb348 100644
|
| --- a/pkg/front_end/test/scanner_fasta_test.dart
|
| +++ b/pkg/front_end/test/scanner_fasta_test.dart
|
| @@ -136,6 +136,74 @@ class ScannerTest_Fasta extends ScannerTestBase {
|
| expect(token.precedingComments?.lexeme, '// EOF comment');
|
| }
|
|
|
| + void test_CommentToken_remove() {
|
| + const code = '''
|
| +/// aaa
|
| +/// bbbb
|
| +/// ccccc
|
| +main() {}
|
| +''';
|
| +
|
| + fasta.Token token;
|
| + fasta.CommentToken c1;
|
| + fasta.CommentToken c2;
|
| + fasta.CommentToken c3;
|
| +
|
| + void prepareTokens() {
|
| + token = new fasta.StringScanner(code, includeComments: true).tokenize();
|
| +
|
| + expect(token.info.kind, fasta.IDENTIFIER_TOKEN);
|
| +
|
| + c1 = token.precedingCommentTokens;
|
| + c2 = c1.next;
|
| + c3 = c2.next;
|
| + expect(c3.next, isNull);
|
| +
|
| + expect(c1.parent, token);
|
| + expect(c2.parent, token);
|
| + expect(c3.parent, token);
|
| +
|
| + expect(c1.lexeme, '/// aaa');
|
| + expect(c2.lexeme, '/// bbbb');
|
| + expect(c3.lexeme, '/// ccccc');
|
| + }
|
| +
|
| + // Remove the first token.
|
| + {
|
| + prepareTokens();
|
| + c1.remove();
|
| + expect(token.precedingCommentTokens, c2);
|
| + expect(c2.next, c3);
|
| + expect(c3.next, isNull);
|
| + }
|
| +
|
| + // Remove the second token.
|
| + {
|
| + prepareTokens();
|
| + c2.remove();
|
| + expect(token.precedingCommentTokens, c1);
|
| + expect(c1.next, c3);
|
| + expect(c3.next, isNull);
|
| + }
|
| +
|
| + // Remove the last token.
|
| + {
|
| + prepareTokens();
|
| + c3.remove();
|
| + expect(token.precedingCommentTokens, c1);
|
| + expect(c1.next, c2);
|
| + expect(c2.next, isNull);
|
| + }
|
| + }
|
| +
|
| + @override
|
| + @failingTest
|
| + void test_incomplete_string_interpolation() {
|
| + // TODO(danrubel): fix ToAnalyzerTokenStreamConverter_WithListener
|
| + // to handle synthetic closers in token stream
|
| + super.test_incomplete_string_interpolation();
|
| + }
|
| +
|
| @override
|
| @failingTest
|
| void test_mismatched_closer() {
|
| @@ -152,31 +220,6 @@ class ScannerTest_Fasta extends ScannerTestBase {
|
| super.test_mismatched_opener();
|
| }
|
|
|
| - void test_next_previous() {
|
| - const source = 'int a; /*1*/ /*2*/ /*3*/ B f(){if (a < 2) {}}';
|
| - fasta.Token token =
|
| - new fasta.StringScanner(source, includeComments: true).tokenize();
|
| - while (!token.isEof) {
|
| - expect(token.next.previousToken, token);
|
| - fasta.CommentToken commentToken = token.precedingComments;
|
| - while (commentToken != null) {
|
| - if (commentToken.next != null) {
|
| - expect(commentToken.next.previousToken, commentToken);
|
| - }
|
| - commentToken = commentToken.next;
|
| - }
|
| - token = token.next;
|
| - }
|
| - }
|
| -
|
| - @override
|
| - @failingTest
|
| - void test_incomplete_string_interpolation() {
|
| - // TODO(danrubel): fix ToAnalyzerTokenStreamConverter_WithListener
|
| - // to handle synthetic closers in token stream
|
| - super.test_incomplete_string_interpolation();
|
| - }
|
| -
|
| @override
|
| void test_mismatched_opener_in_interpolation() {
|
| // When openers and closers are mismatched,
|
| @@ -201,6 +244,23 @@ class ScannerTest_Fasta extends ScannerTestBase {
|
| expect(openParen2.endToken, same(closeParen2));
|
| }
|
|
|
| + void test_next_previous() {
|
| + const source = 'int a; /*1*/ /*2*/ /*3*/ B f(){if (a < 2) {}}';
|
| + fasta.Token token =
|
| + new fasta.StringScanner(source, includeComments: true).tokenize();
|
| + while (!token.isEof) {
|
| + expect(token.next.previousToken, token);
|
| + fasta.CommentToken commentToken = token.precedingComments;
|
| + while (commentToken != null) {
|
| + if (commentToken.next != null) {
|
| + expect(commentToken.next.previousToken, commentToken);
|
| + }
|
| + commentToken = commentToken.next;
|
| + }
|
| + token = token.next;
|
| + }
|
| + }
|
| +
|
| @override
|
| @failingTest
|
| void test_string_multi_unterminated() {
|
|
|