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

Side by Side Diff: pkg/analyzer/test/generated/incremental_scanner_test.dart

Issue 1045553002: Implement the new '??' operator in analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix if_null_precedence_test for unchecked operation. Created 5 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library engine.incremental_scanner_test; 5 library engine.incremental_scanner_test;
6 6
7 import 'package:analyzer/src/generated/engine.dart';
7 import 'package:analyzer/src/generated/incremental_scanner.dart'; 8 import 'package:analyzer/src/generated/incremental_scanner.dart';
8 import 'package:analyzer/src/generated/scanner.dart'; 9 import 'package:analyzer/src/generated/scanner.dart';
9 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
10 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
11 12
12 import '../reflective_tests.dart'; 13 import '../reflective_tests.dart';
13 import 'test_support.dart'; 14 import 'test_support.dart';
14 15
15 main() { 16 main() {
16 groupSep = ' | '; 17 groupSep = ' | ';
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 214 }
214 215
215 void test_insert_newIdentifier_spaceBefore() { 216 void test_insert_newIdentifier_spaceBefore() {
216 // "a; c;" 217 // "a; c;"
217 // "a; b c;" 218 // "a; b c;"
218 _scan("a; ", "", "b ", "c;"); 219 _scan("a; ", "", "b ", "c;");
219 _assertTokens(1, 3, ["a", ";", "b", "c", ";"]); 220 _assertTokens(1, 3, ["a", ";", "b", "c", ";"]);
220 expect(_incrementalScanner.hasNonWhitespaceChange, isTrue); 221 expect(_incrementalScanner.hasNonWhitespaceChange, isTrue);
221 } 222 }
222 223
223 void test_insert_periodAndIdentifier() {
224 // "a + b;"
225 // "a + b.x;"
226 _scan("a + b", "", ".x", ";");
227 _assertTokens(2, 5, ["a", "+", "b", ".", "x", ";"]);
228 }
229
230 void test_insert_period_afterIdentifier() { 224 void test_insert_period_afterIdentifier() {
231 // "a + b;" 225 // "a + b;"
232 // "a + b.;" 226 // "a + b.;"
233 _scan("a + b", "", ".", ";"); 227 _scan("a + b", "", ".", ";");
234 _assertTokens(2, 4, ["a", "+", "b", ".", ";"]); 228 _assertTokens(2, 4, ["a", "+", "b", ".", ";"]);
235 } 229 }
236 230
237 void test_insert_period_betweenIdentifiers_left() { 231 void test_insert_period_betweenIdentifiers_left() {
238 // "a b;" 232 // "a b;"
239 // "a. b;" 233 // "a. b;"
(...skipping 18 matching lines...) Expand all
258 } 252 }
259 253
260 void test_insert_period_insideExistingIdentifier() { 254 void test_insert_period_insideExistingIdentifier() {
261 // "ab;" 255 // "ab;"
262 // "a.b;" 256 // "a.b;"
263 _scan("a", "", ".", "b;"); 257 _scan("a", "", ".", "b;");
264 _assertTokens(-1, 3, ["a", ".", "b", ";"]); 258 _assertTokens(-1, 3, ["a", ".", "b", ";"]);
265 expect(_incrementalScanner.hasNonWhitespaceChange, isTrue); 259 expect(_incrementalScanner.hasNonWhitespaceChange, isTrue);
266 } 260 }
267 261
262 void test_insert_periodAndIdentifier() {
263 // "a + b;"
264 // "a + b.x;"
265 _scan("a + b", "", ".x", ";");
266 _assertTokens(2, 5, ["a", "+", "b", ".", "x", ";"]);
267 }
268
268 void test_insert_splitIdentifier() { 269 void test_insert_splitIdentifier() {
269 // "cob;" 270 // "cob;"
270 // "cow.b;" 271 // "cow.b;"
271 _scan("co", "", "w.", "b;"); 272 _scan("co", "", "w.", "b;");
272 _assertTokens(-1, 3, ["cow", ".", "b", ";"]); 273 _assertTokens(-1, 3, ["cow", ".", "b", ";"]);
273 expect(_incrementalScanner.hasNonWhitespaceChange, isTrue); 274 expect(_incrementalScanner.hasNonWhitespaceChange, isTrue);
274 } 275 }
275 276
276 void test_insert_tokens_within_whitespace() { 277 void test_insert_tokens_within_whitespace() {
277 // "a ;" 278 // "a ;"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 // 492 //
492 GatheringErrorListener modifiedListener = new GatheringErrorListener(); 493 GatheringErrorListener modifiedListener = new GatheringErrorListener();
493 Scanner modifiedScanner = new Scanner( 494 Scanner modifiedScanner = new Scanner(
494 source, new CharSequenceReader(modifiedContents), modifiedListener); 495 source, new CharSequenceReader(modifiedContents), modifiedListener);
495 Token modifiedTokens = modifiedScanner.tokenize(); 496 Token modifiedTokens = modifiedScanner.tokenize();
496 expect(modifiedTokens, isNotNull); 497 expect(modifiedTokens, isNotNull);
497 // 498 //
498 // Incrementally scan the modified contents. 499 // Incrementally scan the modified contents.
499 // 500 //
500 GatheringErrorListener incrementalListener = new GatheringErrorListener(); 501 GatheringErrorListener incrementalListener = new GatheringErrorListener();
501 _incrementalScanner = new IncrementalScanner( 502 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
502 source, new CharSequenceReader(modifiedContents), incrementalListener); 503 _incrementalScanner = new IncrementalScanner(source,
504 new CharSequenceReader(modifiedContents), incrementalListener, options);
503 _incrementalTokens = _incrementalScanner.rescan( 505 _incrementalTokens = _incrementalScanner.rescan(
504 _originalTokens, replaceStart, removed.length, added.length); 506 _originalTokens, replaceStart, removed.length, added.length);
505 // 507 //
506 // Validate that the results of the incremental scan are the same as the 508 // Validate that the results of the incremental scan are the same as the
507 // full scan of the modified source. 509 // full scan of the modified source.
508 // 510 //
509 Token incrementalToken = _incrementalTokens; 511 Token incrementalToken = _incrementalTokens;
510 expect(incrementalToken, isNotNull); 512 expect(incrementalToken, isNotNull);
511 while (incrementalToken.type != TokenType.EOF && 513 while (incrementalToken.type != TokenType.EOF &&
512 modifiedTokens.type != TokenType.EOF) { 514 modifiedTokens.type != TokenType.EOF) {
(...skipping 12 matching lines...) Expand all
525 incrementalToken = incrementalToken.next; 527 incrementalToken = incrementalToken.next;
526 modifiedTokens = modifiedTokens.next; 528 modifiedTokens = modifiedTokens.next;
527 } 529 }
528 expect(incrementalToken.type, same(TokenType.EOF), 530 expect(incrementalToken.type, same(TokenType.EOF),
529 reason: "Too many tokens"); 531 reason: "Too many tokens");
530 expect(modifiedTokens.type, same(TokenType.EOF), 532 expect(modifiedTokens.type, same(TokenType.EOF),
531 reason: "Not enough tokens"); 533 reason: "Not enough tokens");
532 // TODO(brianwilkerson) Verify that the errors are correct? 534 // TODO(brianwilkerson) Verify that the errors are correct?
533 } 535 }
534 } 536 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/engine_test.dart ('k') | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698