OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; | 5 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; |
6 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; | 6 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; |
7 import 'package:front_end/src/scanner/token.dart'; | 7 import 'package:front_end/src/scanner/token.dart'; |
8 import 'package:front_end/src/scanner/reader.dart' as analyzer; | 8 import 'package:front_end/src/scanner/reader.dart' as analyzer; |
9 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 Token comment = token.precedingComments; | 52 Token comment = token.precedingComments; |
53 token = token.next; | 53 token = token.next; |
54 if (comment != null) return comment; | 54 if (comment != null) return comment; |
55 } | 55 } |
56 return null; | 56 return null; |
57 } | 57 } |
58 | 58 |
59 fasta.Token comment = nextComment(); | 59 fasta.Token comment = nextComment(); |
60 expect(comment.lexeme, contains('Single line dartdoc comment')); | 60 expect(comment.lexeme, contains('Single line dartdoc comment')); |
61 expect(comment.type, TokenType.SINGLE_LINE_COMMENT); | 61 expect(comment.type, TokenType.SINGLE_LINE_COMMENT); |
| 62 expect(comment, new isInstanceOf<DocumentationCommentToken>()); |
62 | 63 |
63 comment = nextComment(); | 64 comment = nextComment(); |
64 expect(comment.lexeme, contains('Multi-line dartdoc comment')); | 65 expect(comment.lexeme, contains('Multi-line dartdoc comment')); |
65 expect(comment.type, TokenType.MULTI_LINE_COMMENT); | 66 expect(comment.type, TokenType.MULTI_LINE_COMMENT); |
| 67 expect(comment, new isInstanceOf<DocumentationCommentToken>()); |
66 | 68 |
67 comment = nextComment(); | 69 comment = nextComment(); |
68 expect(comment.lexeme, contains('Single line comment')); | 70 expect(comment.lexeme, contains('Single line comment')); |
69 expect(comment.type, TokenType.SINGLE_LINE_COMMENT); | 71 expect(comment.type, TokenType.SINGLE_LINE_COMMENT); |
| 72 expect(comment, new isInstanceOf<CommentToken>()); |
70 | 73 |
71 comment = nextComment(); | 74 comment = nextComment(); |
72 expect(comment.lexeme, contains('Multi-line comment')); | 75 expect(comment.lexeme, contains('Multi-line comment')); |
73 expect(comment.type, TokenType.MULTI_LINE_COMMENT); | 76 expect(comment.type, TokenType.MULTI_LINE_COMMENT); |
| 77 expect(comment, new isInstanceOf<CommentToken>()); |
74 } | 78 } |
75 | 79 |
76 void test_copy() { | 80 void test_copy() { |
77 String source = '/* 1 */ /* 2 */ main() {print("hello"); return;}'; | 81 String source = '/* 1 */ /* 2 */ main() {print("hello"); return;}'; |
78 int commentCount = 0; | 82 int commentCount = 0; |
79 | 83 |
80 void assertCopiedToken(Token token1, Token token2) { | 84 void assertCopiedToken(Token token1, Token token2) { |
81 if (token1 == null) { | 85 if (token1 == null) { |
82 expect(token2, isNull); | 86 expect(token2, isNull); |
83 return; | 87 return; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 token = token.next; | 164 token = token.next; |
161 expect(token.lexeme, '&'); | 165 expect(token.lexeme, '&'); |
162 expect(token.value(), '&'); | 166 expect(token.value(), '&'); |
163 // String tokens | 167 // String tokens |
164 token = token.next; | 168 token = token.next; |
165 print('String token :: ${token.runtimeType}'); | 169 print('String token :: ${token.runtimeType}'); |
166 expect(token.lexeme, '"home"'); | 170 expect(token.lexeme, '"home"'); |
167 expect(token.value(), '"home"'); | 171 expect(token.value(), '"home"'); |
168 } | 172 } |
169 } | 173 } |
OLD | NEW |