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

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

Issue 1131383008: Generate the proper error when a constant refers to itself. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 expect(outputs[CONSTANT_VALUE], same(target)); 1305 expect(outputs[CONSTANT_VALUE], same(target));
1306 EvaluationResultImpl evaluationResult = 1306 EvaluationResultImpl evaluationResult =
1307 (annotation.elementAnnotation as ElementAnnotationImpl).evaluationRe sult; 1307 (annotation.elementAnnotation as ElementAnnotationImpl).evaluationRe sult;
1308 return evaluationResult; 1308 return evaluationResult;
1309 } 1309 }
1310 } 1310 }
1311 fail('Annotation not found'); 1311 fail('Annotation not found');
1312 return null; 1312 return null;
1313 } 1313 }
1314 1314
1315 fail_circular_reference_one_element() {
1316 // See dartbug.com/23490.
1317 _checkCircularities('x', [], 'const x = x;');
1318 }
1319
1320 test_annotation_with_args() { 1315 test_annotation_with_args() {
1321 Source source = newSource('/test.dart', ''' 1316 Source source = newSource('/test.dart', '''
1322 const x = 1; 1317 const x = 1;
1323 @D(x) class C {} 1318 @D(x) class C {}
1324 class D { 1319 class D {
1325 const D(this.value); 1320 const D(this.value);
1326 final value; 1321 final value;
1327 } 1322 }
1328 '''); 1323 ''');
1329 // First compute the resolved unit for the source. 1324 // First compute the resolved unit for the source.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 expect(evaluationResult.value.intValue, 1); 1357 expect(evaluationResult.value.intValue, 1);
1363 } 1358 }
1364 1359
1365 test_circular_reference() { 1360 test_circular_reference() {
1366 _checkCircularities('x', ['y'], ''' 1361 _checkCircularities('x', ['y'], '''
1367 const x = y + 1; 1362 const x = y + 1;
1368 const y = x + 1; 1363 const y = x + 1;
1369 '''); 1364 ''');
1370 } 1365 }
1371 1366
1367 test_circular_reference_one_element() {
1368 // See dartbug.com/23490.
1369 _checkCircularities('x', [], 'const x = x;');
1370 }
1371
1372 test_circular_reference_strongly_connected_component() { 1372 test_circular_reference_strongly_connected_component() {
1373 // When there is a circularity, all elements in the strongly connected 1373 // When there is a circularity, all elements in the strongly connected
1374 // component should be marked as having an error. 1374 // component should be marked as having an error.
1375 _checkCircularities('a', ['b', 'c', 'd'], ''' 1375 _checkCircularities('a', ['b', 'c', 'd'], '''
1376 const a = b; 1376 const a = b;
1377 const b = c + d; 1377 const b = c + d;
1378 const c = a; 1378 const c = a;
1379 const d = a; 1379 const d = a;
1380 '''); 1380 ''');
1381 } 1381 }
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 /** 2457 /**
2458 * Fill [errorListener] with [result] errors in the current [task]. 2458 * Fill [errorListener] with [result] errors in the current [task].
2459 */ 2459 */
2460 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 2460 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
2461 List<AnalysisError> errors = task.outputs[result]; 2461 List<AnalysisError> errors = task.outputs[result];
2462 expect(errors, isNotNull, reason: result.name); 2462 expect(errors, isNotNull, reason: result.name);
2463 errorListener = new GatheringErrorListener(); 2463 errorListener = new GatheringErrorListener();
2464 errorListener.addAll(errors); 2464 errorListener.addAll(errors);
2465 } 2465 }
2466 } 2466 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/compile_time_error_code_test.dart ('k') | pkg/analyzer/test/src/task/driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698