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 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 | 1823 |
1824 main() { | 1824 main() { |
1825 new C(a: 2); | 1825 new C(a: 2); |
1826 } | 1826 } |
1827 '''); | 1827 '''); |
1828 computeLibrarySourceErrors(source); | 1828 computeLibrarySourceErrors(source); |
1829 assertNoErrors(source); | 1829 assertNoErrors(source); |
1830 verify([source]); | 1830 verify([source]); |
1831 } | 1831 } |
1832 | 1832 |
| 1833 void test_required_constructor_param_redirecting_cons_call() { |
| 1834 Source source = addSource(r''' |
| 1835 import 'package:meta/meta.dart'; |
| 1836 |
| 1837 class C { |
| 1838 C({@required int x}); |
| 1839 C.named() : this(); |
| 1840 } |
| 1841 '''); |
| 1842 computeLibrarySourceErrors(source); |
| 1843 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM]); |
| 1844 verify([source]); |
| 1845 } |
| 1846 |
| 1847 void test_required_constructor_param_super_call() { |
| 1848 Source source = addSource(r''' |
| 1849 import 'package:meta/meta.dart'; |
| 1850 |
| 1851 class C { |
| 1852 C({@Required('must specify an `a`') int a}) {} |
| 1853 } |
| 1854 |
| 1855 class D extends C { |
| 1856 D() : super(); |
| 1857 } |
| 1858 '''); |
| 1859 computeLibrarySourceErrors(source); |
| 1860 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]); |
| 1861 verify([source]); |
| 1862 } |
| 1863 |
1833 void test_required_function_param() { | 1864 void test_required_function_param() { |
1834 Source source = addSource(r''' | 1865 Source source = addSource(r''' |
1835 import 'package:meta/meta.dart'; | 1866 import 'package:meta/meta.dart'; |
1836 | 1867 |
1837 void f({@Required('must specify an `a`') int a}) {} | 1868 void f({@Required('must specify an `a`') int a}) {} |
1838 | 1869 |
1839 main() { | 1870 main() { |
1840 f(); | 1871 f(); |
1841 } | 1872 } |
1842 '''); | 1873 '''); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 f() { | 1907 f() { |
1877 new A().m(); | 1908 new A().m(); |
1878 } | 1909 } |
1879 '''); | 1910 '''); |
1880 | 1911 |
1881 computeLibrarySourceErrors(source); | 1912 computeLibrarySourceErrors(source); |
1882 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]); | 1913 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS]); |
1883 verify([source]); | 1914 verify([source]); |
1884 } | 1915 } |
1885 | 1916 |
| 1917 void test_required_typedef_function_param() { |
| 1918 Source source = addSource(r''' |
| 1919 import 'package:meta/meta.dart'; |
| 1920 |
| 1921 String test(C c) => c.m()(); |
| 1922 |
| 1923 typedef String F({@required String x}); |
| 1924 |
| 1925 class C { |
| 1926 F m() => ({@required String x}) => null; |
| 1927 } |
| 1928 '''); |
| 1929 computeLibrarySourceErrors(source); |
| 1930 assertErrors(source, [HintCode.MISSING_REQUIRED_PARAM]); |
| 1931 verify([source]); |
| 1932 } |
| 1933 |
1886 void test_typeCheck_type_is_Null() { | 1934 void test_typeCheck_type_is_Null() { |
1887 Source source = addSource(r''' | 1935 Source source = addSource(r''' |
1888 m(i) { | 1936 m(i) { |
1889 bool b = i is Null; | 1937 bool b = i is Null; |
1890 }'''); | 1938 }'''); |
1891 computeLibrarySourceErrors(source); | 1939 computeLibrarySourceErrors(source); |
1892 assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]); | 1940 assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]); |
1893 verify([source]); | 1941 verify([source]); |
1894 } | 1942 } |
1895 | 1943 |
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3501 n() { | 3549 n() { |
3502 var a = m(), b = m(); | 3550 var a = m(), b = m(); |
3503 } | 3551 } |
3504 }'''); | 3552 }'''); |
3505 computeLibrarySourceErrors(source); | 3553 computeLibrarySourceErrors(source); |
3506 assertErrors( | 3554 assertErrors( |
3507 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); | 3555 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); |
3508 verify([source]); | 3556 verify([source]); |
3509 } | 3557 } |
3510 } | 3558 } |
OLD | NEW |