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

Side by Side Diff: pkg/analyzer/test/generated/utilities_test.dart

Issue 2081603002: When copying TokenWithComment, use copy of its comments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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/ast/token.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.generated.utilities_test; 5 library analyzer.test.generated.utilities_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 return super.isEqualNodes(first, second); 53 return super.isEqualNodes(first, second);
54 } 54 }
55 55
56 @override 56 @override
57 bool isEqualTokens(Token first, Token second) { 57 bool isEqualTokens(Token first, Token second) {
58 if (expectTokensCopied && first != null && identical(first, second)) { 58 if (expectTokensCopied && first != null && identical(first, second)) {
59 fail('Failed to copy token: ${first.lexeme} (${first.offset})'); 59 fail('Failed to copy token: ${first.lexeme} (${first.offset})');
60 return false; 60 return false;
61 } 61 }
62 if (first is TokenWithComment) {
63 CommentToken comment = first.precedingComments;
64 if (comment.parent != first) {
65 fail('Failed to link the comment "$comment" with the token "$first".');
66 }
67 }
62 return super.isEqualTokens(first, second); 68 return super.isEqualTokens(first, second);
63 } 69 }
64 } 70 }
65 71
66 @reflectiveTest 72 @reflectiveTest
67 class AstClonerTest extends EngineTestCase { 73 class AstClonerTest extends EngineTestCase {
68 void test_visitAdjacentStrings() { 74 void test_visitAdjacentStrings() {
69 _assertCloneExpression("'a' 'b'"); 75 _assertCloneExpression("'a' 'b'");
70 } 76 }
71 77
72 void test_visitAnnotation_constant() { 78 void test_visitAnnotation_constant() {
73 _assertCloneUnitMember('@A main() {}'); 79 _assertCloneUnitMember('@A main() {}');
74 } 80 }
75 81
76 void test_visitAnnotation_constructor() { 82 void test_visitAnnotation_constructor() {
77 _assertCloneUnitMember('@A.c() main() {}'); 83 _assertCloneUnitMember('@A.c() main() {}');
78 } 84 }
79 85
86 void test_visitAnnotation_withComment() {
87 CompilationUnitMember clazz =
88 _parseUnitMember('/** comment */ @deprecated class A {}');
89 Annotation annotation = clazz.metadata.single;
90 _assertClone(annotation);
91 }
92
80 void test_visitArgumentList() { 93 void test_visitArgumentList() {
81 _assertCloneExpression('m(a, b)'); 94 _assertCloneExpression('m(a, b)');
82 } 95 }
83 96
84 void test_visitAsExpression() { 97 void test_visitAsExpression() {
85 _assertCloneExpression('e as T'); 98 _assertCloneExpression('e as T');
86 } 99 }
87 100
88 void test_visitAssertStatement() { 101 void test_visitAssertStatement() {
89 _assertCloneStatement('assert(a);'); 102 _assertCloneStatement('assert(a);');
(...skipping 4277 matching lines...) Expand 10 before | Expand all | Expand 10 after
4367 } 4380 }
4368 4381
4369 void test_get_added() { 4382 void test_get_added() {
4370 TokenMap tokenMap = new TokenMap(); 4383 TokenMap tokenMap = new TokenMap();
4371 Token key = TokenFactory.tokenFromType(TokenType.AT); 4384 Token key = TokenFactory.tokenFromType(TokenType.AT);
4372 Token value = TokenFactory.tokenFromType(TokenType.AT); 4385 Token value = TokenFactory.tokenFromType(TokenType.AT);
4373 tokenMap.put(key, value); 4386 tokenMap.put(key, value);
4374 expect(tokenMap.get(key), same(value)); 4387 expect(tokenMap.get(key), same(value));
4375 } 4388 }
4376 } 4389 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/token.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698