From 679e8fd9ff8a76b6e6944fdbc1f3c51d66a09a7b Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 22 Nov 2016 12:46:55 -0800 Subject: [PATCH] Respect the "allowErrors" parameter in _ResynthesizeAstTest.checkLibrary. R=scheglov@google.com Review URL: https://codereview.chromium.org/2527453002 . --- .../src/summary/resynthesize_ast_test.dart | 7 +++++ .../test/src/summary/resynthesize_common.dart | 26 +++++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart b/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart index 276a842b53d..ca4b1f743dd 100644 --- a/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart +++ b/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart @@ -6,6 +6,7 @@ library analyzer.test.src.summary.resynthesize_ast_test; import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/error/error.dart'; import 'package:analyzer/src/dart/element/element.dart'; import 'package:analyzer/src/generated/engine.dart' show AnalysisContext, AnalysisOptionsImpl; @@ -881,6 +882,12 @@ abstract class _ResynthesizeAstTest extends ResynthesizeTest Source source = addTestSource(text); LibraryElementImpl resynthesized = _encodeDecodeLibraryElement(source); LibraryElementImpl original = context.computeLibraryElement(source); + if (!allowErrors) { + List errors = context.computeErrors(source); + if (errors.where((e) => e.message.startsWith('unused')).isNotEmpty) { + fail('Analysis errors: $errors'); + } + } checkLibraryElements(original, resynthesized); return resynthesized; } diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart index 41f5503828f..97fcedc97e1 100644 --- a/pkg/analyzer/test/src/summary/resynthesize_common.dart +++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart @@ -4540,47 +4540,51 @@ typedef F();'''); } test_unresolved_annotation_namedConstructorCall_noClass() { - checkLibrary('@foo.bar() class C {}'); + checkLibrary('@foo.bar() class C {}', allowErrors: true); } test_unresolved_annotation_namedConstructorCall_noConstructor() { - checkLibrary('@String.foo() class C {}'); + checkLibrary('@String.foo() class C {}', allowErrors: true); } test_unresolved_annotation_prefixedIdentifier_badPrefix() { - checkLibrary('@foo.bar class C {}'); + checkLibrary('@foo.bar class C {}', allowErrors: true); } test_unresolved_annotation_prefixedIdentifier_noDeclaration() { - checkLibrary('import "dart:async" as foo; @foo.bar class C {}'); + checkLibrary('import "dart:async" as foo; @foo.bar class C {}', + allowErrors: true); } test_unresolved_annotation_prefixedNamedConstructorCall_badPrefix() { - checkLibrary('@foo.bar.baz() class C {}'); + checkLibrary('@foo.bar.baz() class C {}', allowErrors: true); } test_unresolved_annotation_prefixedNamedConstructorCall_noClass() { - checkLibrary('import "dart:async" as foo; @foo.bar.baz() class C {}'); + checkLibrary('import "dart:async" as foo; @foo.bar.baz() class C {}', + allowErrors: true); } test_unresolved_annotation_prefixedNamedConstructorCall_noConstructor() { - checkLibrary('import "dart:async" as foo; @foo.Future.bar() class C {}'); + checkLibrary('import "dart:async" as foo; @foo.Future.bar() class C {}', + allowErrors: true); } test_unresolved_annotation_prefixedUnnamedConstructorCall_badPrefix() { - checkLibrary('@foo.bar() class C {}'); + checkLibrary('@foo.bar() class C {}', allowErrors: true); } test_unresolved_annotation_prefixedUnnamedConstructorCall_noClass() { - checkLibrary('import "dart:async" as foo; @foo.bar() class C {}'); + checkLibrary('import "dart:async" as foo; @foo.bar() class C {}', + allowErrors: true); } test_unresolved_annotation_simpleIdentifier() { - checkLibrary('@foo class C {}'); + checkLibrary('@foo class C {}', allowErrors: true); } test_unresolved_annotation_unnamedConstructorCall_noClass() { - checkLibrary('@foo() class C {}'); + checkLibrary('@foo() class C {}', allowErrors: true); } test_unresolved_export() {