| 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/scanner/error_token.dart' as fasta; | 6 import 'package:front_end/src/fasta/scanner/error_token.dart' as fasta; |
| 7 import 'package:front_end/src/fasta/scanner/keyword.dart' as fasta; | 7 import 'package:front_end/src/fasta/scanner/keyword.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 11 matching lines...) Expand all Loading... |
| 22 defineReflectiveTests(ScannerTest_Fasta_Roundtrip); | 22 defineReflectiveTests(ScannerTest_Fasta_Roundtrip); |
| 23 }); | 23 }); |
| 24 } | 24 } |
| 25 | 25 |
| 26 @reflectiveTest | 26 @reflectiveTest |
| 27 class ScannerTest_Fasta extends ScannerTestBase { | 27 class ScannerTest_Fasta extends ScannerTestBase { |
| 28 @override | 28 @override |
| 29 Token scanWithListener(String source, ErrorListener listener, | 29 Token scanWithListener(String source, ErrorListener listener, |
| 30 {bool genericMethodComments: false, | 30 {bool genericMethodComments: false, |
| 31 bool lazyAssignmentOperators: false}) { | 31 bool lazyAssignmentOperators: false}) { |
| 32 if (genericMethodComments) { | |
| 33 // Fasta doesn't support generic method comments. | |
| 34 // TODO(paulberry): once the analyzer toolchain no longer needs generic | |
| 35 // method comments, remove tests that exercise them. | |
| 36 fail('No generic method comment support in Fasta'); | |
| 37 } | |
| 38 // Note: Fasta always supports lazy assignment operators (`&&=` and `||=`), | 32 // Note: Fasta always supports lazy assignment operators (`&&=` and `||=`), |
| 39 // so we can ignore the `lazyAssignmentOperators` flag. | 33 // so we can ignore the `lazyAssignmentOperators` flag. |
| 40 // TODO(paulberry): once lazyAssignmentOperators are fully supported by | 34 // TODO(paulberry): once lazyAssignmentOperators are fully supported by |
| 41 // Dart, remove this flag. | 35 // Dart, remove this flag. |
| 42 var scanner = new fasta.StringScanner(source, includeComments: true); | 36 var scanner = new fasta.StringScanner(source, includeComments: true); |
| 37 scanner.scanGenericMethodComments = genericMethodComments; |
| 43 var token = scanner.tokenize(); | 38 var token = scanner.tokenize(); |
| 44 return new ToAnalyzerTokenStreamConverter_WithListener(listener) | 39 return new ToAnalyzerTokenStreamConverter_WithListener(listener) |
| 45 .convertTokens(token); | 40 .convertTokens(token); |
| 46 } | 41 } |
| 47 | 42 |
| 48 @override | 43 @override |
| 49 @failingTest | 44 @failingTest |
| 50 void test_ampersand_ampersand_eq() { | 45 void test_ampersand_ampersand_eq() { |
| 51 // TODO(paulberry,ahe): Fasta doesn't support `&&=` yet | 46 // TODO(paulberry,ahe): Fasta doesn't support `&&=` yet |
| 52 super.test_ampersand_ampersand_eq(); | 47 super.test_ampersand_ampersand_eq(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 token = token.next; | 131 token = token.next; |
| 137 } | 132 } |
| 138 expect(tokenCount, 26); | 133 expect(tokenCount, 26); |
| 139 expect(spotCheckCount, 3); | 134 expect(spotCheckCount, 3); |
| 140 expect(commentTokenCount, 9); | 135 expect(commentTokenCount, 9); |
| 141 expect(token.precedingComments?.lexeme, '// EOF comment'); | 136 expect(token.precedingComments?.lexeme, '// EOF comment'); |
| 142 } | 137 } |
| 143 | 138 |
| 144 @override | 139 @override |
| 145 @failingTest | 140 @failingTest |
| 146 void test_comment_generic_method_type_assign() { | |
| 147 // TODO(paulberry,ahe): Fasta doesn't support generic method comment syntax. | |
| 148 super.test_comment_generic_method_type_assign(); | |
| 149 } | |
| 150 | |
| 151 @override | |
| 152 @failingTest | |
| 153 void test_comment_generic_method_type_list() { | |
| 154 // TODO(paulberry,ahe): Fasta doesn't support generic method comment syntax. | |
| 155 super.test_comment_generic_method_type_list(); | |
| 156 } | |
| 157 | |
| 158 @override | |
| 159 @failingTest | |
| 160 void test_mismatched_closer() { | 141 void test_mismatched_closer() { |
| 161 // TODO(paulberry,ahe): Fasta and analyzer recover this error differently. | 142 // TODO(paulberry,ahe): Fasta and analyzer recover this error differently. |
| 162 // Figure out which recovery technique we want the front end to use. | 143 // Figure out which recovery technique we want the front end to use. |
| 163 super.test_mismatched_closer(); | 144 super.test_mismatched_closer(); |
| 164 } | 145 } |
| 165 | 146 |
| 166 @override | 147 @override |
| 167 @failingTest | 148 @failingTest |
| 168 void test_mismatched_opener() { | 149 void test_mismatched_opener() { |
| 169 // TODO(paulberry,ahe): Fasta and analyzer recover this error differently. | 150 // TODO(paulberry,ahe): Fasta and analyzer recover this error differently. |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 final ErrorListener _listener; | 497 final ErrorListener _listener; |
| 517 | 498 |
| 518 ToAnalyzerTokenStreamConverter_WithListener(this._listener); | 499 ToAnalyzerTokenStreamConverter_WithListener(this._listener); |
| 519 | 500 |
| 520 @override | 501 @override |
| 521 void reportError( | 502 void reportError( |
| 522 ScannerErrorCode errorCode, int offset, List<Object> arguments) { | 503 ScannerErrorCode errorCode, int offset, List<Object> arguments) { |
| 523 _listener.errors.add(new TestError(offset, errorCode, arguments)); | 504 _listener.errors.add(new TestError(offset, errorCode, arguments)); |
| 524 } | 505 } |
| 525 } | 506 } |
| OLD | NEW |