Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 engine.resolver_test; | 5 library engine.resolver_test; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/context/context.dart' as newContext; | 9 import 'package:analyzer/src/context/context.dart' as newContext; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 13134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13145 '''; | 13145 '''; |
| 13146 _resolveTestUnit(code); | 13146 _resolveTestUnit(code); |
| 13147 | 13147 |
| 13148 SimpleIdentifier identifier = _findIdentifier('foo'); | 13148 SimpleIdentifier identifier = _findIdentifier('foo'); |
| 13149 VariableDeclaration declaration = | 13149 VariableDeclaration declaration = |
| 13150 identifier.getAncestor((node) => node is VariableDeclaration); | 13150 identifier.getAncestor((node) => node is VariableDeclaration); |
| 13151 expect(declaration.initializer.staticType.name, 'String'); | 13151 expect(declaration.initializer.staticType.name, 'String'); |
| 13152 expect(declaration.initializer.propagatedType, isNull); | 13152 expect(declaration.initializer.propagatedType, isNull); |
| 13153 } | 13153 } |
| 13154 | 13154 |
| 13155 void test_genericFunction_typedef() { | |
| 13156 String code = r''' | |
| 13157 typedef T F<T>(T x); | |
| 13158 F f0; | |
| 13159 | |
| 13160 class C { | |
| 13161 static F f1; | |
| 13162 F f2; | |
| 13163 void g(F f3) { | |
|
Jennifer Messerly
2015/12/07 23:15:13
test a local variable as well?
Leaf
2015/12/08 00:00:54
Done.
| |
| 13164 f0(3); | |
| 13165 f1(3); | |
| 13166 f2(3); | |
| 13167 f3(3); | |
| 13168 } | |
| 13169 } | |
| 13170 '''; | |
| 13171 _resolveTestUnit(code); | |
| 13172 | |
| 13173 List<Statement> statements = | |
| 13174 AstFinder.getStatementsInMethod(testUnit, "C", "g"); | |
| 13175 | |
| 13176 ExpressionStatement exps0 = statements[0]; | |
| 13177 ExpressionStatement exps1 = statements[1]; | |
| 13178 ExpressionStatement exps2 = statements[2]; | |
| 13179 ExpressionStatement exps3 = statements[3]; | |
| 13180 Expression exp0 = exps0.expression; | |
| 13181 Expression exp1 = exps1.expression; | |
| 13182 Expression exp2 = exps2.expression; | |
| 13183 Expression exp3 = exps3.expression; | |
| 13184 expect(exp0.staticType, typeProvider.dynamicType); | |
| 13185 expect(exp1.staticType, typeProvider.dynamicType); | |
| 13186 expect(exp2.staticType, typeProvider.dynamicType); | |
| 13187 expect(exp3.staticType, typeProvider.dynamicType); | |
| 13188 } | |
| 13189 | |
| 13155 void test_genericFunction() { | 13190 void test_genericFunction() { |
| 13156 if (!AnalysisEngine.instance.useTaskModel) { | 13191 if (!AnalysisEngine.instance.useTaskModel) { |
| 13157 return; | 13192 return; |
| 13158 } | 13193 } |
| 13159 _resolveTestUnit(r'/*=T*/ f/*<T>*/(/*=T*/ x) => null;'); | 13194 _resolveTestUnit(r'/*=T*/ f/*<T>*/(/*=T*/ x) => null;'); |
| 13160 SimpleIdentifier f = _findIdentifier('f'); | 13195 SimpleIdentifier f = _findIdentifier('f'); |
| 13161 FunctionElementImpl e = f.staticElement; | 13196 FunctionElementImpl e = f.staticElement; |
| 13162 expect(e.typeParameters.toString(), '[T]'); | 13197 expect(e.typeParameters.toString(), '[T]'); |
| 13163 expect(e.type.boundTypeParameters.toString(), '[T]'); | 13198 expect(e.type.boundTypeParameters.toString(), '[T]'); |
| 13164 expect(e.type.typeParameters.toString(), '[]'); | 13199 expect(e.type.typeParameters.toString(), '[]'); |
| (...skipping 3154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16319 | 16354 |
| 16320 void _resolveTestUnit(String code) { | 16355 void _resolveTestUnit(String code) { |
| 16321 testCode = code; | 16356 testCode = code; |
| 16322 testSource = addSource(testCode); | 16357 testSource = addSource(testCode); |
| 16323 LibraryElement library = resolve2(testSource); | 16358 LibraryElement library = resolve2(testSource); |
| 16324 assertNoErrors(testSource); | 16359 assertNoErrors(testSource); |
| 16325 verify([testSource]); | 16360 verify([testSource]); |
| 16326 testUnit = resolveCompilationUnit(testSource, library); | 16361 testUnit = resolveCompilationUnit(testSource, library); |
| 16327 } | 16362 } |
| 16328 } | 16363 } |
| OLD | NEW |