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

Unified Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1798993003: Added tests; improved test output; code clean-up (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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',
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698