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

Side by Side Diff: pkg/analyzer/test/src/task/incremental_element_builder_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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 test.src.task.incremental_element_builder_test; 5 library test.src.task.incremental_element_builder_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/task/incremental_element_builder.dart'; 10 import 'package:analyzer/src/task/incremental_element_builder.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 '../context/abstract_context.dart'; 15 import '../context/abstract_context.dart';
15 16
16 main() { 17 main() {
17 groupSep = ' | '; 18 initializeTestEnvironment();
18 runReflectiveTests(IncrementalCompilationUnitElementBuilderTest); 19 runReflectiveTests(IncrementalCompilationUnitElementBuilderTest);
19 } 20 }
20 21
21 @reflectiveTest 22 @reflectiveTest
22 class IncrementalCompilationUnitElementBuilderTest extends AbstractContextTest { 23 class IncrementalCompilationUnitElementBuilderTest extends AbstractContextTest {
23 Source source; 24 Source source;
24 25
25 String oldCode; 26 String oldCode;
26 CompilationUnit oldUnit; 27 CompilationUnit oldUnit;
27 CompilationUnitElement unitElement; 28 CompilationUnitElement unitElement;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 expect(unitDelta.hasDirectiveChange, isTrue); 73 expect(unitDelta.hasDirectiveChange, isTrue);
73 } 74 }
74 75
75 test_directives_keepOffset_partOf() { 76 test_directives_keepOffset_partOf() {
76 String libCode = ''' 77 String libCode = '''
77 // comment to shift tokens 78 // comment to shift tokens
78 library my_lib; 79 library my_lib;
79 part 'test.dart'; 80 part 'test.dart';
80 '''; 81 ''';
81 Source libSource = newSource('/lib.dart', libCode); 82 Source libSource = newSource('/lib.dart', libCode);
82 _buildOldUnit(r''' 83 _buildOldUnit(
84 r'''
83 part of my_lib; 85 part of my_lib;
84 class A {} 86 class A {}
85 ''', libSource); 87 ''',
88 libSource);
86 List<Directive> oldDirectives = oldUnit.directives.toList(); 89 List<Directive> oldDirectives = oldUnit.directives.toList();
87 _buildNewUnit(r''' 90 _buildNewUnit(r'''
88 part of my_lib; 91 part of my_lib;
89 class A {} 92 class A {}
90 '''); 93 ''');
91 List<Directive> newDirectives = newUnit.directives; 94 List<Directive> newDirectives = newUnit.directives;
92 { 95 {
93 Directive newNode = newDirectives[0]; 96 Directive newNode = newDirectives[0];
94 expect(newNode, same(oldDirectives[0])); 97 expect(newNode, same(oldDirectives[0]));
95 expect(getNodeText(newNode), 'part of my_lib;'); 98 expect(getNodeText(newNode), 'part of my_lib;');
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 class C {} 326 class C {}
324 /// reference [bool] type. 327 /// reference [bool] type.
325 class A {} 328 class A {}
326 /// reference [int] type. 329 /// reference [int] type.
327 class B {} 330 class B {}
328 '''); 331 ''');
329 List<CompilationUnitMember> newNodes = newUnit.declarations; 332 List<CompilationUnitMember> newNodes = newUnit.declarations;
330 { 333 {
331 CompilationUnitMember newNode = newNodes[0]; 334 CompilationUnitMember newNode = newNodes[0];
332 expect(newNode, same(oldNodes[2])); 335 expect(newNode, same(oldNodes[2]));
333 expect(getNodeText(newNode), r''' 336 expect(
337 getNodeText(newNode),
338 r'''
334 /// reference [double] and [B] types. 339 /// reference [double] and [B] types.
335 class C {}'''); 340 class C {}''');
336 ClassElement element = newNode.element; 341 ClassElement element = newNode.element;
337 expect(element, isNotNull); 342 expect(element, isNotNull);
338 expect(element.name, 'C'); 343 expect(element.name, 'C');
339 expect(element.nameOffset, newCode.indexOf('C {}')); 344 expect(element.nameOffset, newCode.indexOf('C {}'));
340 // [double] and [B] are still resolved 345 // [double] and [B] are still resolved
341 { 346 {
342 var docReferences = newNode.documentationComment.references; 347 var docReferences = newNode.documentationComment.references;
343 expect(docReferences, hasLength(2)); 348 expect(docReferences, hasLength(2));
344 expect(docReferences[0].identifier.staticElement.name, 'double'); 349 expect(docReferences[0].identifier.staticElement.name, 'double');
345 expect(docReferences[1].identifier.staticElement, 350 expect(docReferences[1].identifier.staticElement,
346 same(newNodes[2].element)); 351 same(newNodes[2].element));
347 } 352 }
348 } 353 }
349 { 354 {
350 CompilationUnitMember newNode = newNodes[1]; 355 CompilationUnitMember newNode = newNodes[1];
351 expect(newNode, same(oldNodes[0])); 356 expect(newNode, same(oldNodes[0]));
352 expect(getNodeText(newNode), r''' 357 expect(
358 getNodeText(newNode),
359 r'''
353 /// reference [bool] type. 360 /// reference [bool] type.
354 class A {}'''); 361 class A {}''');
355 ClassElement element = newNode.element; 362 ClassElement element = newNode.element;
356 expect(element, isNotNull); 363 expect(element, isNotNull);
357 expect(element.name, 'A'); 364 expect(element.name, 'A');
358 expect(element.nameOffset, newCode.indexOf('A {}')); 365 expect(element.nameOffset, newCode.indexOf('A {}'));
359 // [bool] is still resolved 366 // [bool] is still resolved
360 { 367 {
361 var docReferences = newNode.documentationComment.references; 368 var docReferences = newNode.documentationComment.references;
362 expect(docReferences, hasLength(1)); 369 expect(docReferences, hasLength(1));
363 expect(docReferences[0].identifier.staticElement.name, 'bool'); 370 expect(docReferences[0].identifier.staticElement.name, 'bool');
364 } 371 }
365 } 372 }
366 { 373 {
367 CompilationUnitMember newNode = newNodes[2]; 374 CompilationUnitMember newNode = newNodes[2];
368 expect(newNode, same(oldNodes[1])); 375 expect(newNode, same(oldNodes[1]));
369 expect(getNodeText(newNode), r''' 376 expect(
377 getNodeText(newNode),
378 r'''
370 /// reference [int] type. 379 /// reference [int] type.
371 class B {}'''); 380 class B {}''');
372 ClassElement element = newNode.element; 381 ClassElement element = newNode.element;
373 expect(element, isNotNull); 382 expect(element, isNotNull);
374 expect(element.name, 'B'); 383 expect(element.name, 'B');
375 expect(element.nameOffset, newCode.indexOf('B {}')); 384 expect(element.nameOffset, newCode.indexOf('B {}'));
376 // [int] is still resolved 385 // [int] is still resolved
377 { 386 {
378 var docReferences = newNode.documentationComment.references; 387 var docReferences = newNode.documentationComment.references;
379 expect(docReferences, hasLength(1)); 388 expect(docReferences, hasLength(1));
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 expect(elementB, isNotNull); 623 expect(elementB, isNotNull);
615 expect(elementC, isNotNull); 624 expect(elementC, isNotNull);
616 expect(elementD, isNotNull); 625 expect(elementD, isNotNull);
617 expect(elementA.name, 'a'); 626 expect(elementA.name, 'a');
618 expect(elementB.name, 'b'); 627 expect(elementB.name, 'b');
619 expect(elementC.name, 'c'); 628 expect(elementC.name, 'c');
620 expect(elementD.name, 'd'); 629 expect(elementD.name, 'd');
621 // unit.types 630 // unit.types
622 expect(unitElement.topLevelVariables, 631 expect(unitElement.topLevelVariables,
623 unorderedEquals([elementA, elementB, elementC, elementD])); 632 unorderedEquals([elementA, elementB, elementC, elementD]));
624 expect(unitElement.accessors, unorderedEquals([ 633 expect(
625 elementA.getter, 634 unitElement.accessors,
626 elementA.setter, 635 unorderedEquals([
627 elementB.getter, 636 elementA.getter,
628 elementB.setter, 637 elementA.setter,
629 elementC.getter, 638 elementB.getter,
630 elementC.setter, 639 elementB.setter,
631 elementD.getter, 640 elementC.getter,
632 elementD.setter 641 elementC.setter,
633 ])); 642 elementD.getter,
643 elementD.setter
644 ]));
634 } 645 }
635 646
636 test_unitMembers_topLevelVariable_final() { 647 test_unitMembers_topLevelVariable_final() {
637 _buildOldUnit(r''' 648 _buildOldUnit(r'''
638 final int a = 1; 649 final int a = 1;
639 '''); 650 ''');
640 List<CompilationUnitMember> oldNodes = oldUnit.declarations.toList(); 651 List<CompilationUnitMember> oldNodes = oldUnit.declarations.toList();
641 _buildNewUnit(r''' 652 _buildNewUnit(r'''
642 final int a = 1; 653 final int a = 1;
643 '''); 654 ''');
(...skipping 30 matching lines...) Expand all
674 this.oldCode = oldCode; 685 this.oldCode = oldCode;
675 source = newSource('/test.dart', oldCode); 686 source = newSource('/test.dart', oldCode);
676 if (libSource == null) { 687 if (libSource == null) {
677 libSource = source; 688 libSource = source;
678 } 689 }
679 oldUnit = context.resolveCompilationUnit2(source, libSource); 690 oldUnit = context.resolveCompilationUnit2(source, libSource);
680 unitElement = oldUnit.element; 691 unitElement = oldUnit.element;
681 expect(unitElement, isNotNull); 692 expect(unitElement, isNotNull);
682 } 693 }
683 } 694 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/html_work_manager_test.dart ('k') | pkg/analyzer/test/src/task/inputs_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698