Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: pkg/front_end/test/scanner_replacement_test.dart

Issue 2850853004: Add 'scanGenericMethodComments' parameter to constructors and scan() functions. (Closed)
Patch Set: Parse generic method comments only in strong mode. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/utf8_bytes_scanner.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:convert' show UTF8; 5 import 'dart:convert' show UTF8;
6 6
7 import 'package:front_end/src/fasta/scanner/recover.dart' 7 import 'package:front_end/src/fasta/scanner/recover.dart'
8 show defaultRecoveryStrategy; 8 show defaultRecoveryStrategy;
9 import 'package:front_end/src/fasta/scanner.dart' as fasta; 9 import 'package:front_end/src/fasta/scanner.dart' as fasta;
10 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; 10 import 'package:front_end/src/fasta/scanner/token.dart' as fasta;
(...skipping 17 matching lines...) Expand all
28 /// token stream before verifying assertions. 28 /// token stream before verifying assertions.
29 /// 29 ///
30 /// These tests help to validate the correctness of the analyzer->Fasta token 30 /// These tests help to validate the correctness of the analyzer->Fasta token
31 /// stream conversion. 31 /// stream conversion.
32 @reflectiveTest 32 @reflectiveTest
33 class ScannerTest_Replacement extends ScannerTest { 33 class ScannerTest_Replacement extends ScannerTest {
34 @override 34 @override
35 analyzer.Token scanWithListener(String source, ErrorListener listener, 35 analyzer.Token scanWithListener(String source, ErrorListener listener,
36 {bool genericMethodComments: false, 36 {bool genericMethodComments: false,
37 bool lazyAssignmentOperators: false}) { 37 bool lazyAssignmentOperators: false}) {
38 if (genericMethodComments) {
39 // Fasta doesn't support generic method comments.
40 // TODO(danrubel): once the analyzer toolchain no longer needs generic
41 // method comments, remove tests that exercise them.
42 fail('No generic method comment support in Fasta');
43 }
44 // Note: Fasta always supports lazy assignment operators (`&&=` and `||=`), 38 // Note: Fasta always supports lazy assignment operators (`&&=` and `||=`),
45 // so we can ignore the `lazyAssignmentOperators` flag. 39 // so we can ignore the `lazyAssignmentOperators` flag.
46 // TODO(danrubel): once lazyAssignmentOperators are fully supported by 40 // TODO(danrubel): once lazyAssignmentOperators are fully supported by
47 // Dart, remove this flag. 41 // Dart, remove this flag.
48 fasta.ScannerResult result = fasta.scanString(source, includeComments: true, 42 fasta.ScannerResult result = fasta.scanString(source,
43 includeComments: true, scanGenericMethodComments: genericMethodComments,
49 recover: ((List<int> bytes, fasta.Token tokens, List<int> lineStarts) { 44 recover: ((List<int> bytes, fasta.Token tokens, List<int> lineStarts) {
50 // perform recovery as a separate step 45 // perform recovery as a separate step
51 // so that the token stream can be validated before and after recovery 46 // so that the token stream can be validated before and after recovery
52 return tokens; 47 return tokens;
53 })); 48 }));
54 fasta.Token tokens = result.tokens; 49 fasta.Token tokens = result.tokens;
55 assertValidTokenStream(tokens); 50 assertValidTokenStream(tokens);
56 assertValidBeginTokens(tokens); 51 assertValidBeginTokens(tokens);
57 if (result.hasErrors) { 52 if (result.hasErrors) {
58 List<int> bytes = UTF8.encode(source); 53 List<int> bytes = UTF8.encode(source);
(...skipping 12 matching lines...) Expand all
71 } 66 }
72 67
73 @override 68 @override
74 @failingTest 69 @failingTest
75 void test_bar_bar_eq() { 70 void test_bar_bar_eq() {
76 // TODO(paulberry,ahe): Fasta scanner doesn't support lazy assignment 71 // TODO(paulberry,ahe): Fasta scanner doesn't support lazy assignment
77 // operators. 72 // operators.
78 super.test_bar_bar_eq(); 73 super.test_bar_bar_eq();
79 } 74 }
80 75
81 @override
82 @failingTest
83 void test_comment_generic_method_type_assign() {
84 // TODO(paulberry,ahe): Fasta scanner doesn't support generic comment
85 // syntax.
86 super.test_comment_generic_method_type_assign();
87 }
88
89 @override
90 @failingTest
91 void test_comment_generic_method_type_list() {
92 // TODO(paulberry,ahe): Fasta scanner doesn't support generic comment
93 // syntax.
94 super.test_comment_generic_method_type_list();
95 }
96
97 void _assertOpenClosePair(String source) { 76 void _assertOpenClosePair(String source) {
98 fasta.BeginGroupToken open = _scan(source); 77 fasta.BeginGroupToken open = _scan(source);
99 fasta.Token close = open.next; 78 fasta.Token close = open.next;
100 expect(close.next.isEof, isTrue); 79 expect(close.next.isEof, isTrue);
101 expect(open.endGroup, close); 80 expect(open.endGroup, close);
102 expect(open.isSynthetic, isFalse); 81 expect(open.isSynthetic, isFalse);
103 expect(close.isSynthetic, isFalse); 82 expect(close.isSynthetic, isFalse);
104 } 83 }
105 84
106 void _assertOpenOnly(String source) { 85 void _assertOpenOnly(String source) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } else if (token is fasta.UnmatchedToken) { 369 } else if (token is fasta.UnmatchedToken) {
391 expect(lastClosedGroup?.endGroup?.next, same(token), 370 expect(lastClosedGroup?.endGroup?.next, same(token),
392 reason: 'Unexpected error token for group: $lastClosedGroup'); 371 reason: 'Unexpected error token for group: $lastClosedGroup');
393 expect(token.begin, lastClosedGroup); 372 expect(token.begin, lastClosedGroup);
394 } 373 }
395 token = token.next; 374 token = token.next;
396 } 375 }
397 expect(openerStack, isEmpty, reason: 'Missing closers'); 376 expect(openerStack, isEmpty, reason: 'Missing closers');
398 } 377 }
399 } 378 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/utf8_bytes_scanner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698