| 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:analyzer/src/fasta/token_utils.dart'; | 5 import 'package:analyzer/src/fasta/token_utils.dart'; |
| 6 import 'package:front_end/src/fasta/fasta_codes.dart'; | 6 import 'package:front_end/src/fasta/fasta_codes.dart'; |
| 7 import 'package:front_end/src/fasta/scanner/error_token.dart' as fasta; | 7 import 'package:front_end/src/fasta/scanner/error_token.dart' as fasta; |
| 8 import 'package:front_end/src/fasta/scanner/string_scanner.dart' as fasta; | 8 import 'package:front_end/src/fasta/scanner/string_scanner.dart' as fasta; |
| 9 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; | 9 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; |
| 10 import 'package:front_end/src/fasta/scanner/token_constants.dart' as fasta; | 10 import 'package:front_end/src/fasta/scanner/token_constants.dart' as fasta; |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 /// Scanner tests that exercise the Fasta scanner directly. | 495 /// Scanner tests that exercise the Fasta scanner directly. |
| 496 @reflectiveTest | 496 @reflectiveTest |
| 497 class ScannerTest_Fasta_Direct extends ScannerTest_Fasta_Base { | 497 class ScannerTest_Fasta_Direct extends ScannerTest_Fasta_Base { |
| 498 @override | 498 @override |
| 499 Token scan(String source) { | 499 Token scan(String source) { |
| 500 var scanner = new fasta.StringScanner(source, includeComments: true); | 500 var scanner = new fasta.StringScanner(source, includeComments: true); |
| 501 return scanner.tokenize(); | 501 return scanner.tokenize(); |
| 502 } | 502 } |
| 503 | 503 |
| 504 void test_linestarts() { |
| 505 var scanner = new fasta.StringScanner("var\r\ni\n=\n1;\n"); |
| 506 var token = scanner.tokenize(); |
| 507 expect(token.lexeme, 'var'); |
| 508 var lineStarts = scanner.lineStarts; |
| 509 expect(lineStarts, orderedEquals([0, 5, 7, 9, 12, 13])); |
| 510 } |
| 511 |
| 504 test_unterminated_string_with_unterminated_interpolation() { | 512 test_unterminated_string_with_unterminated_interpolation() { |
| 505 Token token = scan(r'"foo ${bar'); | 513 Token token = scan(r'"foo ${bar'); |
| 506 BeginToken interpolationStart = token.next; | 514 BeginToken interpolationStart = token.next; |
| 507 | 515 |
| 508 Token previous; | 516 Token previous; |
| 509 while (token.kind != fasta.BAD_INPUT_TOKEN) { | 517 while (token.kind != fasta.BAD_INPUT_TOKEN) { |
| 510 expect(token.isEof, isFalse); | 518 expect(token.isEof, isFalse); |
| 511 previous = token; | 519 previous = token; |
| 512 token = token.next; | 520 token = token.next; |
| 513 } | 521 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 final ErrorListener _listener; | 554 final ErrorListener _listener; |
| 547 | 555 |
| 548 ToAnalyzerTokenStreamConverter_WithListener(this._listener); | 556 ToAnalyzerTokenStreamConverter_WithListener(this._listener); |
| 549 | 557 |
| 550 @override | 558 @override |
| 551 void reportError( | 559 void reportError( |
| 552 ScannerErrorCode errorCode, int offset, List<Object> arguments) { | 560 ScannerErrorCode errorCode, int offset, List<Object> arguments) { |
| 553 _listener.errors.add(new TestError(offset, errorCode, arguments)); | 561 _listener.errors.add(new TestError(offset, errorCode, arguments)); |
| 554 } | 562 } |
| 555 } | 563 } |
| OLD | NEW |