| 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'; |
| 11 import 'scanner_roundtrip_test.dart' show TestScanner; | 11 import 'scanner_roundtrip_test.dart' show TestScanner; |
| 12 | 12 |
| 13 main() { | 13 main() { |
| 14 defineReflectiveSuite(() { | 14 defineReflectiveSuite(() { |
| 15 defineReflectiveTests(TokenTest); | 15 defineReflectiveTests(TokenTest); |
| 16 }); | 16 }); |
| 17 } | 17 } |
| 18 | 18 |
| 19 /// Assert that fasta PrecedenceInfo implements analyzer TokenType. | 19 /// Assert that fasta PrecedenceInfo implements analyzer TokenType. |
| 20 @reflectiveTest | 20 @reflectiveTest |
| 21 class TokenTest { | 21 class TokenTest { |
| 22 void test_applyDelta() { |
| 23 var scanner = new StringScanner('/* 1 */ foo', includeComments: true); |
| 24 var token = scanner.tokenize(); |
| 25 expect(token.offset, 8); |
| 26 expect(token.precedingComments.offset, 0); |
| 27 token.applyDelta(12); |
| 28 expect(token.offset, 20); |
| 29 expect(token.precedingComments.offset, 12); |
| 30 } |
| 31 |
| 22 void test_comments() { | 32 void test_comments() { |
| 23 var source = ''' | 33 var source = ''' |
| 24 /// Single line dartdoc comment | 34 /// Single line dartdoc comment |
| 25 class Foo { | 35 class Foo { |
| 26 /** | 36 /** |
| 27 * Multi-line dartdoc comment | 37 * Multi-line dartdoc comment |
| 28 */ | 38 */ |
| 29 void bar() { | 39 void bar() { |
| 30 // Single line comment | 40 // Single line comment |
| 31 int x = 0; | 41 int x = 0; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 // General tokens | 211 // General tokens |
| 202 token = token.next; | 212 token = token.next; |
| 203 expect(token.lexeme, '&'); | 213 expect(token.lexeme, '&'); |
| 204 expect(token.value(), '&'); | 214 expect(token.value(), '&'); |
| 205 // String tokens | 215 // String tokens |
| 206 token = token.next; | 216 token = token.next; |
| 207 expect(token.lexeme, '"home"'); | 217 expect(token.lexeme, '"home"'); |
| 208 expect(token.value(), '"home"'); | 218 expect(token.value(), '"home"'); |
| 209 } | 219 } |
| 210 } | 220 } |
| OLD | NEW |