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

Side by Side Diff: pkg/analysis_server/test/context_manager_test.dart

Issue 2488043002: Enable generic method support by default (Closed)
Patch Set: clean up Created 4 years, 1 month 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.context.directory.manager; 5 library test.context.directory.manager;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analysis_server/src/context_manager.dart'; 9 import 'package:analysis_server/src/context_manager.dart';
10 import 'package:analyzer/error/error.dart'; 10 import 'package:analyzer/error/error.dart';
(...skipping 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 1844
1845 test_analysis_options_file_delete() async { 1845 test_analysis_options_file_delete() async {
1846 // Setup analysis options 1846 // Setup analysis options
1847 newFile( 1847 newFile(
1848 [projPath, optionsFileName], 1848 [projPath, optionsFileName],
1849 r''' 1849 r'''
1850 embedded_libs: 1850 embedded_libs:
1851 "dart:foobar": "../sdk_ext/entry.dart" 1851 "dart:foobar": "../sdk_ext/entry.dart"
1852 analyzer: 1852 analyzer:
1853 language: 1853 language:
1854 enableGenericMethods: true 1854 enableStrictCallChecks: true
1855 errors: 1855 errors:
1856 unused_local_variable: false 1856 unused_local_variable: false
1857 linter: 1857 linter:
1858 rules: 1858 rules:
1859 - camel_case_types 1859 - camel_case_types
1860 '''); 1860 ''');
1861 1861
1862 // Setup context. 1862 // Setup context.
1863 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 1863 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
1864 await pumpEventQueue(); 1864 await pumpEventQueue();
1865 1865
1866 // Verify options were set. 1866 // Verify options were set.
1867 expect(errorProcessors, hasLength(1)); 1867 expect(errorProcessors, hasLength(1));
1868 expect(lints, hasLength(1)); 1868 expect(lints, hasLength(1));
1869 expect(options.enableGenericMethods, isTrue); 1869 expect(options.enableStrictCallChecks, isTrue);
1870 1870
1871 // Remove options. 1871 // Remove options.
1872 deleteFile([projPath, optionsFileName]); 1872 deleteFile([projPath, optionsFileName]);
1873 await pumpEventQueue(); 1873 await pumpEventQueue();
1874 1874
1875 // Verify defaults restored. 1875 // Verify defaults restored.
1876 expect(errorProcessors, isEmpty); 1876 expect(errorProcessors, isEmpty);
1877 expect(lints, isEmpty); 1877 expect(lints, isEmpty);
1878 expect(options.enableGenericMethods, isFalse); 1878 expect(options.enableStrictCallChecks, isFalse);
1879 } 1879 }
1880 1880
1881 test_analysis_options_file_delete_with_embedder() async { 1881 test_analysis_options_file_delete_with_embedder() async {
1882 // Setup _embedder.yaml. 1882 // Setup _embedder.yaml.
1883 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); 1883 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]);
1884 newFile( 1884 newFile(
1885 [libPath, '_embedder.yaml'], 1885 [libPath, '_embedder.yaml'],
1886 r''' 1886 r'''
1887 analyzer: 1887 analyzer:
1888 strong-mode: true 1888 strong-mode: true
1889 errors: 1889 errors:
1890 missing_return: false 1890 missing_return: false
1891 linter: 1891 linter:
1892 rules: 1892 rules:
1893 - avoid_as 1893 - avoid_as
1894 '''); 1894 ''');
1895 1895
1896 // Setup .packages file 1896 // Setup .packages file
1897 newFile( 1897 newFile(
1898 [projPath, '.packages'], 1898 [projPath, '.packages'],
1899 r''' 1899 r'''
1900 test_pack:lib/'''); 1900 test_pack:lib/''');
1901 1901
1902 // Setup analysis options 1902 // Setup analysis options
1903 newFile( 1903 newFile(
1904 [projPath, optionsFileName], 1904 [projPath, optionsFileName],
1905 r''' 1905 r'''
1906 analyzer: 1906 analyzer:
1907 language: 1907 language:
1908 enableGenericMethods: true 1908 enableStrictCallChecks: true
1909 errors: 1909 errors:
1910 unused_local_variable: false 1910 unused_local_variable: false
1911 linter: 1911 linter:
1912 rules: 1912 rules:
1913 - camel_case_types 1913 - camel_case_types
1914 '''); 1914 ''');
1915 1915
1916 // Setup context. 1916 // Setup context.
1917 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 1917 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
1918 await pumpEventQueue(); 1918 await pumpEventQueue();
1919 1919
1920 // Verify options were set. 1920 // Verify options were set.
1921 expect(options.enableGenericMethods, isTrue); 1921 expect(options.enableStrictCallChecks, isTrue);
1922 expect(options.strongMode, isTrue); 1922 expect(options.strongMode, isTrue);
1923 expect(errorProcessors, hasLength(2)); 1923 expect(errorProcessors, hasLength(2));
1924 expect(lints, hasLength(2)); 1924 expect(lints, hasLength(2));
1925 1925
1926 // Remove options. 1926 // Remove options.
1927 deleteFile([projPath, optionsFileName]); 1927 deleteFile([projPath, optionsFileName]);
1928 await pumpEventQueue(); 1928 await pumpEventQueue();
1929 1929
1930 // Verify defaults restored. 1930 // Verify defaults restored.
1931 expect(options.enableGenericMethods, isFalse); 1931 expect(options.enableStrictCallChecks, isFalse);
1932 expect(lints, hasLength(1)); 1932 expect(lints, hasLength(1));
1933 expect(lints.first, new isInstanceOf<AvoidAs>()); 1933 expect(lints.first, new isInstanceOf<AvoidAs>());
1934 expect(errorProcessors, hasLength(1)); 1934 expect(errorProcessors, hasLength(1));
1935 expect(getProcessor(missing_return).severity, isNull); 1935 expect(getProcessor(missing_return).severity, isNull);
1936 } 1936 }
1937 1937
1938 test_analysis_options_parse_failure() async { 1938 test_analysis_options_parse_failure() async {
1939 // Create files. 1939 // Create files.
1940 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); 1940 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]);
1941 newFile([libPath, 'main.dart']); 1941 newFile([libPath, 'main.dart']);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 '''); 1990 ''');
1991 1991
1992 // Setup analysis options 1992 // Setup analysis options
1993 newFile( 1993 newFile(
1994 [projPath, optionsFileName], 1994 [projPath, optionsFileName],
1995 r''' 1995 r'''
1996 analyzer: 1996 analyzer:
1997 exclude: 1997 exclude:
1998 - 'test/**' 1998 - 'test/**'
1999 language: 1999 language:
2000 enableGenericMethods: true 2000 enableStrictCallChecks: true
2001 errors: 2001 errors:
2002 unused_local_variable: false 2002 unused_local_variable: false
2003 linter: 2003 linter:
2004 rules: 2004 rules:
2005 - camel_case_types 2005 - camel_case_types
2006 '''); 2006 ''');
2007 2007
2008 // Setup context. 2008 // Setup context.
2009 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 2009 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
2010 await pumpEventQueue(); 2010 await pumpEventQueue();
2011 2011
2012 // Confirm that one context was created. 2012 // Confirm that one context was created.
2013 var contexts = 2013 var contexts =
2014 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); 2014 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath));
2015 expect(contexts, isNotNull); 2015 expect(contexts, isNotNull);
2016 expect(contexts, hasLength(1)); 2016 expect(contexts, hasLength(1));
2017 2017
2018 var context = contexts.first; 2018 var context = contexts.first;
2019 2019
2020 // Verify options. 2020 // Verify options.
2021 // * from `config.yaml`: 2021 // * from `config.yaml`:
2022 expect(context.analysisOptions.strongMode, isTrue); 2022 expect(context.analysisOptions.strongMode, isTrue);
2023 expect(context.analysisOptions.enableSuperMixins, isTrue); 2023 expect(context.analysisOptions.enableSuperMixins, isTrue);
2024 // * from analysis options: 2024 // * from analysis options:
2025 expect(context.analysisOptions.enableGenericMethods, isTrue); 2025 expect(context.analysisOptions.enableStrictCallChecks, isTrue);
2026 2026
2027 // * verify tests are excluded 2027 // * verify tests are excluded
2028 expect(callbacks.currentContextFilePaths[projPath].keys, 2028 expect(callbacks.currentContextFilePaths[projPath].keys,
2029 unorderedEquals(['/my/proj/$optionsFileName'])); 2029 unorderedEquals(['/my/proj/$optionsFileName']));
2030 2030
2031 // Verify filter setup. 2031 // Verify filter setup.
2032 expect(errorProcessors, hasLength(2)); 2032 expect(errorProcessors, hasLength(2));
2033 2033
2034 // * (config.) 2034 // * (config.)
2035 expect(getProcessor(missing_return).severity, isNull); 2035 expect(getProcessor(missing_return).severity, isNull);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 test_pack:lib/'''); 2086 test_pack:lib/''');
2087 2087
2088 // Setup analysis options 2088 // Setup analysis options
2089 newFile( 2089 newFile(
2090 [projPath, optionsFileName], 2090 [projPath, optionsFileName],
2091 r''' 2091 r'''
2092 analyzer: 2092 analyzer:
2093 exclude: 2093 exclude:
2094 - 'test/**' 2094 - 'test/**'
2095 language: 2095 language:
2096 enableGenericMethods: true 2096 enableStrictCallChecks: true
2097 errors: 2097 errors:
2098 unused_local_variable: false 2098 unused_local_variable: false
2099 linter: 2099 linter:
2100 rules: 2100 rules:
2101 - camel_case_types 2101 - camel_case_types
2102 '''); 2102 ''');
2103 2103
2104 // Setup config.yaml. 2104 // Setup config.yaml.
2105 newFile( 2105 newFile(
2106 [libPath, 'config', 'config.yaml'], 2106 [libPath, 'config', 'config.yaml'],
(...skipping 15 matching lines...) Expand all
2122 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); 2122 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath));
2123 expect(contexts, isNotNull); 2123 expect(contexts, isNotNull);
2124 expect(contexts, hasLength(1)); 2124 expect(contexts, hasLength(1));
2125 var context = contexts[0]; 2125 var context = contexts[0];
2126 2126
2127 // Verify options. 2127 // Verify options.
2128 // * from `_embedder.yaml`: 2128 // * from `_embedder.yaml`:
2129 expect(context.analysisOptions.strongMode, isTrue); 2129 expect(context.analysisOptions.strongMode, isTrue);
2130 expect(context.analysisOptions.enableSuperMixins, isTrue); 2130 expect(context.analysisOptions.enableSuperMixins, isTrue);
2131 // * from analysis options: 2131 // * from analysis options:
2132 expect(context.analysisOptions.enableGenericMethods, isTrue); 2132 expect(context.analysisOptions.enableStrictCallChecks, isTrue);
2133 2133
2134 // * verify tests are excluded 2134 // * verify tests are excluded
2135 expect( 2135 expect(
2136 callbacks.currentContextFilePaths[projPath].keys, 2136 callbacks.currentContextFilePaths[projPath].keys,
2137 unorderedEquals( 2137 unorderedEquals(
2138 ['/my/proj/sdk_ext/entry.dart', '/my/proj/$optionsFileName'])); 2138 ['/my/proj/sdk_ext/entry.dart', '/my/proj/$optionsFileName']));
2139 2139
2140 // Verify filter setup. 2140 // Verify filter setup.
2141 expect(errorProcessors, hasLength(3)); 2141 expect(errorProcessors, hasLength(3));
2142 2142
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 test_pack:lib/'''); 2195 test_pack:lib/''');
2196 2196
2197 // Setup analysis options 2197 // Setup analysis options
2198 newFile( 2198 newFile(
2199 [projPath, optionsFileName], 2199 [projPath, optionsFileName],
2200 r''' 2200 r'''
2201 analyzer: 2201 analyzer:
2202 exclude: 2202 exclude:
2203 - 'test/**' 2203 - 'test/**'
2204 language: 2204 language:
2205 enableGenericMethods: true 2205 enableStrictCallChecks: true
2206 errors: 2206 errors:
2207 unused_local_variable: false 2207 unused_local_variable: false
2208 linter: 2208 linter:
2209 rules: 2209 rules:
2210 - camel_case_types 2210 - camel_case_types
2211 '''); 2211 ''');
2212 2212
2213 // Setup context. 2213 // Setup context.
2214 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 2214 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
2215 await pumpEventQueue(); 2215 await pumpEventQueue();
2216 2216
2217 // Confirm that one context was created. 2217 // Confirm that one context was created.
2218 var contexts = 2218 var contexts =
2219 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath)); 2219 manager.contextsInAnalysisRoot(resourceProvider.newFolder(projPath));
2220 expect(contexts, isNotNull); 2220 expect(contexts, isNotNull);
2221 expect(contexts, hasLength(1)); 2221 expect(contexts, hasLength(1));
2222 var context = contexts[0]; 2222 var context = contexts[0];
2223 2223
2224 // Verify options. 2224 // Verify options.
2225 // * from `_embedder.yaml`: 2225 // * from `_embedder.yaml`:
2226 expect(context.analysisOptions.strongMode, isTrue); 2226 expect(context.analysisOptions.strongMode, isTrue);
2227 expect(context.analysisOptions.enableSuperMixins, isTrue); 2227 expect(context.analysisOptions.enableSuperMixins, isTrue);
2228 // * from analysis options: 2228 // * from analysis options:
2229 expect(context.analysisOptions.enableGenericMethods, isTrue); 2229 expect(context.analysisOptions.enableStrictCallChecks, isTrue);
2230 2230
2231 // * verify tests are excluded 2231 // * verify tests are excluded
2232 expect( 2232 expect(
2233 callbacks.currentContextFilePaths[projPath].keys, 2233 callbacks.currentContextFilePaths[projPath].keys,
2234 unorderedEquals( 2234 unorderedEquals(
2235 ['/my/proj/sdk_ext/entry.dart', '/my/proj/$optionsFileName'])); 2235 ['/my/proj/sdk_ext/entry.dart', '/my/proj/$optionsFileName']));
2236 2236
2237 // Verify filter setup. 2237 // Verify filter setup.
2238 expect(errorProcessors, hasLength(2)); 2238 expect(errorProcessors, hasLength(2));
2239 2239
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
2767 class TestUriResolver extends UriResolver { 2767 class TestUriResolver extends UriResolver {
2768 Map<Uri, Source> uriMap; 2768 Map<Uri, Source> uriMap;
2769 2769
2770 TestUriResolver(this.uriMap); 2770 TestUriResolver(this.uriMap);
2771 2771
2772 @override 2772 @override
2773 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 2773 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
2774 return uriMap[uri]; 2774 return uriMap[uri];
2775 } 2775 }
2776 } 2776 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/status/get_handler.dart ('k') | pkg/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698