OLD | NEW |
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.scanner_test; | 5 library analyzer.test.generated.scanner_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/token.dart'; | 7 import 'package:analyzer/dart/ast/token.dart'; |
8 import 'package:analyzer/src/dart/ast/token.dart'; | 8 import 'package:analyzer/src/dart/ast/token.dart'; |
9 import 'package:analyzer/src/dart/scanner/reader.dart'; | 9 import 'package:analyzer/src/dart/scanner/reader.dart'; |
10 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 10 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
11 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
| 12 import 'package:front_end/src/scanner/scanner.dart' as fe; |
12 import 'package:test/test.dart'; | 13 import 'package:test/test.dart'; |
13 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 14 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
14 | 15 |
15 import 'test_support.dart'; | 16 import 'test_support.dart'; |
16 | 17 |
17 main() { | 18 main() { |
18 defineReflectiveSuite(() { | 19 defineReflectiveSuite(() { |
19 defineReflectiveTests(LineInfoTest); | 20 defineReflectiveTests(LineInfoTest); |
20 }); | 21 }); |
21 } | 22 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 125 } |
125 | 126 |
126 void test_linestarts() { | 127 void test_linestarts() { |
127 String source = "var\r\ni\n=\n1;\n"; | 128 String source = "var\r\ni\n=\n1;\n"; |
128 GatheringErrorListener listener = new GatheringErrorListener(); | 129 GatheringErrorListener listener = new GatheringErrorListener(); |
129 Scanner scanner = | 130 Scanner scanner = |
130 new Scanner(null, new CharSequenceReader(source), listener); | 131 new Scanner(null, new CharSequenceReader(source), listener); |
131 var token = scanner.tokenize(); | 132 var token = scanner.tokenize(); |
132 expect(token.lexeme, 'var'); | 133 expect(token.lexeme, 'var'); |
133 var lineStarts = scanner.lineStarts; | 134 var lineStarts = scanner.lineStarts; |
134 expect(lineStarts, orderedEquals([0, 5, 7, 9, 11])); | 135 expect( |
| 136 lineStarts, orderedEquals([0, 5, 7, 9, fe.Scanner.useFasta ? 12 : 11])); |
135 } | 137 } |
136 | 138 |
137 void _assertLineInfo( | 139 void _assertLineInfo( |
138 String source, List<ScannerTest_ExpectedLocation> expectedLocations) { | 140 String source, List<ScannerTest_ExpectedLocation> expectedLocations) { |
139 GatheringErrorListener listener = new GatheringErrorListener(); | 141 GatheringErrorListener listener = new GatheringErrorListener(); |
140 _scanWithListener(source, listener); | 142 _scanWithListener(source, listener); |
141 listener.assertNoErrors(); | 143 listener.assertNoErrors(); |
142 LineInfo info = listener.getLineInfo(new TestSource()); | 144 LineInfo info = listener.getLineInfo(new TestSource()); |
143 expect(info, isNotNull); | 145 expect(info, isNotNull); |
144 int count = expectedLocations.length; | 146 int count = expectedLocations.length; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 buffer.write(token.type); | 240 buffer.write(token.type); |
239 buffer.write(", '"); | 241 buffer.write(", '"); |
240 buffer.write(token.lexeme); | 242 buffer.write(token.lexeme); |
241 buffer.write("', "); | 243 buffer.write("', "); |
242 buffer.write(token.offset); | 244 buffer.write(token.offset); |
243 buffer.write(", "); | 245 buffer.write(", "); |
244 buffer.write(token.length); | 246 buffer.write(token.length); |
245 buffer.write("]"); | 247 buffer.write("]"); |
246 } | 248 } |
247 } | 249 } |
OLD | NEW |