Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: pkg/analyzer/test/generated/parser_fasta_test.dart

Issue 3007943002: gracefully recover from extraneous top level modifiers (Closed)
Patch Set: address comments Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/ast/token.dart' as analyzer; 6 import 'package:analyzer/dart/ast/token.dart' as analyzer;
7 import 'package:analyzer/dart/ast/token.dart' show TokenType; 7 import 'package:analyzer/dart/ast/token.dart' show TokenType;
8 import 'package:analyzer/error/error.dart'; 8 import 'package:analyzer/error/error.dart';
9 import 'package:analyzer/error/listener.dart' show ErrorReporter; 9 import 'package:analyzer/error/listener.dart' show ErrorReporter;
10 import 'package:analyzer/src/dart/scanner/scanner.dart'; 10 import 'package:analyzer/src/dart/scanner/scanner.dart';
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 @override 198 @override
199 @failingTest 199 @failingTest
200 void test_constAndVar() { 200 void test_constAndVar() {
201 super.test_constAndVar(); 201 super.test_constAndVar();
202 } 202 }
203 203
204 @override 204 @override
205 @failingTest 205 @failingTest
206 void test_constClass() { 206 void test_constClass() {
207 // TODO(danrubel): Rather than reporting ParserErrorCode.EXTRANEOUS_MODIFIER
208 // report ParserErrorCode.CONST_CLASS to better help the user
207 super.test_constClass(); 209 super.test_constClass();
208 } 210 }
209 211
210 @override 212 @override
211 @failingTest 213 @failingTest
212 void test_constConstructorWithBody() { 214 void test_constConstructorWithBody() {
213 super.test_constConstructorWithBody(); 215 super.test_constConstructorWithBody();
214 } 216 }
215 217
216 @override 218 @override
217 @failingTest 219 @failingTest
218 void test_constEnum() {
219 super.test_constEnum();
220 }
221
222 @override
223 @failingTest
224 void test_constFactory() { 220 void test_constFactory() {
225 super.test_constFactory(); 221 super.test_constFactory();
226 } 222 }
227 223
228 @override 224 @override
229 @failingTest 225 @failingTest
230 void test_constMethod() { 226 void test_constMethod() {
231 super.test_constMethod(); 227 super.test_constMethod();
232 } 228 }
233 229
234 @override 230 @override
235 @failingTest 231 @failingTest
236 void test_constructorWithReturnType() { 232 void test_constructorWithReturnType() {
237 super.test_constructorWithReturnType(); 233 super.test_constructorWithReturnType();
238 } 234 }
239 235
240 @override 236 @override
241 @failingTest 237 @failingTest
242 void test_constructorWithReturnType_var() { 238 void test_constructorWithReturnType_var() {
243 super.test_constructorWithReturnType_var(); 239 super.test_constructorWithReturnType_var();
244 } 240 }
245 241
246 @override 242 @override
247 @failingTest 243 @failingTest
248 void test_constTypedef() {
249 super.test_constTypedef();
250 }
251
252 @override
253 @failingTest
254 void test_continueOutsideOfLoop_continueInDoStatement() { 244 void test_continueOutsideOfLoop_continueInDoStatement() {
255 super.test_continueOutsideOfLoop_continueInDoStatement(); 245 super.test_continueOutsideOfLoop_continueInDoStatement();
256 } 246 }
257 247
258 @override 248 @override
259 @failingTest 249 @failingTest
260 void test_continueOutsideOfLoop_continueInForStatement() { 250 void test_continueOutsideOfLoop_continueInForStatement() {
261 super.test_continueOutsideOfLoop_continueInForStatement(); 251 super.test_continueOutsideOfLoop_continueInForStatement();
262 } 252 }
263 253
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 } 750 }
761 751
762 @override 752 @override
763 @failingTest 753 @failingTest
764 void test_finalAndVar() { 754 void test_finalAndVar() {
765 super.test_finalAndVar(); 755 super.test_finalAndVar();
766 } 756 }
767 757
768 @override 758 @override
769 @failingTest 759 @failingTest
770 void test_finalClass() {
771 super.test_finalClass();
772 }
773
774 @override
775 @failingTest
776 void test_finalConstructor() { 760 void test_finalConstructor() {
777 super.test_finalConstructor(); 761 super.test_finalConstructor();
778 } 762 }
779 763
780 @override 764 @override
781 @failingTest 765 @failingTest
782 void test_finalEnum() {
783 super.test_finalEnum();
784 }
785
786 @override
787 @failingTest
788 void test_finalMethod() { 766 void test_finalMethod() {
789 super.test_finalMethod(); 767 super.test_finalMethod();
790 } 768 }
791 769
792 @override 770 @override
793 @failingTest 771 @failingTest
794 void test_finalTypedef() {
795 super.test_finalTypedef();
796 }
797
798 @override
799 @failingTest
800 void test_functionTypedParameter_const() { 772 void test_functionTypedParameter_const() {
801 super.test_functionTypedParameter_const(); 773 super.test_functionTypedParameter_const();
802 } 774 }
803 775
804 @override 776 @override
805 @failingTest 777 @failingTest
806 void test_functionTypedParameter_final() { 778 void test_functionTypedParameter_final() {
807 super.test_functionTypedParameter_final(); 779 super.test_functionTypedParameter_final();
808 } 780 }
809 781
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 } 1621 }
1650 1622
1651 @override 1623 @override
1652 @failingTest 1624 @failingTest
1653 void test_staticSetterWithoutBody() { 1625 void test_staticSetterWithoutBody() {
1654 super.test_staticSetterWithoutBody(); 1626 super.test_staticSetterWithoutBody();
1655 } 1627 }
1656 1628
1657 @override 1629 @override
1658 @failingTest 1630 @failingTest
1659 void test_staticTopLevelDeclaration_class() {
1660 super.test_staticTopLevelDeclaration_class();
1661 }
1662
1663 @override
1664 @failingTest
1665 void test_staticTopLevelDeclaration_enum() {
1666 super.test_staticTopLevelDeclaration_enum();
1667 }
1668
1669 @override
1670 @failingTest
1671 void test_staticTopLevelDeclaration_function() {
1672 super.test_staticTopLevelDeclaration_function();
1673 }
1674
1675 @override
1676 @failingTest
1677 void test_staticTopLevelDeclaration_typedef() {
1678 super.test_staticTopLevelDeclaration_typedef();
1679 }
1680
1681 @override
1682 @failingTest
1683 void test_staticTopLevelDeclaration_variable() {
1684 super.test_staticTopLevelDeclaration_variable();
1685 }
1686
1687 @override
1688 @failingTest
1689 void test_string_unterminated_interpolation_block() { 1631 void test_string_unterminated_interpolation_block() {
1690 super.test_string_unterminated_interpolation_block(); 1632 super.test_string_unterminated_interpolation_block();
1691 } 1633 }
1692 1634
1693 @override 1635 @override
1694 @failingTest 1636 @failingTest
1695 void test_switchHasCaseAfterDefaultCase() { 1637 void test_switchHasCaseAfterDefaultCase() {
1696 super.test_switchHasCaseAfterDefaultCase(); 1638 super.test_switchHasCaseAfterDefaultCase();
1697 } 1639 }
1698 1640
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
2487 return result; 2429 return result;
2488 } 2430 }
2489 2431
2490 List<ErrorCode> _toFastaGeneratedAnalyzerErrorCodes( 2432 List<ErrorCode> _toFastaGeneratedAnalyzerErrorCodes(
2491 List<ErrorCode> expectedErrorCodes) => 2433 List<ErrorCode> expectedErrorCodes) =>
2492 expectedErrorCodes.map((code) { 2434 expectedErrorCodes.map((code) {
2493 if (code == ParserErrorCode.ABSTRACT_CLASS_MEMBER || 2435 if (code == ParserErrorCode.ABSTRACT_CLASS_MEMBER ||
2494 code == ParserErrorCode.ABSTRACT_ENUM || 2436 code == ParserErrorCode.ABSTRACT_ENUM ||
2495 code == ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION || 2437 code == ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION ||
2496 code == ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE || 2438 code == ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE ||
2497 code == ParserErrorCode.ABSTRACT_TYPEDEF) 2439 code == ParserErrorCode.ABSTRACT_TYPEDEF ||
2440 code == ParserErrorCode.CONST_ENUM ||
2441 code == ParserErrorCode.CONST_TYPEDEF ||
2442 code == ParserErrorCode.FINAL_CLASS ||
2443 code == ParserErrorCode.FINAL_ENUM ||
2444 code == ParserErrorCode.FINAL_TYPEDEF ||
2445 code == ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION)
2498 return ParserErrorCode.EXTRANEOUS_MODIFIER; 2446 return ParserErrorCode.EXTRANEOUS_MODIFIER;
2499 return code; 2447 return code;
2500 }).toList(); 2448 }).toList();
2501 } 2449 }
2502 2450
2503 /** 2451 /**
2504 * Tests of the fasta parser based on [FormalParameterParserTestMixin]. 2452 * Tests of the fasta parser based on [FormalParameterParserTestMixin].
2505 */ 2453 */
2506 @reflectiveTest 2454 @reflectiveTest
2507 class FormalParameterParserTest_Fasta extends FastaParserTestCase 2455 class FormalParameterParserTest_Fasta extends FastaParserTestCase
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
4287 allowNativeClause = false; 4235 allowNativeClause = false;
4288 test_parseClassDeclaration_native_missing_literal(); 4236 test_parseClassDeclaration_native_missing_literal();
4289 } 4237 }
4290 4238
4291 void test_parseClassDeclaration_native_not_allowed() { 4239 void test_parseClassDeclaration_native_not_allowed() {
4292 allowNativeClause = false; 4240 allowNativeClause = false;
4293 test_parseClassDeclaration_native(); 4241 test_parseClassDeclaration_native();
4294 } 4242 }
4295 4243
4296 @override 4244 @override
4245 void test_parseCompilationUnit_builtIn_asFunctionName() {
4246 //super.test_parseCompilationUnit_builtIn_asFunctionName();
4247
4248 // This is a subset of
4249 // super.test_parseCompilationUnit_builtIn_asFunctionName
4250 // that passes. The remainder are in the
4251 // test_parseCompilationUnit_builtIn_asFunctionName2 method below
4252 parseCompilationUnit('abstract(x) => 0;');
4253 parseCompilationUnit('as(x) => 0;');
4254 parseCompilationUnit('dynamic(x) => 0;');
4255 parseCompilationUnit('external(x) => 0;');
4256 parseCompilationUnit('factory(x) => 0;');
4257 parseCompilationUnit('get(x) => 0;');
4258 parseCompilationUnit('implements(x) => 0;');
4259 parseCompilationUnit('operator(x) => 0;');
4260 parseCompilationUnit('set(x) => 0;');
4261 parseCompilationUnit('static(x) => 0;');
4262 parseCompilationUnit('static(abstract) => 0;');
4263 parseCompilationUnit('typedef(x) => 0;');
4264 }
4265
4297 @failingTest 4266 @failingTest
4298 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { 4267 void test_parseCompilationUnit_builtIn_asFunctionName2() {
4299 // TODO(danrubel): built-in "abstract" cannot be used as a type 4268 // TODO(paulberry,ahe): Fasta's parser is confused when one of the built-in
4300 super.test_parseCompilationUnit_abstractAsPrefix_parameterized(); 4269 // identifiers `export`, `import`, `library`, `part`, or `typedef` appears
4270 // as the name of a top level function with an implicit return type.
4271 parseCompilationUnit('export(x) => 0;');
4272 parseCompilationUnit('import(x) => 0;');
4273 parseCompilationUnit('library(x) => 0;');
4274 parseCompilationUnit('part(x) => 0;');
4301 } 4275 }
4302 4276
4303 @override 4277 @override
4304 @failingTest
4305 void test_parseCompilationUnit_builtIn_asFunctionName() {
4306 // TODO(paulberry,ahe): Fasta's parser is confused when one of the built-in
4307 // identifiers `export`, `import`, `library`, `part`, or `typedef` appears
4308 // as the name of a top level function with an implicit return type.
4309 super.test_parseCompilationUnit_builtIn_asFunctionName();
4310 }
4311
4312 @override
4313 @failingTest 4278 @failingTest
4314 void test_parseCompilationUnit_exportAsPrefix() { 4279 void test_parseCompilationUnit_exportAsPrefix() {
4315 // TODO(paulberry): As of commit 5de9108 this syntax is invalid. 4280 // TODO(paulberry): As of commit 5de9108 this syntax is invalid.
4316 super.test_parseCompilationUnit_exportAsPrefix(); 4281 super.test_parseCompilationUnit_exportAsPrefix();
4317 } 4282 }
4318 4283
4319 @override 4284 @override
4320 @failingTest 4285 @failingTest
4321 void test_parseCompilationUnit_exportAsPrefix_parameterized() { 4286 void test_parseCompilationUnit_exportAsPrefix_parameterized() {
4322 // TODO(paulberry): As of commit 5de9108 this syntax is invalid. 4287 // TODO(paulberry): As of commit 5de9108 this syntax is invalid.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4354 @override 4319 @override
4355 @failingTest 4320 @failingTest
4356 void test_parseDirectives_mixed() { 4321 void test_parseDirectives_mixed() {
4357 // TODO(paulberry,ahe): This test verifies the analyzer parser's ability to 4322 // TODO(paulberry,ahe): This test verifies the analyzer parser's ability to
4358 // stop parsing as soon as the first non-directive is encountered; this is 4323 // stop parsing as soon as the first non-directive is encountered; this is
4359 // useful for quickly traversing an import graph. Consider adding a similar 4324 // useful for quickly traversing an import graph. Consider adding a similar
4360 // ability to Fasta's parser. 4325 // ability to Fasta's parser.
4361 super.test_parseDirectives_mixed(); 4326 super.test_parseDirectives_mixed();
4362 } 4327 }
4363 } 4328 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/parser/listener.dart » ('j') | pkg/front_end/lib/src/fasta/parser/parser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698