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

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

Issue 1409813002: Fix another place where identifiers were not being re-resolved correctly (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
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 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 usedElements = outputs[USED_IMPORTED_ELEMENTS]; 1905 usedElements = outputs[USED_IMPORTED_ELEMENTS];
1906 usedElementNames = usedElements.elements.map((e) => e.name).toSet(); 1906 usedElementNames = usedElements.elements.map((e) => e.name).toSet();
1907 } 1907 }
1908 } 1908 }
1909 1909
1910 @reflectiveTest 1910 @reflectiveTest
1911 class GatherUsedLocalElementsTaskTest extends _AbstractDartTaskTest { 1911 class GatherUsedLocalElementsTaskTest extends _AbstractDartTaskTest {
1912 UsedLocalElements usedElements; 1912 UsedLocalElements usedElements;
1913 Set<String> usedElementNames; 1913 Set<String> usedElementNames;
1914 1914
1915 fail_perform_forPart_afterLibraryUpdate() { 1915 test_perform_forPart_afterLibraryUpdate() {
1916 Source libSource = newSource( 1916 Source libSource = newSource(
1917 '/my_lib.dart', 1917 '/my_lib.dart',
1918 ''' 1918 '''
1919 library my_lib; 1919 library my_lib;
1920 part 'my_part.dart'; 1920 part 'my_part.dart';
1921 foo() => null; 1921 foo() => null;
1922 class _LocalClass {} 1922 class _LocalClass {}
1923 '''); 1923 ''');
1924 Source partSource = newSource( 1924 Source partSource = newSource(
1925 '/my_part.dart', 1925 '/my_part.dart',
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after
3975 } 3975 }
3976 3976
3977 @reflectiveTest 3977 @reflectiveTest
3978 class StrongModeVerifyUnitTaskTest extends _AbstractDartTaskTest { 3978 class StrongModeVerifyUnitTaskTest extends _AbstractDartTaskTest {
3979 @override 3979 @override
3980 void setUp() { 3980 void setUp() {
3981 super.setUp(); 3981 super.setUp();
3982 enableStrongMode(); 3982 enableStrongMode();
3983 } 3983 }
3984 3984
3985 void test_perform_verifyError() {
3986 enableStrongMode();
3987 AnalysisTarget source = newSource(
3988 '/test.dart',
3989 '''
3990 int topLevel = 3;
3991 class C {
3992 String field = topLevel;
3993 }
3994 ''');
3995 computeResult(new LibrarySpecificUnit(source, source), STRONG_MODE_ERRORS);
3996 // validate
3997 _fillErrorListener(STRONG_MODE_ERRORS);
3998
3999 var errors = errorListener.errors;
4000 expect(errors.length, 1);
4001 expect(errors[0].errorCode.name, "dev_compiler.StaticTypeError");
4002 }
4003
4004 void test_perform_recordDynamicInvoke() { 3985 void test_perform_recordDynamicInvoke() {
4005 enableStrongMode(); 3986 enableStrongMode();
4006 AnalysisTarget source = newSource( 3987 AnalysisTarget source = newSource(
4007 '/test.dart', 3988 '/test.dart',
4008 ''' 3989 '''
4009 void main() { 3990 void main() {
4010 dynamic a = []; 3991 dynamic a = [];
4011 a[0]; 3992 a[0];
4012 } 3993 }
4013 '''); 3994 ''');
4014 computeResult(new LibrarySpecificUnit(source, source), STRONG_MODE_ERRORS); 3995 computeResult(new LibrarySpecificUnit(source, source), STRONG_MODE_ERRORS);
4015 CompilationUnit unit = outputs[RESOLVED_UNIT]; 3996 CompilationUnit unit = outputs[RESOLVED_UNIT];
4016 3997
4017 // validate 3998 // validate
4018 _fillErrorListener(STRONG_MODE_ERRORS); 3999 _fillErrorListener(STRONG_MODE_ERRORS);
4019 expect(errorListener.errors, isEmpty); 4000 expect(errorListener.errors, isEmpty);
4020 4001
4021 List<Statement> statements = getStatementsInTopLevelFunction(unit, "main"); 4002 List<Statement> statements = getStatementsInTopLevelFunction(unit, "main");
4022 ExpressionStatement statement = statements[1]; 4003 ExpressionStatement statement = statements[1];
4023 IndexExpression idx = statement.expression; 4004 IndexExpression idx = statement.expression;
4024 expect(DynamicInvoke.get(idx.target), isNotNull); 4005 expect(DynamicInvoke.get(idx.target), isNotNull);
4025 expect(DynamicInvoke.get(idx.target), isNotNull); 4006 expect(DynamicInvoke.get(idx.target), isNotNull);
4026 expect(DynamicInvoke.get(idx.target), isTrue); 4007 expect(DynamicInvoke.get(idx.target), isTrue);
4027 } 4008 }
4009
4010 void test_perform_verifyError() {
4011 enableStrongMode();
4012 AnalysisTarget source = newSource(
4013 '/test.dart',
4014 '''
4015 int topLevel = 3;
4016 class C {
4017 String field = topLevel;
4018 }
4019 ''');
4020 computeResult(new LibrarySpecificUnit(source, source), STRONG_MODE_ERRORS);
4021 // validate
4022 _fillErrorListener(STRONG_MODE_ERRORS);
4023
4024 var errors = errorListener.errors;
4025 expect(errors.length, 1);
4026 expect(errors[0].errorCode.name, "dev_compiler.StaticTypeError");
4027 }
4028 } 4028 }
4029 4029
4030 @reflectiveTest 4030 @reflectiveTest
4031 class VerifyUnitTaskTest extends _AbstractDartTaskTest { 4031 class VerifyUnitTaskTest extends _AbstractDartTaskTest {
4032 test_perform_constantError() { 4032 test_perform_constantError() {
4033 Source source = newSource( 4033 Source source = newSource(
4034 '/test.dart', 4034 '/test.dart',
4035 ''' 4035 '''
4036 main(int p) { 4036 main(int p) {
4037 const v = p; 4037 const v = p;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
4308 /** 4308 /**
4309 * Fill [errorListener] with [result] errors in the current [task]. 4309 * Fill [errorListener] with [result] errors in the current [task].
4310 */ 4310 */
4311 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 4311 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
4312 List<AnalysisError> errors = task.outputs[result]; 4312 List<AnalysisError> errors = task.outputs[result];
4313 expect(errors, isNotNull, reason: result.name); 4313 expect(errors, isNotNull, reason: result.name);
4314 errorListener = new GatheringErrorListener(); 4314 errorListener = new GatheringErrorListener();
4315 errorListener.addAll(errors); 4315 errorListener.addAll(errors);
4316 } 4316 }
4317 } 4317 }
OLDNEW
« pkg/analyzer/lib/src/task/dart.dart ('K') | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698