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

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

Issue 2872433005: more work aligning fasta.Token with analyzer.Token (Closed)
Patch Set: 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
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 'package:analyzer/src/fasta/token_utils.dart'; 5 import 'package:analyzer/src/fasta/token_utils.dart';
6 import 'package:front_end/src/fasta/scanner/error_token.dart' as fasta; 6 import 'package:front_end/src/fasta/scanner/error_token.dart' as fasta;
7 import 'package:front_end/src/fasta/scanner/string_scanner.dart' as fasta; 7 import 'package:front_end/src/fasta/scanner/string_scanner.dart' as fasta;
8 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; 8 import 'package:front_end/src/fasta/scanner/token.dart' as fasta;
9 import 'package:front_end/src/fasta/scanner/token_constants.dart' as fasta; 9 import 'package:front_end/src/fasta/scanner/token_constants.dart' as fasta;
10 import 'package:front_end/src/scanner/errors.dart'; 10 import 'package:front_end/src/scanner/errors.dart';
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 fasta.Token token; 146 fasta.Token token;
147 fasta.CommentToken c1; 147 fasta.CommentToken c1;
148 fasta.CommentToken c2; 148 fasta.CommentToken c2;
149 fasta.CommentToken c3; 149 fasta.CommentToken c3;
150 150
151 void prepareTokens() { 151 void prepareTokens() {
152 token = new fasta.StringScanner(code, includeComments: true).tokenize(); 152 token = new fasta.StringScanner(code, includeComments: true).tokenize();
153 153
154 expect(token.type.kind, fasta.IDENTIFIER_TOKEN); 154 expect(token.type.kind, fasta.IDENTIFIER_TOKEN);
155 155
156 c1 = token.precedingCommentTokens; 156 c1 = token.precedingComments;
157 c2 = c1.next; 157 c2 = c1.next;
158 c3 = c2.next; 158 c3 = c2.next;
159 expect(c3.next, isNull); 159 expect(c3.next, isNull);
160 160
161 expect(c1.parent, token); 161 expect(c1.parent, token);
162 expect(c2.parent, token); 162 expect(c2.parent, token);
163 expect(c3.parent, token); 163 expect(c3.parent, token);
164 164
165 expect(c1.lexeme, '/// aaa'); 165 expect(c1.lexeme, '/// aaa');
166 expect(c2.lexeme, '/// bbbb'); 166 expect(c2.lexeme, '/// bbbb');
167 expect(c3.lexeme, '/// ccccc'); 167 expect(c3.lexeme, '/// ccccc');
168 } 168 }
169 169
170 // Remove the first token. 170 // Remove the first token.
171 { 171 {
172 prepareTokens(); 172 prepareTokens();
173 c1.remove(); 173 c1.remove();
174 expect(token.precedingCommentTokens, c2); 174 expect(token.precedingComments, c2);
175 expect(c2.next, c3); 175 expect(c2.next, c3);
176 expect(c3.next, isNull); 176 expect(c3.next, isNull);
177 } 177 }
178 178
179 // Remove the second token. 179 // Remove the second token.
180 { 180 {
181 prepareTokens(); 181 prepareTokens();
182 c2.remove(); 182 c2.remove();
183 expect(token.precedingCommentTokens, c1); 183 expect(token.precedingComments, c1);
184 expect(c1.next, c3); 184 expect(c1.next, c3);
185 expect(c3.next, isNull); 185 expect(c3.next, isNull);
186 } 186 }
187 187
188 // Remove the last token. 188 // Remove the last token.
189 { 189 {
190 prepareTokens(); 190 prepareTokens();
191 c3.remove(); 191 c3.remove();
192 expect(token.precedingCommentTokens, c1); 192 expect(token.precedingComments, c1);
193 expect(c1.next, c2); 193 expect(c1.next, c2);
194 expect(c2.next, isNull); 194 expect(c2.next, isNull);
195 } 195 }
196 } 196 }
197 197
198 @override 198 @override
199 @failingTest 199 @failingTest
200 void test_incomplete_string_interpolation() { 200 void test_incomplete_string_interpolation() {
201 // TODO(danrubel): fix ToAnalyzerTokenStreamConverter_WithListener 201 // TODO(danrubel): fix ToAnalyzerTokenStreamConverter_WithListener
202 // to handle synthetic closers in token stream 202 // to handle synthetic closers in token stream
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 expect(openParen1.endToken, same(closeParen1)); 241 expect(openParen1.endToken, same(closeParen1));
242 expect(openBrace.endToken, same(closeBrace)); 242 expect(openBrace.endToken, same(closeBrace));
243 expect(openParen2.endToken, same(closeParen2)); 243 expect(openParen2.endToken, same(closeParen2));
244 } 244 }
245 245
246 void test_next_previous() { 246 void test_next_previous() {
247 const source = 'int a; /*1*/ /*2*/ /*3*/ B f(){if (a < 2) {}}'; 247 const source = 'int a; /*1*/ /*2*/ /*3*/ B f(){if (a < 2) {}}';
248 fasta.Token token = 248 fasta.Token token =
249 new fasta.StringScanner(source, includeComments: true).tokenize(); 249 new fasta.StringScanner(source, includeComments: true).tokenize();
250 while (!token.isEof) { 250 while (!token.isEof) {
251 expect(token.next.previousToken, token); 251 expect(token.next.previous, token);
252 fasta.CommentToken commentToken = token.precedingComments; 252 fasta.CommentToken commentToken = token.precedingComments;
253 while (commentToken != null) { 253 while (commentToken != null) {
254 if (commentToken.next != null) { 254 if (commentToken.next != null) {
255 expect(commentToken.next.previousToken, commentToken); 255 expect(commentToken.next.previous, commentToken);
256 } 256 }
257 commentToken = commentToken.next; 257 commentToken = commentToken.next;
258 } 258 }
259 token = token.next; 259 token = token.next;
260 } 260 }
261 } 261 }
262 262
263 @override 263 @override
264 @failingTest 264 @failingTest
265 void test_string_multi_unterminated() { 265 void test_string_multi_unterminated() {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 final ErrorListener _listener; 556 final ErrorListener _listener;
557 557
558 ToAnalyzerTokenStreamConverter_WithListener(this._listener); 558 ToAnalyzerTokenStreamConverter_WithListener(this._listener);
559 559
560 @override 560 @override
561 void reportError( 561 void reportError(
562 ScannerErrorCode errorCode, int offset, List<Object> arguments) { 562 ScannerErrorCode errorCode, int offset, List<Object> arguments) {
563 _listener.errors.add(new TestError(offset, errorCode, arguments)); 563 _listener.errors.add(new TestError(offset, errorCode, arguments));
564 } 564 }
565 } 565 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698