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

Unified Diff: pkg/analyzer/test/generated/static_type_analyzer_test.dart

Issue 1843473002: Sort analyzer sources (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Remove generated file and fix misplaced comments Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/generated/static_type_analyzer_test.dart
diff --git a/pkg/analyzer/test/generated/static_type_analyzer_test.dart b/pkg/analyzer/test/generated/static_type_analyzer_test.dart
index 61910204a99a5b966b4acdb9e721199fb2f0b6a0..21085bab3d22ed5e3e490b959fa76c559f4bd6aa 100644
--- a/pkg/analyzer/test/generated/static_type_analyzer_test.dart
+++ b/pkg/analyzer/test/generated/static_type_analyzer_test.dart
@@ -37,6 +37,143 @@ main() {
runReflectiveTests(StaticTypeAnalyzer2Test);
}
+/**
+ * Like [StaticTypeAnalyzerTest], but as end-to-end tests.
+ */
+@reflectiveTest
+class StaticTypeAnalyzer2Test extends StaticTypeAnalyzer2TestShared {
+ void test_FunctionExpressionInvocation_block() {
+ String code = r'''
+main() {
+ var foo = (() { return 1; })();
+}
+''';
+ resolveTestUnit(code);
+ expectInitializerType('foo', 'dynamic', isNull);
+ }
+
+ void test_FunctionExpressionInvocation_curried() {
+ String code = r'''
+typedef int F();
+F f() => null;
+main() {
+ var foo = f()();
+}
+''';
+ resolveTestUnit(code);
+ expectInitializerType('foo', 'int', isNull);
+ }
+
+ void test_FunctionExpressionInvocation_expression() {
+ String code = r'''
+main() {
+ var foo = (() => 1)();
+}
+''';
+ resolveTestUnit(code);
+ expectInitializerType('foo', 'int', isNull);
+ }
+
+ void test_MethodInvocation_nameType_localVariable() {
+ String code = r"""
+typedef Foo();
+main() {
+ Foo foo;
+ foo();
+}
+""";
+ resolveTestUnit(code);
+ // "foo" should be resolved to the "Foo" type
+ expectIdentifierType("foo();", new isInstanceOf<FunctionType>());
+ }
+
+ void test_MethodInvocation_nameType_parameter_FunctionTypeAlias() {
+ String code = r"""
+typedef Foo();
+main(Foo foo) {
+ foo();
+}
+""";
+ resolveTestUnit(code);
+ // "foo" should be resolved to the "Foo" type
+ expectIdentifierType("foo();", new isInstanceOf<FunctionType>());
+ }
+
+ void test_MethodInvocation_nameType_parameter_propagatedType() {
+ String code = r"""
+typedef Foo();
+main(p) {
+ if (p is Foo) {
+ p();
+ }
+}
+""";
+ resolveTestUnit(code);
+ expectIdentifierType("p()", DynamicTypeImpl.instance,
+ predicate((type) => type.name == 'Foo'));
+ }
+
+ void test_staticMethods_classTypeParameters() {
+ String code = r'''
+class C<T> {
+ static void m() => null;
+}
+main() {
+ print(C.m);
+}
+''';
+ resolveTestUnit(code);
+ expectFunctionType('m);', '() → void');
+ }
+
+ void test_staticMethods_classTypeParameters_genericMethod() {
+ AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ options.enableGenericMethods = true;
+ resetWithOptions(options);
+ String code = r'''
+class C<T> {
+ static void m<S>(S s) {
+ void f<U>(S s, U u) {}
+ print(f);
+ }
+}
+main() {
+ print(C.m);
+}
+''';
+ resolveTestUnit(code);
+ // C - m
+ TypeParameterType typeS;
+ {
+ expectFunctionType('m);', '<S>(S) → void',
+ elementTypeParams: '[S]', typeFormals: '[S]');
+
+ FunctionTypeImpl type = findIdentifier('m);').staticType;
+ typeS = type.typeFormals[0].type;
+ type = type.instantiate([DynamicTypeImpl.instance]);
+ expect(type.toString(), '(dynamic) → void');
+ expect(type.typeParameters.toString(), '[S]');
+ expect(type.typeArguments, [DynamicTypeImpl.instance]);
+ expect(type.typeFormals, isEmpty);
+ }
+ // C - m - f
+ {
+ expectFunctionType('f);', '<U>(S, U) → void',
+ elementTypeParams: '[U]',
+ typeParams: '[S]',
+ typeArgs: '[S]',
+ typeFormals: '[U]');
+
+ FunctionTypeImpl type = findIdentifier('f);').staticType;
+ type = type.instantiate([DynamicTypeImpl.instance]);
+ expect(type.toString(), '(S, dynamic) → void');
+ expect(type.typeParameters.toString(), '[S, U]');
+ expect(type.typeArguments, [typeS, DynamicTypeImpl.instance]);
+ expect(type.typeFormals, isEmpty);
+ }
+ }
+}
+
@reflectiveTest
class StaticTypeAnalyzerTest extends EngineTestCase {
/**
@@ -1480,140 +1617,3 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
(element as ParameterElementImpl).type = type;
}
}
-
-/**
- * Like [StaticTypeAnalyzerTest], but as end-to-end tests.
- */
-@reflectiveTest
-class StaticTypeAnalyzer2Test extends StaticTypeAnalyzer2TestShared {
- void test_FunctionExpressionInvocation_block() {
- String code = r'''
-main() {
- var foo = (() { return 1; })();
-}
-''';
- resolveTestUnit(code);
- expectInitializerType('foo', 'dynamic', isNull);
- }
-
- void test_FunctionExpressionInvocation_curried() {
- String code = r'''
-typedef int F();
-F f() => null;
-main() {
- var foo = f()();
-}
-''';
- resolveTestUnit(code);
- expectInitializerType('foo', 'int', isNull);
- }
-
- void test_FunctionExpressionInvocation_expression() {
- String code = r'''
-main() {
- var foo = (() => 1)();
-}
-''';
- resolveTestUnit(code);
- expectInitializerType('foo', 'int', isNull);
- }
-
- void test_MethodInvocation_nameType_localVariable() {
- String code = r"""
-typedef Foo();
-main() {
- Foo foo;
- foo();
-}
-""";
- resolveTestUnit(code);
- // "foo" should be resolved to the "Foo" type
- expectIdentifierType("foo();", new isInstanceOf<FunctionType>());
- }
-
- void test_MethodInvocation_nameType_parameter_FunctionTypeAlias() {
- String code = r"""
-typedef Foo();
-main(Foo foo) {
- foo();
-}
-""";
- resolveTestUnit(code);
- // "foo" should be resolved to the "Foo" type
- expectIdentifierType("foo();", new isInstanceOf<FunctionType>());
- }
-
- void test_MethodInvocation_nameType_parameter_propagatedType() {
- String code = r"""
-typedef Foo();
-main(p) {
- if (p is Foo) {
- p();
- }
-}
-""";
- resolveTestUnit(code);
- expectIdentifierType("p()", DynamicTypeImpl.instance,
- predicate((type) => type.name == 'Foo'));
- }
-
- void test_staticMethods_classTypeParameters() {
- String code = r'''
-class C<T> {
- static void m() => null;
-}
-main() {
- print(C.m);
-}
-''';
- resolveTestUnit(code);
- expectFunctionType('m);', '() → void');
- }
-
- void test_staticMethods_classTypeParameters_genericMethod() {
- AnalysisOptionsImpl options = new AnalysisOptionsImpl();
- options.enableGenericMethods = true;
- resetWithOptions(options);
- String code = r'''
-class C<T> {
- static void m<S>(S s) {
- void f<U>(S s, U u) {}
- print(f);
- }
-}
-main() {
- print(C.m);
-}
-''';
- resolveTestUnit(code);
- // C - m
- TypeParameterType typeS;
- {
- expectFunctionType('m);', '<S>(S) → void',
- elementTypeParams: '[S]', typeFormals: '[S]');
-
- FunctionTypeImpl type = findIdentifier('m);').staticType;
- typeS = type.typeFormals[0].type;
- type = type.instantiate([DynamicTypeImpl.instance]);
- expect(type.toString(), '(dynamic) → void');
- expect(type.typeParameters.toString(), '[S]');
- expect(type.typeArguments, [DynamicTypeImpl.instance]);
- expect(type.typeFormals, isEmpty);
- }
- // C - m - f
- {
- expectFunctionType('f);', '<U>(S, U) → void',
- elementTypeParams: '[U]',
- typeParams: '[S]',
- typeArgs: '[S]',
- typeFormals: '[U]');
-
- FunctionTypeImpl type = findIdentifier('f);').staticType;
- type = type.instantiate([DynamicTypeImpl.instance]);
- expect(type.toString(), '(S, dynamic) → void');
- expect(type.typeParameters.toString(), '[S, U]');
- expect(type.typeArguments, [typeS, DynamicTypeImpl.instance]);
- expect(type.typeFormals, isEmpty);
- }
- }
-}
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test_case.dart ('k') | pkg/analyzer/test/generated/static_type_warning_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698