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

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

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.generated.hint_code_test; 5 library analyzer.test.generated.hint_code_test;
6 6
7 import 'package:analyzer/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/src/error/codes.dart'; 8 import 'package:analyzer/src/error/codes.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/parser.dart'; 10 import 'package:analyzer/src/generated/parser.dart';
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 m() {} 768 m() {}
769 n() {m();} 769 n() {m();}
770 }'''); 770 }''');
771 await computeAnalysisResult(source); 771 await computeAnalysisResult(source);
772 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); 772 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
773 verify([source]); 773 verify([source]);
774 } 774 }
775 775
776 test_deprecatedAnnotationUse_export() async { 776 test_deprecatedAnnotationUse_export() async {
777 Source source = addSource("export 'deprecated_library.dart';"); 777 Source source = addSource("export 'deprecated_library.dart';");
778 addNamedSource( 778 addNamedSource("/deprecated_library.dart", r'''
779 "/deprecated_library.dart",
780 r'''
781 @deprecated 779 @deprecated
782 library deprecated_library; 780 library deprecated_library;
783 class A {}'''); 781 class A {}''');
784 await computeAnalysisResult(source); 782 await computeAnalysisResult(source);
785 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); 783 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
786 verify([source]); 784 verify([source]);
787 } 785 }
788 786
789 test_deprecatedAnnotationUse_field() async { 787 test_deprecatedAnnotationUse_field() async {
790 Source source = addSource(r''' 788 Source source = addSource(r'''
(...skipping 20 matching lines...) Expand all
811 }'''); 809 }''');
812 await computeAnalysisResult(source); 810 await computeAnalysisResult(source);
813 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); 811 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
814 verify([source]); 812 verify([source]);
815 } 813 }
816 814
817 test_deprecatedAnnotationUse_import() async { 815 test_deprecatedAnnotationUse_import() async {
818 Source source = addSource(r''' 816 Source source = addSource(r'''
819 import 'deprecated_library.dart'; 817 import 'deprecated_library.dart';
820 f(A a) {}'''); 818 f(A a) {}''');
821 addNamedSource( 819 addNamedSource("/deprecated_library.dart", r'''
822 "/deprecated_library.dart",
823 r'''
824 @deprecated 820 @deprecated
825 library deprecated_library; 821 library deprecated_library;
826 class A {}'''); 822 class A {}''');
827 await computeAnalysisResult(source); 823 await computeAnalysisResult(source);
828 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); 824 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]);
829 verify([source]); 825 verify([source]);
830 } 826 }
831 827
832 test_deprecatedAnnotationUse_indexExpression() async { 828 test_deprecatedAnnotationUse_indexExpression() async {
833 Source source = addSource(r''' 829 Source source = addSource(r'''
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]); 1047 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]);
1052 verify([source]); 1048 verify([source]);
1053 } 1049 }
1054 1050
1055 test_duplicateImport() async { 1051 test_duplicateImport() async {
1056 Source source = addSource(r''' 1052 Source source = addSource(r'''
1057 library L; 1053 library L;
1058 import 'lib1.dart'; 1054 import 'lib1.dart';
1059 import 'lib1.dart'; 1055 import 'lib1.dart';
1060 A a;'''); 1056 A a;''');
1061 addNamedSource( 1057 addNamedSource("/lib1.dart", r'''
1062 "/lib1.dart",
1063 r'''
1064 library lib1; 1058 library lib1;
1065 class A {}'''); 1059 class A {}''');
1066 await computeAnalysisResult(source); 1060 await computeAnalysisResult(source);
1067 assertErrors(source, [HintCode.DUPLICATE_IMPORT]); 1061 assertErrors(source, [HintCode.DUPLICATE_IMPORT]);
1068 verify([source]); 1062 verify([source]);
1069 } 1063 }
1070 1064
1071 test_duplicateImport2() async { 1065 test_duplicateImport2() async {
1072 Source source = addSource(r''' 1066 Source source = addSource(r'''
1073 library L; 1067 library L;
1074 import 'lib1.dart'; 1068 import 'lib1.dart';
1075 import 'lib1.dart'; 1069 import 'lib1.dart';
1076 import 'lib1.dart'; 1070 import 'lib1.dart';
1077 A a;'''); 1071 A a;''');
1078 addNamedSource( 1072 addNamedSource("/lib1.dart", r'''
1079 "/lib1.dart",
1080 r'''
1081 library lib1; 1073 library lib1;
1082 class A {}'''); 1074 class A {}''');
1083 await computeAnalysisResult(source); 1075 await computeAnalysisResult(source);
1084 assertErrors( 1076 assertErrors(
1085 source, [HintCode.DUPLICATE_IMPORT, HintCode.DUPLICATE_IMPORT]); 1077 source, [HintCode.DUPLICATE_IMPORT, HintCode.DUPLICATE_IMPORT]);
1086 verify([source]); 1078 verify([source]);
1087 } 1079 }
1088 1080
1089 test_duplicateImport3() async { 1081 test_duplicateImport3() async {
1090 Source source = addSource(r''' 1082 Source source = addSource(r'''
1091 library L; 1083 library L;
1092 import 'lib1.dart' as M show A hide B; 1084 import 'lib1.dart' as M show A hide B;
1093 import 'lib1.dart' as M show A hide B; 1085 import 'lib1.dart' as M show A hide B;
1094 M.A a;'''); 1086 M.A a;''');
1095 addNamedSource( 1087 addNamedSource("/lib1.dart", r'''
1096 "/lib1.dart",
1097 r'''
1098 library lib1; 1088 library lib1;
1099 class A {} 1089 class A {}
1100 class B {}'''); 1090 class B {}''');
1101 await computeAnalysisResult(source); 1091 await computeAnalysisResult(source);
1102 assertErrors(source, [HintCode.DUPLICATE_IMPORT]); 1092 assertErrors(source, [HintCode.DUPLICATE_IMPORT]);
1103 verify([source]); 1093 verify([source]);
1104 } 1094 }
1105 1095
1106 test_factory__expr_return_null_OK() async { 1096 test_factory__expr_return_null_OK() async {
1107 Source source = addSource(r''' 1097 Source source = addSource(r'''
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 @immutable 1365 @immutable
1376 void m() {} 1366 void m() {}
1377 } 1367 }
1378 '''); 1368 ''');
1379 await computeAnalysisResult(source); 1369 await computeAnalysisResult(source);
1380 assertErrors(source, [HintCode.INVALID_IMMUTABLE_ANNOTATION]); 1370 assertErrors(source, [HintCode.INVALID_IMMUTABLE_ANNOTATION]);
1381 verify([source]); 1371 verify([source]);
1382 } 1372 }
1383 1373
1384 test_invalidRequiredParam_on_named_parameter_with_default() async { 1374 test_invalidRequiredParam_on_named_parameter_with_default() async {
1385 Source source = addNamedSource( 1375 Source source = addNamedSource('/lib1.dart', r'''
1386 '/lib1.dart',
1387 r'''
1388 import 'package:meta/meta.dart'; 1376 import 'package:meta/meta.dart';
1389 1377
1390 m({@required a = 1}) => null; 1378 m({@required a = 1}) => null;
1391 '''); 1379 ''');
1392 await computeAnalysisResult(source); 1380 await computeAnalysisResult(source);
1393 assertErrors(source, [HintCode.INVALID_REQUIRED_PARAM]); 1381 assertErrors(source, [HintCode.INVALID_REQUIRED_PARAM]);
1394 verify([source]); 1382 verify([source]);
1395 } 1383 }
1396 1384
1397 test_invalidRequiredParam_on_positional_parameter() async { 1385 test_invalidRequiredParam_on_positional_parameter() async {
1398 Source source = addNamedSource( 1386 Source source = addNamedSource('/lib1.dart', r'''
1399 '/lib1.dart',
1400 r'''
1401 import 'package:meta/meta.dart'; 1387 import 'package:meta/meta.dart';
1402 1388
1403 m([@required a]) => null; 1389 m([@required a]) => null;
1404 '''); 1390 ''');
1405 await computeAnalysisResult(source); 1391 await computeAnalysisResult(source);
1406 assertErrors(source, [HintCode.INVALID_REQUIRED_PARAM]); 1392 assertErrors(source, [HintCode.INVALID_REQUIRED_PARAM]);
1407 verify([source]); 1393 verify([source]);
1408 } 1394 }
1409 1395
1410 test_invalidRequiredParam_on_positional_parameter_with_default() async { 1396 test_invalidRequiredParam_on_positional_parameter_with_default() async {
1411 Source source = addNamedSource( 1397 Source source = addNamedSource('/lib1.dart', r'''
1412 '/lib1.dart',
1413 r'''
1414 import 'package:meta/meta.dart'; 1398 import 'package:meta/meta.dart';
1415 1399
1416 m([@required a = 1]) => null; 1400 m([@required a = 1]) => null;
1417 '''); 1401 ''');
1418 await computeAnalysisResult(source); 1402 await computeAnalysisResult(source);
1419 assertErrors(source, [HintCode.INVALID_REQUIRED_PARAM]); 1403 assertErrors(source, [HintCode.INVALID_REQUIRED_PARAM]);
1420 verify([source]); 1404 verify([source]);
1421 } 1405 }
1422 1406
1423 test_invalidRequiredParam_on_required_parameter() async { 1407 test_invalidRequiredParam_on_required_parameter() async {
1424 Source source = addNamedSource( 1408 Source source = addNamedSource('/lib1.dart', r'''
1425 '/lib1.dart',
1426 r'''
1427 import 'package:meta/meta.dart'; 1409 import 'package:meta/meta.dart';
1428 1410
1429 m(@required a) => null; 1411 m(@required a) => null;
1430 '''); 1412 ''');
1431 await computeAnalysisResult(source); 1413 await computeAnalysisResult(source);
1432 assertErrors(source, [HintCode.INVALID_REQUIRED_PARAM]); 1414 assertErrors(source, [HintCode.INVALID_REQUIRED_PARAM]);
1433 verify([source]); 1415 verify([source]);
1434 } 1416 }
1435 1417
1436 test_invalidRequiredParam_valid() async { 1418 test_invalidRequiredParam_valid() async {
1437 Source source = addNamedSource( 1419 Source source = addNamedSource('/lib1.dart', r'''
1438 '/lib1.dart',
1439 r'''
1440 import 'package:meta/meta.dart'; 1420 import 'package:meta/meta.dart';
1441 1421
1442 m1() => null; 1422 m1() => null;
1443 m2(a) => null; 1423 m2(a) => null;
1444 m3([a]) => null; 1424 m3([a]) => null;
1445 m4({a}) => null; 1425 m4({a}) => null;
1446 m5({@required a}) => null; 1426 m5({@required a}) => null;
1447 m6({a, @required b}) => null; 1427 m6({a, @required b}) => null;
1448 '''); 1428 ''');
1449 await computeAnalysisResult(source); 1429 await computeAnalysisResult(source);
1450 assertNoErrors(source); 1430 assertNoErrors(source);
1451 verify([source]); 1431 verify([source]);
1452 } 1432 }
1453 1433
1454 test_invalidUseOfProtectedMember_closure() async { 1434 test_invalidUseOfProtectedMember_closure() async {
1455 Source source = addNamedSource( 1435 Source source = addNamedSource('/lib1.dart', r'''
1456 '/lib1.dart',
1457 r'''
1458 import 'package:meta/meta.dart'; 1436 import 'package:meta/meta.dart';
1459 1437
1460 class A { 1438 class A {
1461 @protected 1439 @protected
1462 int a() => 42; 1440 int a() => 42;
1463 } 1441 }
1464 '''); 1442 ''');
1465 Source source2 = addNamedSource( 1443 Source source2 = addNamedSource('/lib2.dart', r'''
1466 '/lib2.dart',
1467 r'''
1468 import 'lib1.dart'; 1444 import 'lib1.dart';
1469 1445
1470 void main() { 1446 void main() {
1471 var leak = new A().a; 1447 var leak = new A().a;
1472 print(leak); 1448 print(leak);
1473 } 1449 }
1474 '''); 1450 ''');
1475 await computeAnalysisResult(source); 1451 await computeAnalysisResult(source);
1476 await computeAnalysisResult(source2); 1452 await computeAnalysisResult(source2);
1477 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]); 1453 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
1478 assertNoErrors(source); 1454 assertNoErrors(source);
1479 verify([source, source2]); 1455 verify([source, source2]);
1480 } 1456 }
1481 1457
1482 test_invalidUseOfProtectedMember_field() async { 1458 test_invalidUseOfProtectedMember_field() async {
1483 Source source = addNamedSource( 1459 Source source = addNamedSource('/lib1.dart', r'''
1484 '/lib1.dart',
1485 r'''
1486 import 'package:meta/meta.dart'; 1460 import 'package:meta/meta.dart';
1487 class A { 1461 class A {
1488 @protected 1462 @protected
1489 int a; 1463 int a;
1490 } 1464 }
1491 '''); 1465 ''');
1492 Source source2 = addNamedSource( 1466 Source source2 = addNamedSource('/lib2.dart', r'''
1493 '/lib2.dart',
1494 r'''
1495 import 'lib1.dart'; 1467 import 'lib1.dart';
1496 1468
1497 abstract class B { 1469 abstract class B {
1498 int b() => new A().a; 1470 int b() => new A().a;
1499 } 1471 }
1500 '''); 1472 ''');
1501 await computeAnalysisResult(source); 1473 await computeAnalysisResult(source);
1502 await computeAnalysisResult(source2); 1474 await computeAnalysisResult(source2);
1503 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]); 1475 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
1504 assertNoErrors(source); 1476 assertNoErrors(source);
1505 verify([source, source2]); 1477 verify([source, source2]);
1506 } 1478 }
1507 1479
1508 test_invalidUseOfProtectedMember_field_OK() async { 1480 test_invalidUseOfProtectedMember_field_OK() async {
1509 Source source = addSource(r''' 1481 Source source = addSource(r'''
1510 import 'package:meta/meta.dart'; 1482 import 'package:meta/meta.dart';
1511 class A { 1483 class A {
1512 @protected 1484 @protected
1513 int a; 1485 int a;
1514 } 1486 }
1515 abstract class B implements A { 1487 abstract class B implements A {
1516 int b() => a; 1488 int b() => a;
1517 }'''); 1489 }''');
1518 await computeAnalysisResult(source); 1490 await computeAnalysisResult(source);
1519 assertNoErrors(source); 1491 assertNoErrors(source);
1520 verify([source]); 1492 verify([source]);
1521 } 1493 }
1522 1494
1523 test_invalidUseOfProtectedMember_function() async { 1495 test_invalidUseOfProtectedMember_function() async {
1524 Source source = addNamedSource( 1496 Source source = addNamedSource('/lib1.dart', r'''
1525 '/lib1.dart',
1526 r'''
1527 import 'package:meta/meta.dart'; 1497 import 'package:meta/meta.dart';
1528 class A { 1498 class A {
1529 @protected 1499 @protected
1530 void a(){ } 1500 void a(){ }
1531 } 1501 }
1532 '''); 1502 ''');
1533 Source source2 = addNamedSource( 1503 Source source2 = addNamedSource('/lib2.dart', r'''
1534 '/lib2.dart',
1535 r'''
1536 import 'lib1.dart'; 1504 import 'lib1.dart';
1537 1505
1538 main() { 1506 main() {
1539 new A().a(); 1507 new A().a();
1540 } 1508 }
1541 '''); 1509 ''');
1542 await computeAnalysisResult(source); 1510 await computeAnalysisResult(source);
1543 await computeAnalysisResult(source2); 1511 await computeAnalysisResult(source2);
1544 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]); 1512 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
1545 assertNoErrors(source); 1513 assertNoErrors(source);
(...skipping 25 matching lines...) Expand all
1571 } 1539 }
1572 main() { 1540 main() {
1573 new A().a(); 1541 new A().a();
1574 }'''); 1542 }''');
1575 await computeAnalysisResult(source); 1543 await computeAnalysisResult(source);
1576 assertNoErrors(source); 1544 assertNoErrors(source);
1577 verify([source]); 1545 verify([source]);
1578 } 1546 }
1579 1547
1580 test_invalidUseOfProtectedMember_getter() async { 1548 test_invalidUseOfProtectedMember_getter() async {
1581 Source source = addNamedSource( 1549 Source source = addNamedSource('/lib1.dart', r'''
1582 '/lib1.dart',
1583 r'''
1584 import 'package:meta/meta.dart'; 1550 import 'package:meta/meta.dart';
1585 class A { 1551 class A {
1586 @protected 1552 @protected
1587 int get a => 42; 1553 int get a => 42;
1588 } 1554 }
1589 '''); 1555 ''');
1590 Source source2 = addNamedSource( 1556 Source source2 = addNamedSource('/lib2.dart', r'''
1591 '/lib2.dart',
1592 r'''
1593 import 'lib1.dart'; 1557 import 'lib1.dart';
1594 1558
1595 class B { 1559 class B {
1596 A a; 1560 A a;
1597 int b() => a.a; 1561 int b() => a.a;
1598 } 1562 }
1599 '''); 1563 ''');
1600 await computeAnalysisResult(source); 1564 await computeAnalysisResult(source);
1601 await computeAnalysisResult(source2); 1565 await computeAnalysisResult(source2);
1602 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]); 1566 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 1598
1635 /// OK: [A.a], [A.b], [A.c]. 1599 /// OK: [A.a], [A.b], [A.c].
1636 f() {} 1600 f() {}
1637 '''); 1601 ''');
1638 await computeAnalysisResult(source); 1602 await computeAnalysisResult(source);
1639 assertNoErrors(source); 1603 assertNoErrors(source);
1640 verify([source]); 1604 verify([source]);
1641 } 1605 }
1642 1606
1643 test_invalidUseOfProtectedMember_message() async { 1607 test_invalidUseOfProtectedMember_message() async {
1644 Source source = addNamedSource( 1608 Source source = addNamedSource('/lib1.dart', r'''
1645 '/lib1.dart',
1646 r'''
1647 import 'package:meta/meta.dart'; 1609 import 'package:meta/meta.dart';
1648 class A { 1610 class A {
1649 @protected 1611 @protected
1650 void a(){ } 1612 void a(){ }
1651 } 1613 }
1652 '''); 1614 ''');
1653 Source source2 = addNamedSource( 1615 Source source2 = addNamedSource('/lib2.dart', r'''
1654 '/lib2.dart',
1655 r'''
1656 import 'lib1.dart'; 1616 import 'lib1.dart';
1657 1617
1658 class B { 1618 class B {
1659 void b() => new A().a(); 1619 void b() => new A().a();
1660 } 1620 }
1661 '''); 1621 ''');
1662 await computeAnalysisResult(source); 1622 await computeAnalysisResult(source);
1663 await computeAnalysisResult(source2); 1623 await computeAnalysisResult(source2);
1664 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]); 1624 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
1665 verify([source, source2]); 1625 verify([source, source2]);
1666 } 1626 }
1667 1627
1668 test_invalidUseOfProtectedMember_method_1() async { 1628 test_invalidUseOfProtectedMember_method_1() async {
1669 Source source = addNamedSource( 1629 Source source = addNamedSource('/lib1.dart', r'''
1670 '/lib1.dart',
1671 r'''
1672 import 'package:meta/meta.dart'; 1630 import 'package:meta/meta.dart';
1673 class A { 1631 class A {
1674 @protected 1632 @protected
1675 void a(){ } 1633 void a(){ }
1676 } 1634 }
1677 '''); 1635 ''');
1678 Source source2 = addNamedSource( 1636 Source source2 = addNamedSource('/lib2.dart', r'''
1679 '/lib2.dart',
1680 r'''
1681 import 'lib1.dart'; 1637 import 'lib1.dart';
1682 1638
1683 class B { 1639 class B {
1684 void b() => new A().a(); 1640 void b() => new A().a();
1685 } 1641 }
1686 '''); 1642 ''');
1687 1643
1688 await computeAnalysisResult(source); 1644 await computeAnalysisResult(source);
1689 await computeAnalysisResult(source2); 1645 await computeAnalysisResult(source2);
1690 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]); 1646 assertErrors(source2, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 this.a = a; 1794 this.a = a;
1839 } 1795 }
1840 } 1796 }
1841 '''); 1797 ''');
1842 await computeAnalysisResult(source); 1798 await computeAnalysisResult(source);
1843 assertNoErrors(source); 1799 assertNoErrors(source);
1844 verify([source]); 1800 verify([source]);
1845 } 1801 }
1846 1802
1847 test_invalidUseOfProtectedMember_setter() async { 1803 test_invalidUseOfProtectedMember_setter() async {
1848 Source source = addNamedSource( 1804 Source source = addNamedSource('/lib1.dart', r'''
1849 '/lib1.dart',
1850 r'''
1851 import 'package:meta/meta.dart'; 1805 import 'package:meta/meta.dart';
1852 class A { 1806 class A {
1853 @protected 1807 @protected
1854 void set a(int i) { } 1808 void set a(int i) { }
1855 } 1809 }
1856 '''); 1810 ''');
1857 Source source2 = addNamedSource( 1811 Source source2 = addNamedSource('/lib2.dart', r'''
1858 '/lib2.dart',
1859 r'''
1860 import 'lib1.dart'; 1812 import 'lib1.dart';
1861 1813
1862 class B{ 1814 class B{
1863 A a; 1815 A a;
1864 b(int i) { 1816 b(int i) {
1865 a.a = i; 1817 a.a = i;
1866 } 1818 }
1867 } 1819 }
1868 '''); 1820 ''');
1869 await computeAnalysisResult(source); 1821 await computeAnalysisResult(source);
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 f() { 2488 f() {
2537 new A().m(); 2489 new A().m();
2538 } 2490 }
2539 '''); 2491 ''');
2540 await computeAnalysisResult(source); 2492 await computeAnalysisResult(source);
2541 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]); 2493 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]);
2542 verify([source]); 2494 verify([source]);
2543 } 2495 }
2544 2496
2545 test_required_method_param_in_other_lib() async { 2497 test_required_method_param_in_other_lib() async {
2546 addNamedSource( 2498 addNamedSource('/a_lib.dart', r'''
2547 '/a_lib.dart',
2548 r'''
2549 library a_lib; 2499 library a_lib;
2550 import 'package:meta/meta.dart'; 2500 import 'package:meta/meta.dart';
2551 class A { 2501 class A {
2552 void m({@Required('must specify an `a`') int a}) {} 2502 void m({@Required('must specify an `a`') int a}) {}
2553 } 2503 }
2554 '''); 2504 ''');
2555 2505
2556 Source source = addSource(r''' 2506 Source source = addSource(r'''
2557 import "a_lib.dart"; 2507 import "a_lib.dart";
2558 f() { 2508 f() {
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
3885 assertNoErrors(source2); 3835 assertNoErrors(source2);
3886 verify([source, source2]); 3836 verify([source, source2]);
3887 } 3837 }
3888 3838
3889 test_unusedImport_as() async { 3839 test_unusedImport_as() async {
3890 Source source = addSource(r''' 3840 Source source = addSource(r'''
3891 library L; 3841 library L;
3892 import 'lib1.dart'; 3842 import 'lib1.dart';
3893 import 'lib1.dart' as one; 3843 import 'lib1.dart' as one;
3894 one.A a;'''); 3844 one.A a;''');
3895 Source source2 = addNamedSource( 3845 Source source2 = addNamedSource("/lib1.dart", r'''
3896 "/lib1.dart",
3897 r'''
3898 library lib1; 3846 library lib1;
3899 class A {}'''); 3847 class A {}''');
3900 await computeAnalysisResult(source); 3848 await computeAnalysisResult(source);
3901 await computeAnalysisResult(source2); 3849 await computeAnalysisResult(source2);
3902 assertErrors(source, [HintCode.UNUSED_IMPORT]); 3850 assertErrors(source, [HintCode.UNUSED_IMPORT]);
3903 assertNoErrors(source2); 3851 assertNoErrors(source2);
3904 verify([source, source2]); 3852 verify([source, source2]);
3905 } 3853 }
3906 3854
3907 @failingTest 3855 @failingTest
3908 test_unusedImport_as_equalPrefixes() async { 3856 test_unusedImport_as_equalPrefixes() async {
3909 // See todo at ImportsVerifier.prefixElementMap. 3857 // See todo at ImportsVerifier.prefixElementMap.
3910 Source source = addSource(r''' 3858 Source source = addSource(r'''
3911 library L; 3859 library L;
3912 import 'lib1.dart' as one; 3860 import 'lib1.dart' as one;
3913 import 'lib2.dart' as one; 3861 import 'lib2.dart' as one;
3914 one.A a;'''); 3862 one.A a;''');
3915 Source source2 = addNamedSource( 3863 Source source2 = addNamedSource("/lib1.dart", r'''
3916 "/lib1.dart",
3917 r'''
3918 library lib1; 3864 library lib1;
3919 class A {}'''); 3865 class A {}''');
3920 Source source3 = addNamedSource( 3866 Source source3 = addNamedSource("/lib2.dart", r'''
3921 "/lib2.dart",
3922 r'''
3923 library lib2; 3867 library lib2;
3924 class B {}'''); 3868 class B {}''');
3925 await computeAnalysisResult(source); 3869 await computeAnalysisResult(source);
3926 await computeAnalysisResult(source2); 3870 await computeAnalysisResult(source2);
3927 await computeAnalysisResult(source3); 3871 await computeAnalysisResult(source3);
3928 assertErrors(source, [HintCode.UNUSED_IMPORT]); 3872 assertErrors(source, [HintCode.UNUSED_IMPORT]);
3929 assertNoErrors(source2); 3873 assertNoErrors(source2);
3930 assertNoErrors(source3); 3874 assertNoErrors(source3);
3931 verify([source, source2, source3]); 3875 verify([source, source2, source3]);
3932 } 3876 }
3933 3877
3934 test_unusedImport_hide() async { 3878 test_unusedImport_hide() async {
3935 Source source = addSource(r''' 3879 Source source = addSource(r'''
3936 library L; 3880 library L;
3937 import 'lib1.dart'; 3881 import 'lib1.dart';
3938 import 'lib1.dart' hide A; 3882 import 'lib1.dart' hide A;
3939 A a;'''); 3883 A a;''');
3940 Source source2 = addNamedSource( 3884 Source source2 = addNamedSource("/lib1.dart", r'''
3941 "/lib1.dart",
3942 r'''
3943 library lib1; 3885 library lib1;
3944 class A {}'''); 3886 class A {}''');
3945 await computeAnalysisResult(source); 3887 await computeAnalysisResult(source);
3946 await computeAnalysisResult(source2); 3888 await computeAnalysisResult(source2);
3947 assertErrors(source, [HintCode.UNUSED_IMPORT]); 3889 assertErrors(source, [HintCode.UNUSED_IMPORT]);
3948 assertNoErrors(source2); 3890 assertNoErrors(source2);
3949 verify([source, source2]); 3891 verify([source, source2]);
3950 } 3892 }
3951 3893
3952 test_unusedImport_inComment_libraryDirective() async { 3894 test_unusedImport_inComment_libraryDirective() async {
3953 Source source = addSource(r''' 3895 Source source = addSource(r'''
3954 /// Use [Future] class. 3896 /// Use [Future] class.
3955 library L; 3897 library L;
3956 import 'dart:async'; 3898 import 'dart:async';
3957 '''); 3899 ''');
3958 await computeAnalysisResult(source); 3900 await computeAnalysisResult(source);
3959 assertNoErrors(source); 3901 assertNoErrors(source);
3960 } 3902 }
3961 3903
3962 test_unusedImport_show() async { 3904 test_unusedImport_show() async {
3963 Source source = addSource(r''' 3905 Source source = addSource(r'''
3964 library L; 3906 library L;
3965 import 'lib1.dart' show A; 3907 import 'lib1.dart' show A;
3966 import 'lib1.dart' show B; 3908 import 'lib1.dart' show B;
3967 A a;'''); 3909 A a;''');
3968 Source source2 = addNamedSource( 3910 Source source2 = addNamedSource("/lib1.dart", r'''
3969 "/lib1.dart",
3970 r'''
3971 library lib1; 3911 library lib1;
3972 class A {} 3912 class A {}
3973 class B {}'''); 3913 class B {}''');
3974 await computeAnalysisResult(source); 3914 await computeAnalysisResult(source);
3975 await computeAnalysisResult(source2); 3915 await computeAnalysisResult(source2);
3976 assertErrors(source, [HintCode.UNUSED_IMPORT]); 3916 assertErrors(source, [HintCode.UNUSED_IMPORT]);
3977 assertNoErrors(source2); 3917 assertNoErrors(source2);
3978 verify([source, source2]); 3918 verify([source, source2]);
3979 } 3919 }
3980 3920
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
4178 await computeAnalysisResult(source); 4118 await computeAnalysisResult(source);
4179 assertErrors(source); 4119 assertErrors(source);
4180 verify([source]); 4120 verify([source]);
4181 } 4121 }
4182 4122
4183 test_unusedShownName() async { 4123 test_unusedShownName() async {
4184 Source source = addSource(r''' 4124 Source source = addSource(r'''
4185 library L; 4125 library L;
4186 import 'lib1.dart' show A, B; 4126 import 'lib1.dart' show A, B;
4187 A a;'''); 4127 A a;''');
4188 Source source2 = addNamedSource( 4128 Source source2 = addNamedSource("/lib1.dart", r'''
4189 "/lib1.dart",
4190 r'''
4191 library lib1; 4129 library lib1;
4192 class A {} 4130 class A {}
4193 class B {}'''); 4131 class B {}''');
4194 await computeAnalysisResult(source); 4132 await computeAnalysisResult(source);
4195 await computeAnalysisResult(source2); 4133 await computeAnalysisResult(source2);
4196 assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]); 4134 assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
4197 assertNoErrors(source2); 4135 assertNoErrors(source2);
4198 verify([source, source2]); 4136 verify([source, source2]);
4199 } 4137 }
4200 4138
4201 test_unusedShownName_as() async { 4139 test_unusedShownName_as() async {
4202 Source source = addSource(r''' 4140 Source source = addSource(r'''
4203 library L; 4141 library L;
4204 import 'lib1.dart' as p show A, B; 4142 import 'lib1.dart' as p show A, B;
4205 p.A a;'''); 4143 p.A a;''');
4206 Source source2 = addNamedSource( 4144 Source source2 = addNamedSource("/lib1.dart", r'''
4207 "/lib1.dart",
4208 r'''
4209 library lib1; 4145 library lib1;
4210 class A {} 4146 class A {}
4211 class B {}'''); 4147 class B {}''');
4212 await computeAnalysisResult(source); 4148 await computeAnalysisResult(source);
4213 await computeAnalysisResult(source2); 4149 await computeAnalysisResult(source2);
4214 assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]); 4150 assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
4215 assertNoErrors(source2); 4151 assertNoErrors(source2);
4216 verify([source, source2]); 4152 verify([source, source2]);
4217 } 4153 }
4218 4154
4219 test_unusedShownName_duplicates() async { 4155 test_unusedShownName_duplicates() async {
4220 Source source = addSource(r''' 4156 Source source = addSource(r'''
4221 library L; 4157 library L;
4222 import 'lib1.dart' show A, B; 4158 import 'lib1.dart' show A, B;
4223 import 'lib1.dart' show C, D; 4159 import 'lib1.dart' show C, D;
4224 A a; 4160 A a;
4225 C c;'''); 4161 C c;''');
4226 Source source2 = addNamedSource( 4162 Source source2 = addNamedSource("/lib1.dart", r'''
4227 "/lib1.dart",
4228 r'''
4229 library lib1; 4163 library lib1;
4230 class A {} 4164 class A {}
4231 class B {} 4165 class B {}
4232 class C {} 4166 class C {}
4233 class D {}'''); 4167 class D {}''');
4234 await computeAnalysisResult(source); 4168 await computeAnalysisResult(source);
4235 await computeAnalysisResult(source2); 4169 await computeAnalysisResult(source2);
4236 assertErrors( 4170 assertErrors(
4237 source, [HintCode.UNUSED_SHOWN_NAME, HintCode.UNUSED_SHOWN_NAME]); 4171 source, [HintCode.UNUSED_SHOWN_NAME, HintCode.UNUSED_SHOWN_NAME]);
4238 assertNoErrors(source2); 4172 assertNoErrors(source2);
4239 verify([source, source2]); 4173 verify([source, source2]);
4240 } 4174 }
4241 4175
4242 test_unusedShownName_topLevelVariable() async { 4176 test_unusedShownName_topLevelVariable() async {
4243 Source source = addSource(r''' 4177 Source source = addSource(r'''
4244 library L; 4178 library L;
4245 import 'lib1.dart' show var1, var2; 4179 import 'lib1.dart' show var1, var2;
4246 import 'lib1.dart' show var3, var4; 4180 import 'lib1.dart' show var3, var4;
4247 int a = var1; 4181 int a = var1;
4248 int b = var2; 4182 int b = var2;
4249 int c = var3;'''); 4183 int c = var3;''');
4250 Source source2 = addNamedSource( 4184 Source source2 = addNamedSource("/lib1.dart", r'''
4251 "/lib1.dart",
4252 r'''
4253 library lib1; 4185 library lib1;
4254 const int var1 = 1; 4186 const int var1 = 1;
4255 const int var2 = 2; 4187 const int var2 = 2;
4256 const int var3 = 3; 4188 const int var3 = 3;
4257 const int var4 = 4;'''); 4189 const int var4 = 4;''');
4258 await computeAnalysisResult(source); 4190 await computeAnalysisResult(source);
4259 await computeAnalysisResult(source2); 4191 await computeAnalysisResult(source2);
4260 assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]); 4192 assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
4261 assertNoErrors(source2); 4193 assertNoErrors(source2);
4262 verify([source, source2]); 4194 verify([source, source2]);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
4336 n() { 4268 n() {
4337 var a = m(), b = m(); 4269 var a = m(), b = m();
4338 } 4270 }
4339 }'''); 4271 }''');
4340 await computeAnalysisResult(source); 4272 await computeAnalysisResult(source);
4341 assertErrors( 4273 assertErrors(
4342 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 4274 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
4343 verify([source]); 4275 verify([source]);
4344 } 4276 }
4345 } 4277 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/element_resolver_test.dart ('k') | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698