| Index: pkg/analyzer/test/src/task/dart_test.dart
|
| diff --git a/pkg/analyzer/test/src/task/dart_test.dart b/pkg/analyzer/test/src/task/dart_test.dart
|
| index 599485d4bbe3c89a59dd1c1f6c17326465a70cff..d98ceed2f45bd0ab00799f54c40167330d584dc1 100644
|
| --- a/pkg/analyzer/test/src/task/dart_test.dart
|
| +++ b/pkg/analyzer/test/src/task/dart_test.dart
|
| @@ -4794,6 +4794,42 @@ main(int p) {
|
| ]);
|
| }
|
|
|
| + test_perform_ConstantValidator_declaredIdentifier() {
|
| + Source source = newSource(
|
| + '/test.dart',
|
| + '''
|
| +void main() {
|
| + for (const foo in []) {
|
| + print(foo);
|
| + }
|
| +}
|
| +''');
|
| + LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
|
| + computeResult(target, VERIFY_ERRORS, matcher: isVerifyUnitTask);
|
| + // validate
|
| + _fillErrorListener(VERIFY_ERRORS);
|
| + errorListener.assertNoErrors();
|
| + }
|
| +
|
| + test_perform_ConstantValidator_dependencyCycle() {
|
| + Source source = newSource(
|
| + '/test.dart',
|
| + '''
|
| +const int a = b;
|
| +const int b = c;
|
| +const int c = a;
|
| +''');
|
| + LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
|
| + computeResult(target, VERIFY_ERRORS, matcher: isVerifyUnitTask);
|
| + // validate
|
| + _fillErrorListener(VERIFY_ERRORS);
|
| + errorListener.assertErrorsWithCodes(<ErrorCode>[
|
| + CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT,
|
| + CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT,
|
| + CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT
|
| + ]);
|
| + }
|
| +
|
| test_perform_ConstantValidator_duplicateFields() {
|
| Source source = newSource(
|
| '/test.dart',
|
| @@ -4815,6 +4851,38 @@ main() {
|
| errorListener.assertNoErrors();
|
| }
|
|
|
| + test_perform_ConstantValidator_noInitializer() {
|
| + Source source = newSource(
|
| + '/test.dart',
|
| + '''
|
| +const x;
|
| +''');
|
| + LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
|
| + computeResult(target, VERIFY_ERRORS, matcher: isVerifyUnitTask);
|
| + // validate
|
| + _fillErrorListener(VERIFY_ERRORS);
|
| + errorListener.assertErrorsWithCodes(
|
| + <ErrorCode>[CompileTimeErrorCode.CONST_NOT_INITIALIZED]);
|
| + }
|
| +
|
| + test_perform_ConstantValidator_unknownValue() {
|
| + Source source = newSource(
|
| + '/test.dart',
|
| + '''
|
| +import 'no-such-file.dart' as p;
|
| +
|
| +const int x = p.y;
|
| +''');
|
| + LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
|
| + computeResult(target, VERIFY_ERRORS, matcher: isVerifyUnitTask);
|
| + // validate
|
| + _fillErrorListener(VERIFY_ERRORS);
|
| + errorListener.assertErrorsWithCodes(<ErrorCode>[
|
| + CompileTimeErrorCode.URI_DOES_NOT_EXIST,
|
| + CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
|
| + ]);
|
| + }
|
| +
|
| test_perform_directiveError() {
|
| Source source = newSource(
|
| '/test.dart',
|
|
|