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

Unified Diff: pkg/front_end/test/token_test.dart

Issue 2757153002: update fasta scanner to generate two types of comments (Closed)
Patch Set: rebase Created 3 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/front_end/test/precedence_info_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/test/token_test.dart
diff --git a/pkg/front_end/test/token_test.dart b/pkg/front_end/test/token_test.dart
index 8f8a20a9058441c7d82117271074142de99281e8..3570fb3d2e120cf416d66ef78680a050abd64ad3 100644
--- a/pkg/front_end/test/token_test.dart
+++ b/pkg/front_end/test/token_test.dart
@@ -29,6 +29,50 @@ class TokenTest {
expect(token.precedingComments.offset, 12);
}
+ void test_comments() {
+ var source = '''
+/// Single line dartdoc comment
+class Foo {
+ /**
+ * Multi-line dartdoc comment
+ */
+ void bar() {
+ // Single line comment
+ int x = 0;
+ /* Multi-line comment */
+ x = x + 1;
+ }
+}
+''';
+ var scanner = new StringScanner(source, includeComments: true);
+ fasta.Token token = scanner.tokenize();
+
+ Token nextComment() {
+ while (!token.isEof) {
+ Token comment = token.precedingComments;
+ token = token.next;
+ if (comment != null) return comment;
+ }
+ return null;
+ }
+
+ fasta.Token comment = nextComment();
+ expect(comment.lexeme, contains('Single line dartdoc comment'));
+ expect(comment.type, TokenType.SINGLE_LINE_COMMENT);
+
+ comment = nextComment();
+ expect(comment.lexeme, contains('Multi-line dartdoc comment'));
+ expect(comment.type, TokenType.MULTI_LINE_COMMENT);
+
+ comment = nextComment();
+ expect(comment.lexeme, contains('Single line comment'));
+ expect(comment.type, TokenType.SINGLE_LINE_COMMENT);
+
+ comment = nextComment();
+ expect(comment.lexeme, contains('Multi-line comment'));
+ expect(comment.type, TokenType.MULTI_LINE_COMMENT);
+ }
+
void test_copy() {
String source = '/* 1 */ /* 2 */ main() {print("hello"); return;}';
int commentCount = 0;
« no previous file with comments | « pkg/front_end/test/precedence_info_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698