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

Side by Side Diff: pkg/analyzer/test/src/dart/constant/utilities_test.dart

Issue 1958433002: Do not fail when an enum constant is annotated (issue 26413) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « pkg/analyzer/lib/src/dart/constant/utilities.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 analyzer.test.src.dart.constant.utilities_test; 5 library analyzer.test.src.dart.constant.utilities_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/dart/ast/token.dart'; 10 import 'package:analyzer/src/dart/ast/token.dart';
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ElementFactory.compilationUnit('/test.dart', _source)..source = _source; 54 ElementFactory.compilationUnit('/test.dart', _source)..source = _source;
55 ElementFactory.library(_context, 'L').definingCompilationUnit = 55 ElementFactory.library(_context, 'L').definingCompilationUnit =
56 compilationUnitElement; 56 compilationUnitElement;
57 ElementAnnotationImpl elementAnnotation = 57 ElementAnnotationImpl elementAnnotation =
58 new ElementAnnotationImpl(compilationUnitElement); 58 new ElementAnnotationImpl(compilationUnitElement);
59 _node = elementAnnotation.annotationAst = AstFactory.annotation( 59 _node = elementAnnotation.annotationAst = AstFactory.annotation(
60 AstFactory.identifier3('x'))..elementAnnotation = elementAnnotation; 60 AstFactory.identifier3('x'))..elementAnnotation = elementAnnotation;
61 expect(_findAnnotations(), contains(_node)); 61 expect(_findAnnotations(), contains(_node));
62 } 62 }
63 63
64 void test_visitAnnotation_enumConstant() {
65 // Analyzer ignores annotations on enum constant declarations.
66 Annotation annotation = AstFactory.annotation2(
67 AstFactory.identifier3('A'), null, AstFactory.argumentList());
68 _node = new EnumConstantDeclaration(
69 null, <Annotation>[annotation], AstFactory.identifier3('C'));
70 expect(_findConstants(), isEmpty);
71 }
72
64 /** 73 /**
65 * Test an annotation that represents the invocation of a constant 74 * Test an annotation that represents the invocation of a constant
66 * constructor. 75 * constructor.
67 */ 76 */
68 void test_visitAnnotation_invocation() { 77 void test_visitAnnotation_invocation() {
69 CompilationUnitElement compilationUnitElement = 78 CompilationUnitElement compilationUnitElement =
70 ElementFactory.compilationUnit('/test.dart', _source)..source = _source; 79 ElementFactory.compilationUnit('/test.dart', _source)..source = _source;
71 ElementFactory.library(_context, 'L').definingCompilationUnit = 80 ElementFactory.library(_context, 'L').definingCompilationUnit =
72 compilationUnitElement; 81 compilationUnitElement;
73 ElementAnnotationImpl elementAnnotation = 82 ElementAnnotationImpl elementAnnotation =
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 354
346 void _visitNode(AstNode node) { 355 void _visitNode(AstNode node) {
347 node.accept(_createReferenceFinder(_head)); 356 node.accept(_createReferenceFinder(_head));
348 } 357 }
349 } 358 }
350 359
351 class _TestAnalysisContext extends TestAnalysisContext { 360 class _TestAnalysisContext extends TestAnalysisContext {
352 @override 361 @override
353 InternalAnalysisContext getContextFor(Source source) => this; 362 InternalAnalysisContext getContextFor(Source source) => this;
354 } 363 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/constant/utilities.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698