| OLD | NEW |
| 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 analyzer.test.src.summary.summary_test; | 5 library analyzer.test.src.summary.summary_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 */ | 551 */ |
| 552 void checkUnresolvedTypeRef( | 552 void checkUnresolvedTypeRef( |
| 553 UnlinkedTypeRef typeRef, String expectedPrefix, String expectedName) { | 553 UnlinkedTypeRef typeRef, String expectedPrefix, String expectedName) { |
| 554 // When serializing from the element model, unresolved type refs lose their | 554 // When serializing from the element model, unresolved type refs lose their |
| 555 // name. | 555 // name. |
| 556 checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null, | 556 checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null, |
| 557 expectedPrefix: expectedPrefix, | 557 expectedPrefix: expectedPrefix, |
| 558 expectedKind: PrelinkedReferenceKind.unresolved); | 558 expectedKind: PrelinkedReferenceKind.unresolved); |
| 559 } | 559 } |
| 560 | 560 |
| 561 fail_dependencies_export_to_export_unused() { |
| 562 // TODO(paulberry): fix this test. |
| 563 addNamedSource('/a.dart', 'export "b.dart";'); |
| 564 addNamedSource('/b.dart', ''); |
| 565 serializeLibraryText('export "a.dart";'); |
| 566 // The main test library depends on b.dart, even though it doesn't |
| 567 // re-export any names defined in b.dart, because a change to b.dart might |
| 568 // cause it to start exporting a name that the main test library *does* |
| 569 // use. |
| 570 checkHasDependency(absUri('/b.dart'), 'b.dart'); |
| 571 } |
| 572 |
| 573 fail_dependencies_export_unused() { |
| 574 // TODO(paulberry): fix this test. |
| 575 addNamedSource('/a.dart', ''); |
| 576 serializeLibraryText('export "a.dart";'); |
| 577 // The main test library depends on a.dart, even though it doesn't |
| 578 // re-export any names defined in a.dart, because a change to a.dart might |
| 579 // cause it to start exporting a name that the main test library *will* |
| 580 // re-export. |
| 581 checkHasDependency(absUri('/a.dart'), 'a.dart'); |
| 582 } |
| 583 |
| 561 fail_enum_value_documented() { | 584 fail_enum_value_documented() { |
| 562 // TODO(paulberry): currently broken because of dartbug.com/25385 | 585 // TODO(paulberry): currently broken because of dartbug.com/25385 |
| 563 String text = ''' | 586 String text = ''' |
| 564 enum E { | 587 enum E { |
| 565 /** | 588 /** |
| 566 * Docs | 589 * Docs |
| 567 */ | 590 */ |
| 568 v | 591 v |
| 569 }'''; | 592 }'''; |
| 570 UnlinkedEnumValue value = serializeEnumText(text).values[0]; | 593 UnlinkedEnumValue value = serializeEnumText(text).values[0]; |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 addNamedSource('/a.dart', 'library a; export "b.dart"; class A {}'); | 1545 addNamedSource('/a.dart', 'library a; export "b.dart"; class A {}'); |
| 1523 addNamedSource('/b.dart', 'library b; export "c.dart";'); | 1546 addNamedSource('/b.dart', 'library b; export "c.dart";'); |
| 1524 addNamedSource('/c.dart', 'library c;'); | 1547 addNamedSource('/c.dart', 'library c;'); |
| 1525 serializeLibraryText('import "a.dart"; A a;'); | 1548 serializeLibraryText('import "a.dart"; A a;'); |
| 1526 checkHasDependency(absUri('/a.dart'), 'a.dart'); | 1549 checkHasDependency(absUri('/a.dart'), 'a.dart'); |
| 1527 // The main test library depends on c.dart, because names defined in | 1550 // The main test library depends on c.dart, because names defined in |
| 1528 // c.dart are exported by b.dart and then re-exported by a.dart. | 1551 // c.dart are exported by b.dart and then re-exported by a.dart. |
| 1529 checkHasDependency(absUri('/c.dart'), 'c.dart'); | 1552 checkHasDependency(absUri('/c.dart'), 'c.dart'); |
| 1530 } | 1553 } |
| 1531 | 1554 |
| 1555 test_dependencies_import_to_export_unused() { |
| 1556 addNamedSource('/a.dart', 'export "b.dart";'); |
| 1557 addNamedSource('/b.dart', ''); |
| 1558 serializeLibraryText('import "a.dart";', allowErrors: true); |
| 1559 // The main test library depends on b.dart, even though it doesn't use any |
| 1560 // names defined in b.dart, because a change to b.dart might cause it to |
| 1561 // start exporting a name that the main test library *does* use. |
| 1562 checkHasDependency(absUri('/b.dart'), 'b.dart'); |
| 1563 } |
| 1564 |
| 1532 test_dependencies_import_transitive_closure() { | 1565 test_dependencies_import_transitive_closure() { |
| 1533 addNamedSource( | 1566 addNamedSource( |
| 1534 '/a.dart', 'library a; import "b.dart"; class A extends B {}'); | 1567 '/a.dart', 'library a; import "b.dart"; class A extends B {}'); |
| 1535 addNamedSource('/b.dart', 'library b; class B {}'); | 1568 addNamedSource('/b.dart', 'library b; class B {}'); |
| 1536 serializeLibraryText('import "a.dart"; A a;'); | 1569 serializeLibraryText('import "a.dart"; A a;'); |
| 1537 checkHasDependency(absUri('/a.dart'), 'a.dart'); | 1570 checkHasDependency(absUri('/a.dart'), 'a.dart'); |
| 1538 // The main test library doesn't depend on b.dart, because no change to | 1571 // The main test library doesn't depend on b.dart, because no change to |
| 1539 // b.dart can possibly affect the serialized element model for it. | 1572 // b.dart can possibly affect the serialized element model for it. |
| 1540 checkLacksDependency(absUri('/b.dart'), 'b.dart'); | 1573 checkLacksDependency(absUri('/b.dart'), 'b.dart'); |
| 1541 } | 1574 } |
| 1542 | 1575 |
| 1576 test_dependencies_import_unused() { |
| 1577 addNamedSource('/a.dart', ''); |
| 1578 serializeLibraryText('import "a.dart";', allowErrors: true); |
| 1579 // The main test library depends on a.dart, even though it doesn't use any |
| 1580 // names defined in a.dart, because a change to a.dart might cause it to |
| 1581 // start exporting a name that the main test library *does* use. |
| 1582 checkHasDependency(absUri('/a.dart'), 'a.dart'); |
| 1583 } |
| 1584 |
| 1543 test_dependencies_parts() { | 1585 test_dependencies_parts() { |
| 1544 addNamedSource( | 1586 addNamedSource( |
| 1545 '/a.dart', 'library a; part "b.dart"; part "c.dart"; class A {}'); | 1587 '/a.dart', 'library a; part "b.dart"; part "c.dart"; class A {}'); |
| 1546 addNamedSource('/b.dart', 'part of a;'); | 1588 addNamedSource('/b.dart', 'part of a;'); |
| 1547 addNamedSource('/c.dart', 'part of a;'); | 1589 addNamedSource('/c.dart', 'part of a;'); |
| 1548 serializeLibraryText('import "a.dart"; A a;'); | 1590 serializeLibraryText('import "a.dart"; A a;'); |
| 1549 PrelinkedDependency dep = checkHasDependency(absUri('/a.dart'), 'a.dart'); | 1591 PrelinkedDependency dep = checkHasDependency(absUri('/a.dart'), 'a.dart'); |
| 1550 checkDependencyParts( | 1592 checkDependencyParts( |
| 1551 dep, [absUri('/b.dart'), absUri('/c.dart')], ['b.dart', 'c.dart']); | 1593 dep, [absUri('/b.dart'), absUri('/c.dart')], ['b.dart', 'c.dart']); |
| 1552 } | 1594 } |
| (...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2957 UnlinkedVariable variable = | 2999 UnlinkedVariable variable = |
| 2958 serializeVariableText('int i;', variableName: 'i'); | 3000 serializeVariableText('int i;', variableName: 'i'); |
| 2959 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); | 3001 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); |
| 2960 } | 3002 } |
| 2961 | 3003 |
| 2962 test_varible_private() { | 3004 test_varible_private() { |
| 2963 serializeVariableText('int _i;', variableName: '_i'); | 3005 serializeVariableText('int _i;', variableName: '_i'); |
| 2964 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 3006 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 2965 } | 3007 } |
| 2966 } | 3008 } |
| OLD | NEW |