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/scanner/errors.dart' as analyzer; | 6 import 'package:front_end/src/scanner/errors.dart' as analyzer; |
7 import 'package:front_end/src/scanner/reader.dart' as analyzer; | 7 import 'package:front_end/src/scanner/reader.dart' as analyzer; |
8 import 'package:front_end/src/scanner/scanner.dart' as analyzer; | 8 import 'package:front_end/src/scanner/scanner.dart' as analyzer; |
9 import 'package:front_end/src/scanner/token.dart'; | 9 import 'package:front_end/src/scanner/token.dart'; |
10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
11 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 11 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
12 | 12 |
13 import 'scanner_fasta_test.dart'; | 13 import 'scanner_fasta_test.dart'; |
14 import 'scanner_test.dart'; | 14 import 'scanner_test.dart'; |
15 | 15 |
16 main() { | 16 main() { |
17 defineReflectiveSuite(() { | 17 // round trip test removed |
ahe
2017/05/24 21:32:00
Shouldn't you just delete this file?
danrubel
2017/05/25 01:08:15
Good point. Done.
https://codereview.chromium.org/
| |
18 defineReflectiveTests(ScannerTest_RoundTrip); | |
19 }); | |
20 } | |
21 | |
22 /// Scanner tests that use the analyzer scanner, then convert the resulting | |
23 /// token stream into a Fasta token stream, then convert back to an analyzer | |
24 /// token stream before verifying assertions. | |
25 /// | |
26 /// These tests help to validate the correctness of the analyzer->Fasta token | |
27 /// stream conversion. | |
28 @reflectiveTest | |
29 class ScannerTest_RoundTrip extends ScannerTest { | |
30 @override | |
31 Token scanWithListener(String source, ErrorListener listener, | |
32 {bool genericMethodComments: false, | |
33 bool lazyAssignmentOperators: false}) { | |
34 var analyzerToken = super.scanWithListener(source, listener, | |
35 genericMethodComments: genericMethodComments, | |
36 lazyAssignmentOperators: lazyAssignmentOperators); | |
37 var fastaToken = fromAnalyzerTokenStream(analyzerToken); | |
38 // Since [scanWithListener] reports errors to the listener, we don't | |
39 // expect any error tokens in the Fasta token stream, so we convert using | |
40 // ToAnalyzerTokenStreamConverter_NoErrors. | |
41 return new ToAnalyzerTokenStreamConverter_NoErrors() | |
42 .convertTokens(fastaToken); | |
43 } | |
44 } | 18 } |
45 | 19 |
46 class TestScanner extends analyzer.Scanner { | 20 class TestScanner extends analyzer.Scanner { |
47 TestScanner(analyzer.CharacterReader reader) : super.create(reader); | 21 TestScanner(analyzer.CharacterReader reader) : super.create(reader); |
48 | 22 |
49 @override | 23 @override |
50 void reportError( | 24 void reportError( |
51 analyzer.ScannerErrorCode errorCode, int offset, List<Object> arguments) { | 25 analyzer.ScannerErrorCode errorCode, int offset, List<Object> arguments) { |
52 fail('Unexpected error $errorCode while scanning offset $offset\n' | 26 fail('Unexpected error $errorCode while scanning offset $offset\n' |
53 ' arguments: $arguments'); | 27 ' arguments: $arguments'); |
54 } | 28 } |
55 } | 29 } |
OLD | NEW |