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

Side by Side Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1342903002: Fixes for the new task model (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.src.task.dart_test; 5 library test.src.task.dart_test;
6 6
7 import 'package:analyzer/src/context/cache.dart'; 7 import 'package:analyzer/src/context/cache.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/constant.dart'; 9 import 'package:analyzer/src/generated/constant.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 runReflectiveTests(GenerateHintsTaskTest); 50 runReflectiveTests(GenerateHintsTaskTest);
51 runReflectiveTests(InferInstanceMembersInUnitTaskTest); 51 runReflectiveTests(InferInstanceMembersInUnitTaskTest);
52 runReflectiveTests(InferStaticVariableTypesInUnitTaskTest); 52 runReflectiveTests(InferStaticVariableTypesInUnitTaskTest);
53 runReflectiveTests(InferStaticVariableTypeTaskTest); 53 runReflectiveTests(InferStaticVariableTypeTaskTest);
54 runReflectiveTests(LibraryErrorsReadyTaskTest); 54 runReflectiveTests(LibraryErrorsReadyTaskTest);
55 runReflectiveTests(LibraryUnitErrorsTaskTest); 55 runReflectiveTests(LibraryUnitErrorsTaskTest);
56 runReflectiveTests(ParseDartTaskTest); 56 runReflectiveTests(ParseDartTaskTest);
57 runReflectiveTests(PartiallyResolveUnitReferencesTaskTest); 57 runReflectiveTests(PartiallyResolveUnitReferencesTaskTest);
58 runReflectiveTests(ResolveFunctionBodiesInUnitTaskTest); 58 runReflectiveTests(ResolveFunctionBodiesInUnitTaskTest);
59 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); 59 runReflectiveTests(ResolveLibraryTypeNamesTaskTest);
60 // runReflectiveTests(ResolveUnitReferencesTaskTest);
61 runReflectiveTests(ResolveUnitTypeNamesTaskTest); 60 runReflectiveTests(ResolveUnitTypeNamesTaskTest);
62 runReflectiveTests(ResolveVariableReferencesTaskTest); 61 runReflectiveTests(ResolveVariableReferencesTaskTest);
63 runReflectiveTests(ScanDartTaskTest); 62 runReflectiveTests(ScanDartTaskTest);
64 runReflectiveTests(VerifyUnitTaskTest); 63 runReflectiveTests(VerifyUnitTaskTest);
65 } 64 }
66 65
67 isInstanceOf isBuildCompilationUnitElementTask = 66 isInstanceOf isBuildCompilationUnitElementTask =
68 new isInstanceOf<BuildCompilationUnitElementTask>(); 67 new isInstanceOf<BuildCompilationUnitElementTask>();
69 isInstanceOf isBuildDirectiveElementsTask = 68 isInstanceOf isBuildDirectiveElementsTask =
70 new isInstanceOf<BuildDirectiveElementsTask>(); 69 new isInstanceOf<BuildDirectiveElementsTask>();
(...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 2353
2355 FunctionDeclaration mainFunction = unit.declarations[0]; 2354 FunctionDeclaration mainFunction = unit.declarations[0];
2356 expect(mainFunction.element, isNotNull); 2355 expect(mainFunction.element, isNotNull);
2357 BlockFunctionBody body = mainFunction.functionExpression.body; 2356 BlockFunctionBody body = mainFunction.functionExpression.body;
2358 List<Statement> statements = body.block.statements; 2357 List<Statement> statements = body.block.statements;
2359 ExpressionStatement statement = statements[0]; 2358 ExpressionStatement statement = statements[0];
2360 MethodInvocation invocation = statement.expression; 2359 MethodInvocation invocation = statement.expression;
2361 MethodElement methodElement = invocation.methodName.staticElement; 2360 MethodElement methodElement = invocation.methodName.staticElement;
2362 expect(methodElement, isNull); 2361 expect(methodElement, isNull);
2363 } 2362 }
2363
2364 test_perform_notResolved() {
2365 enableStrongMode();
2366 Source source = newSource(
2367 '/test.dart',
2368 '''
2369 int A;
2370 f1() {
2371 A;
2372 }
2373 var f2 = () {
2374 A;
2375 void f3() {
2376 A;
2377 }
2378 }
2379 class C {
2380 C() {
2381 A;
2382 }
2383 m() {
2384 A;
2385 }
2386 }
2387 ''');
2388 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
2389 computeResult(target, RESOLVED_UNIT5,
2390 matcher: isPartiallyResolveUnitReferencesTask);
2391 CompilationUnit unit = outputs[RESOLVED_UNIT5];
2392 NodeList<CompilationUnitMember> declarations = unit.declarations;
2393
2394 void expectReference(BlockFunctionBody body, bool isResolved) {
2395 ExpressionStatement statement = body.block.statements[0];
2396 SimpleIdentifier reference = statement.expression;
2397 expect(reference.staticElement, isResolved ? isNotNull : isNull);
2398 }
2399 //
2400 // The reference to 'A' in 'f1' should not be resolved.
2401 //
2402 FunctionDeclaration f1 = declarations[1];
2403 expectReference(f1.functionExpression.body, false);
2404 //
2405 // The references to 'A' in 'f2' should be resolved.
2406 //
2407 TopLevelVariableDeclaration f2 = declarations[2];
2408 FunctionExpression expression2 = f2.variables.variables[0].initializer;
2409 BlockFunctionBody body2 = expression2.body;
2410 expectReference(body2, true);
2411
2412 FunctionDeclarationStatement statement2 = body2.block.statements[1];
2413 BlockFunctionBody innerBody =
2414 statement2.functionDeclaration.functionExpression.body;
2415 expectReference(innerBody, true);
2416 //
2417 // The references to 'A' in 'C' should not be resolved.
2418 //
2419 ClassDeclaration c = declarations[3];
2420 NodeList<ClassMember> members = c.members;
2421
2422 ConstructorDeclaration constructor = members[0];
2423 expectReference(constructor.body, false);
2424
2425 MethodDeclaration method = members[1];
2426 expectReference(method.body, false);
2427 }
2364 } 2428 }
2365 2429
2366 @reflectiveTest 2430 @reflectiveTest
2367 class ResolveFunctionBodiesInUnitTaskTest extends _AbstractDartTaskTest { 2431 class ResolveFunctionBodiesInUnitTaskTest extends _AbstractDartTaskTest {
2368 void test_perform() { 2432 void test_perform() {
2369 AnalysisTarget source = newSource( 2433 AnalysisTarget source = newSource(
2370 '/test.dart', 2434 '/test.dart',
2371 ''' 2435 '''
2372 void f() { 2436 void f() {
2373 var c = new C(); 2437 var c = new C();
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
2866 /** 2930 /**
2867 * Fill [errorListener] with [result] errors in the current [task]. 2931 * Fill [errorListener] with [result] errors in the current [task].
2868 */ 2932 */
2869 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 2933 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
2870 List<AnalysisError> errors = task.outputs[result]; 2934 List<AnalysisError> errors = task.outputs[result];
2871 expect(errors, isNotNull, reason: result.name); 2935 expect(errors, isNotNull, reason: result.name);
2872 errorListener = new GatheringErrorListener(); 2936 errorListener = new GatheringErrorListener();
2873 errorListener.addAll(errors); 2937 errorListener.addAll(errors);
2874 } 2938 }
2875 } 2939 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698