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

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

Issue 1266923004: More fixes for failures on the Windows bot (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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) 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/engine.dart';
8 import 'package:analyzer/src/generated/incremental_scanner.dart'; 8 import 'package:analyzer/src/generated/incremental_scanner.dart';
9 import 'package:analyzer/src/generated/scanner.dart'; 9 import 'package:analyzer/src/generated/scanner.dart';
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
11 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
12 12
13 import '../reflective_tests.dart'; 13 import '../reflective_tests.dart';
14 import '../utils.dart';
14 import 'test_support.dart'; 15 import 'test_support.dart';
15 16
16 main() { 17 main() {
17 groupSep = ' | '; 18 initializeTestEnvironment();
18 runReflectiveTests(IncrementalScannerTest); 19 runReflectiveTests(IncrementalScannerTest);
19 } 20 }
20 21
21 @reflectiveTest 22 @reflectiveTest
22 class IncrementalScannerTest extends EngineTestCase { 23 class IncrementalScannerTest extends EngineTestCase {
23 /** 24 /**
24 * The first token from the token stream resulting from parsing the original 25 * The first token from the token stream resulting from parsing the original
25 * source, or `null` if [scan] has not been invoked. 26 * source, or `null` if [scan] has not been invoked.
26 */ 27 */
27 Token _originalTokens; 28 Token _originalTokens;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // "a + b; " 311 // "a + b; "
311 // "a + b; " 312 // "a + b; "
312 _scan("a + b; ", "", " ", ""); 313 _scan("a + b; ", "", " ", "");
313 _assertTokens(3, 4, ["a", "+", "b", ";"]); 314 _assertTokens(3, 4, ["a", "+", "b", ";"]);
314 expect(_incrementalScanner.hasNonWhitespaceChange, isFalse); 315 expect(_incrementalScanner.hasNonWhitespaceChange, isFalse);
315 } 316 }
316 317
317 void test_insert_whitespace_withMultipleComments() { 318 void test_insert_whitespace_withMultipleComments() {
318 // "//comment1", "//comment2", "a + b;" 319 // "//comment1", "//comment2", "a + b;"
319 // "//comment1", "//comment2", "a + b;" 320 // "//comment1", "//comment2", "a + b;"
320 _scan(r''' 321 _scan(
322 r'''
321 //comment1 323 //comment1
322 //comment2 324 //comment2
323 a''', "", " ", " + b;"); 325 a''',
326 "",
327 " ",
328 " + b;");
324 _assertTokens(1, 2, ["a", "+", "b", ";"]); 329 _assertTokens(1, 2, ["a", "+", "b", ";"]);
325 expect(_incrementalScanner.hasNonWhitespaceChange, isFalse); 330 expect(_incrementalScanner.hasNonWhitespaceChange, isFalse);
326 } 331 }
327 332
328 void test_replace_identifier_beginning() { 333 void test_replace_identifier_beginning() {
329 // "bell + b;" 334 // "bell + b;"
330 // "fell + b;" 335 // "fell + b;"
331 _scan("", "b", "f", "ell + b;"); 336 _scan("", "b", "f", "ell + b;");
332 _assertTokens(-1, 1, ["fell", "+", "b", ";"]); 337 _assertTokens(-1, 1, ["fell", "+", "b", ";"]);
333 expect(_incrementalScanner.hasNonWhitespaceChange, isTrue); 338 expect(_incrementalScanner.hasNonWhitespaceChange, isTrue);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 } 411 }
407 } 412 }
408 413
409 /** 414 /**
410 * Assert that the [expected] token is equal to the [actual] token. 415 * Assert that the [expected] token is equal to the [actual] token.
411 */ 416 */
412 void _assertEqualTokens(Token actual, Token expected) { 417 void _assertEqualTokens(Token actual, Token expected) {
413 expect(actual.type, same(expected.type), reason: "Wrong type for token"); 418 expect(actual.type, same(expected.type), reason: "Wrong type for token");
414 expect(actual.lexeme, expected.lexeme, reason: "Wrong lexeme for token"); 419 expect(actual.lexeme, expected.lexeme, reason: "Wrong lexeme for token");
415 expect(actual.offset, expected.offset, 420 expect(actual.offset, expected.offset,
416 reason: "Wrong offset for token ('${actual.lexeme}' != '${expected.lexem e}')"); 421 reason:
422 "Wrong offset for token ('${actual.lexeme}' != '${expected.lexeme}') ");
417 expect(actual.length, expected.length, 423 expect(actual.length, expected.length,
418 reason: "Wrong length for token ('${actual.lexeme}' != '${expected.lexem e}')"); 424 reason:
425 "Wrong length for token ('${actual.lexeme}' != '${expected.lexeme}') ");
419 } 426 }
420 427
421 /** 428 /**
422 * Assert that the result of the incremental scan matches the given list of 429 * Assert that the result of the incremental scan matches the given list of
423 * [lexemes] and that the left and right tokens correspond to the tokens at 430 * [lexemes] and that the left and right tokens correspond to the tokens at
424 * the [leftIndex] and [rightIndex]. 431 * the [leftIndex] and [rightIndex].
425 */ 432 */
426 void _assertTokens(int leftIndex, int rightIndex, List<String> lexemes) { 433 void _assertTokens(int leftIndex, int rightIndex, List<String> lexemes) {
427 int count = lexemes.length; 434 int count = lexemes.length;
428 expect(leftIndex >= -1 && leftIndex < count, isTrue, 435 expect(leftIndex >= -1 && leftIndex < count, isTrue,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 modifiedTokens.type != TokenType.EOF) { 521 modifiedTokens.type != TokenType.EOF) {
515 _assertEqualTokens(incrementalToken, modifiedTokens); 522 _assertEqualTokens(incrementalToken, modifiedTokens);
516 Token incrementalComment = incrementalToken.precedingComments; 523 Token incrementalComment = incrementalToken.precedingComments;
517 Token modifiedComment = modifiedTokens.precedingComments; 524 Token modifiedComment = modifiedTokens.precedingComments;
518 while (incrementalComment != null && modifiedComment != null) { 525 while (incrementalComment != null && modifiedComment != null) {
519 _assertEqualTokens(incrementalComment, modifiedComment); 526 _assertEqualTokens(incrementalComment, modifiedComment);
520 incrementalComment = incrementalComment.next; 527 incrementalComment = incrementalComment.next;
521 modifiedComment = modifiedComment.next; 528 modifiedComment = modifiedComment.next;
522 } 529 }
523 expect(incrementalComment, isNull, 530 expect(incrementalComment, isNull,
524 reason: "Too many comment tokens preceeding '${incrementalToken.lexeme }'"); 531 reason:
532 "Too many comment tokens preceeding '${incrementalToken.lexeme}'") ;
525 expect(modifiedComment, isNull, 533 expect(modifiedComment, isNull,
526 reason: "Not enough comment tokens preceeding '${incrementalToken.lexe me}'"); 534 reason:
535 "Not enough comment tokens preceeding '${incrementalToken.lexeme}' ");
527 incrementalToken = incrementalToken.next; 536 incrementalToken = incrementalToken.next;
528 modifiedTokens = modifiedTokens.next; 537 modifiedTokens = modifiedTokens.next;
529 } 538 }
530 expect(incrementalToken.type, same(TokenType.EOF), 539 expect(incrementalToken.type, same(TokenType.EOF),
531 reason: "Too many tokens"); 540 reason: "Too many tokens");
532 expect(modifiedTokens.type, same(TokenType.EOF), 541 expect(modifiedTokens.type, same(TokenType.EOF),
533 reason: "Not enough tokens"); 542 reason: "Not enough tokens");
534 // TODO(brianwilkerson) Verify that the errors are correct? 543 // TODO(brianwilkerson) Verify that the errors are correct?
535 } 544 }
536 } 545 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/incremental_resolver_test.dart ('k') | pkg/analyzer/test/generated/java_core_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698