| OLD | NEW |
| 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/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
| 8 import 'package:analyzer/src/generated/error.dart'; | 8 import 'package:analyzer/src/generated/error.dart'; |
| 9 import 'package:analyzer/src/generated/source_io.dart'; | 9 import 'package:analyzer/src/generated/source_io.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 1720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 } | 1731 } |
| 1732 f() { | 1732 f() { |
| 1733 new A().m(); | 1733 new A().m(); |
| 1734 } | 1734 } |
| 1735 '''); | 1735 '''); |
| 1736 computeLibrarySourceErrors(source); | 1736 computeLibrarySourceErrors(source); |
| 1737 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]); | 1737 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]); |
| 1738 verify([source]); | 1738 verify([source]); |
| 1739 } | 1739 } |
| 1740 | 1740 |
| 1741 void test_required_method_param_in_other_lib() { |
| 1742 addNamedSource( |
| 1743 '/a_lib.dart', |
| 1744 r''' |
| 1745 library a_lib; |
| 1746 import 'package:meta/meta.dart'; |
| 1747 class A { |
| 1748 void m({@Required('must specify an `a`') int a}) {} |
| 1749 } |
| 1750 '''); |
| 1751 |
| 1752 Source source = addSource(r''' |
| 1753 import "a_lib.dart"; |
| 1754 f() { |
| 1755 new A().m(); |
| 1756 } |
| 1757 '''); |
| 1758 |
| 1759 computeLibrarySourceErrors(source); |
| 1760 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]); |
| 1761 verify([source]); |
| 1762 } |
| 1763 |
| 1741 void test_typeCheck_type_is_Null() { | 1764 void test_typeCheck_type_is_Null() { |
| 1742 Source source = addSource(r''' | 1765 Source source = addSource(r''' |
| 1743 m(i) { | 1766 m(i) { |
| 1744 bool b = i is Null; | 1767 bool b = i is Null; |
| 1745 }'''); | 1768 }'''); |
| 1746 computeLibrarySourceErrors(source); | 1769 computeLibrarySourceErrors(source); |
| 1747 assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]); | 1770 assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]); |
| 1748 verify([source]); | 1771 verify([source]); |
| 1749 } | 1772 } |
| 1750 | 1773 |
| 1751 void test_typeCheck_type_not_Null() { | 1774 void test_typeCheck_type_not_Null() { |
| 1752 Source source = addSource(r''' | 1775 Source source = addSource(r''' |
| 1753 m(i) { | 1776 m(i) { |
| 1754 bool b = i is! Null; | 1777 bool b = i is! Null; |
| 1755 }'''); | 1778 }'''); |
| 1756 computeLibrarySourceErrors(source); | 1779 computeLibrarySourceErrors(source); |
| 1757 assertErrors(source, [HintCode.TYPE_CHECK_IS_NOT_NULL]); | 1780 assertErrors(source, [HintCode.TYPE_CHECK_IS_NOT_NULL]); |
| 1758 verify([source]); | 1781 verify([source]); |
| 1759 } | 1782 } |
| 1760 | 1783 |
| 1761 void test_undefinedIdentifier_importHide() { | 1784 void test_undefinedIdentifier_importHide() { |
| 1762 Source source = addSource(r''' | 1785 Source source = addSource(r''' |
| 1763 library L; | 1786 library L; |
| 1764 import 'lib1.dart' hide a;'''); | 1787 import 'lib1.dart' hide a;'''); |
| 1765 addNamedSource("/lib1.dart", "library lib1;"); | 1788 addNamedSource("/lib1.dart", "library lib1;"); |
| 1766 computeLibrarySourceErrors(source); | 1789 computeLibrarySourceErrors(source); |
| 1767 assertErrors( | 1790 assertErrors( |
| 1768 source, | 1791 source, [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_HIDDEN_NAME]); |
| 1769 [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_HIDDEN_NAME]); | |
| 1770 verify([source]); | 1792 verify([source]); |
| 1771 } | 1793 } |
| 1772 | 1794 |
| 1773 void test_undefinedIdentifier_importShow() { | 1795 void test_undefinedIdentifier_importShow() { |
| 1774 Source source = addSource(r''' | 1796 Source source = addSource(r''' |
| 1775 library L; | 1797 library L; |
| 1776 import 'lib1.dart' show a;'''); | 1798 import 'lib1.dart' show a;'''); |
| 1777 addNamedSource("/lib1.dart", "library lib1;"); | 1799 addNamedSource("/lib1.dart", "library lib1;"); |
| 1778 computeLibrarySourceErrors(source); | 1800 computeLibrarySourceErrors(source); |
| 1779 assertErrors( | 1801 assertErrors( |
| 1780 source, | 1802 source, [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_SHOWN_NAME]); |
| 1781 [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_SHOWN_NAME]); | |
| 1782 verify([source]); | 1803 verify([source]); |
| 1783 } | 1804 } |
| 1784 | 1805 |
| 1785 void test_undefinedIdentifier_exportHide() { | 1806 void test_undefinedIdentifier_exportHide() { |
| 1786 Source source = addSource(r''' | 1807 Source source = addSource(r''' |
| 1787 library L; | 1808 library L; |
| 1788 export 'lib1.dart' hide a;'''); | 1809 export 'lib1.dart' hide a;'''); |
| 1789 addNamedSource("/lib1.dart", "library lib1;"); | 1810 addNamedSource("/lib1.dart", "library lib1;"); |
| 1790 computeLibrarySourceErrors(source); | 1811 computeLibrarySourceErrors(source); |
| 1791 assertErrors(source, [HintCode.UNDEFINED_HIDDEN_NAME]); | 1812 assertErrors(source, [HintCode.UNDEFINED_HIDDEN_NAME]); |
| (...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3334 n() { | 3355 n() { |
| 3335 var a = m(), b = m(); | 3356 var a = m(), b = m(); |
| 3336 } | 3357 } |
| 3337 }'''); | 3358 }'''); |
| 3338 computeLibrarySourceErrors(source); | 3359 computeLibrarySourceErrors(source); |
| 3339 assertErrors( | 3360 assertErrors( |
| 3340 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); | 3361 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); |
| 3341 verify([source]); | 3362 verify([source]); |
| 3342 } | 3363 } |
| 3343 } | 3364 } |
| OLD | NEW |