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

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

Issue 3011643002: Fix several failing tests (Closed)
Patch Set: fix sort and metadata parsing 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';
11 import 'package:analyzer/src/fasta/ast_builder.dart'; 11 import 'package:analyzer/src/fasta/ast_builder.dart';
12 import 'package:analyzer/src/generated/parser.dart' as analyzer; 12 import 'package:analyzer/src/generated/parser.dart' as analyzer;
13 import 'package:analyzer/src/generated/parser.dart' show CommentAndMetadata;
13 import 'package:analyzer/src/generated/utilities_dart.dart'; 14 import 'package:analyzer/src/generated/utilities_dart.dart';
14 import 'package:analyzer/src/string_source.dart'; 15 import 'package:analyzer/src/string_source.dart';
15 import 'package:front_end/src/fasta/fasta_codes.dart' show Message; 16 import 'package:front_end/src/fasta/fasta_codes.dart' show Message;
16 import 'package:front_end/src/fasta/kernel/kernel_builder.dart'; 17 import 'package:front_end/src/fasta/kernel/kernel_builder.dart';
17 import 'package:front_end/src/fasta/kernel/kernel_library_builder.dart'; 18 import 'package:front_end/src/fasta/kernel/kernel_library_builder.dart';
18 import 'package:front_end/src/fasta/parser.dart' show IdentifierContext; 19 import 'package:front_end/src/fasta/parser.dart' show IdentifierContext;
19 import 'package:front_end/src/fasta/parser.dart' as fasta; 20 import 'package:front_end/src/fasta/parser.dart' as fasta;
20 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; 21 import 'package:front_end/src/fasta/scanner/string_scanner.dart';
21 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; 22 import 'package:front_end/src/fasta/scanner/token.dart' as fasta;
23 import 'package:front_end/src/fasta/source/stack_listener.dart';
22 import 'package:test/test.dart'; 24 import 'package:test/test.dart';
23 import 'package:test_reflective_loader/test_reflective_loader.dart'; 25 import 'package:test_reflective_loader/test_reflective_loader.dart';
24 26
25 import 'parser_fasta_listener.dart'; 27 import 'parser_fasta_listener.dart';
26 import 'parser_test.dart'; 28 import 'parser_test.dart';
27 import 'test_support.dart'; 29 import 'test_support.dart';
28 30
29 main() { 31 main() {
30 defineReflectiveSuite(() { 32 defineReflectiveSuite(() {
31 defineReflectiveTests(ClassMemberParserTest_Fasta); 33 defineReflectiveTests(ClassMemberParserTest_Fasta);
(...skipping 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after
2801 _eventListener.end('CompilationUnit'); 2803 _eventListener.end('CompilationUnit');
2802 _astBuilder.className = null; 2804 _astBuilder.className = null;
2803 return result; 2805 return result;
2804 } 2806 }
2805 2807
2806 List<Combinator> parseCombinators() { 2808 List<Combinator> parseCombinators() {
2807 return _run((parser) => parser.parseCombinators); 2809 return _run((parser) => parser.parseCombinators);
2808 } 2810 }
2809 2811
2810 @override 2812 @override
2813 CommentAndMetadata parseCommentAndMetadata() {
2814 List commentAndMetadata =
2815 _run((parser) => parser.parseMetadataStar, nodeCount: -1);
2816 expect(commentAndMetadata, hasLength(2));
2817 Object comment = commentAndMetadata[0];
2818 Object metadata = commentAndMetadata[1];
2819 if (comment == NullValue.Comments) {
2820 comment = null;
2821 }
2822 if (metadata == NullValue.Metadata) {
2823 metadata = null;
2824 } else {
2825 metadata = new List<Annotation>.from(metadata);
2826 }
2827 return new CommentAndMetadata(comment, metadata);
2828 }
2829
2830 @override
2811 CompilationUnit parseCompilationUnit2() { 2831 CompilationUnit parseCompilationUnit2() {
2812 var result = _run(null) as CompilationUnit; 2832 var result = _run(null) as CompilationUnit;
2813 _eventListener.expectEmpty(); 2833 _eventListener.expectEmpty();
2814 return result; 2834 return result;
2815 } 2835 }
2816 2836
2817 @override 2837 @override
2818 Configuration parseConfiguration() { 2838 Configuration parseConfiguration() {
2819 return _run((parser) => parser.parseConditionalUri) as Configuration; 2839 return _run((parser) => parser.parseConditionalUri) as Configuration;
2820 } 2840 }
(...skipping 21 matching lines...) Expand all
2842 TypeAnnotation parseTypeAnnotation(bool inExpression) { 2862 TypeAnnotation parseTypeAnnotation(bool inExpression) {
2843 return _run((parser) => parser.parseType) as TypeAnnotation; 2863 return _run((parser) => parser.parseType) as TypeAnnotation;
2844 } 2864 }
2845 2865
2846 @override 2866 @override
2847 TypeArgumentList parseTypeArgumentList() { 2867 TypeArgumentList parseTypeArgumentList() {
2848 return _run((parser) => parser.parseTypeVariablesOpt) as TypeArgumentList; 2868 return _run((parser) => parser.parseTypeVariablesOpt) as TypeArgumentList;
2849 } 2869 }
2850 2870
2851 /** 2871 /**
2852 * Runs a single parser function, and returns the result as an analyzer AST. 2872 * Runs a single parser function (returned by [getParseFunction]), and returns
2873 * the result as an analyzer AST. It checks that the parse consumed all of the
2874 * tokens and that there were [nodeCount] AST nodes created (unless the node
2875 * count is negative).
2853 */ 2876 */
2854 Object _run(ParseFunction getParseFunction(fasta.Parser parser)) { 2877 Object _run(ParseFunction getParseFunction(fasta.Parser parser),
2878 {int nodeCount: 1}) {
2855 ParseFunction parseFunction; 2879 ParseFunction parseFunction;
2856 if (getParseFunction != null) { 2880 if (getParseFunction != null) {
2857 parseFunction = getParseFunction(_fastaParser); 2881 parseFunction = getParseFunction(_fastaParser);
2858 _fastaParser.firstToken = _currentFastaToken; 2882 _fastaParser.firstToken = _currentFastaToken;
2859 } else { 2883 } else {
2860 parseFunction = _fastaParser.parseUnit; 2884 parseFunction = _fastaParser.parseUnit;
2861 // firstToken should be set by beginCompilationUnit event. 2885 // firstToken should be set by beginCompilationUnit event.
2862 } 2886 }
2863 _currentFastaToken = parseFunction(_currentFastaToken); 2887 _currentFastaToken = parseFunction(_currentFastaToken);
2864 expect(_currentFastaToken.isEof, isTrue); 2888 expect(_currentFastaToken.isEof, isTrue);
2865 expect(_astBuilder.stack, hasLength(1)); 2889 if (nodeCount >= 0) {
2890 expect(_astBuilder.stack, hasLength(nodeCount));
2891 }
2892 if (nodeCount != 1) {
2893 return _astBuilder.stack.values;
2894 }
2866 return _astBuilder.pop(); 2895 return _astBuilder.pop();
2867 } 2896 }
2868 } 2897 }
2869 2898
2870 @reflectiveTest 2899 @reflectiveTest
2871 class RecoveryParserTest_Fasta extends FastaParserTestCase 2900 class RecoveryParserTest_Fasta extends FastaParserTestCase
2872 with RecoveryParserTestMixin { 2901 with RecoveryParserTestMixin {
2873 @override 2902 @override
2874 @failingTest 2903 @failingTest
2875 void test_additiveExpression_missing_LHS() { 2904 void test_additiveExpression_missing_LHS() {
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
3806 @failingTest 3835 @failingTest
3807 void test_parseArgumentList_trailing_comma() { 3836 void test_parseArgumentList_trailing_comma() {
3808 // TODO(brianwilkerson) Produces a method invocation rather than an empty 3837 // TODO(brianwilkerson) Produces a method invocation rather than an empty
3809 // argument list. 3838 // argument list.
3810 super.test_parseArgumentList_trailing_comma(); 3839 super.test_parseArgumentList_trailing_comma();
3811 } 3840 }
3812 3841
3813 @override 3842 @override
3814 @failingTest 3843 @failingTest
3815 void test_parseCombinator_hide() { 3844 void test_parseCombinator_hide() {
3816 // TODO(brianwilkerson) exception:
3817 // Uninteresting. Covered by the test_parseCombinators_* methods. 3845 // Uninteresting. Covered by the test_parseCombinators_* methods.
3818 super.test_parseCombinator_hide(); 3846 super.test_parseCombinator_hide();
3819 } 3847 }
3820 3848
3821 @override 3849 @override
3822 @failingTest 3850 @failingTest
3823 void test_parseCombinator_show() { 3851 void test_parseCombinator_show() {
3824 // TODO(brianwilkerson) exception:
3825 // Uninteresting. Covered by the test_parseCombinators_* methods. 3852 // Uninteresting. Covered by the test_parseCombinators_* methods.
3826 super.test_parseCombinator_show(); 3853 super.test_parseCombinator_show();
3827 } 3854 }
3828 3855
3829 @override 3856 @override
3830 @failingTest 3857 @failingTest
3831 void test_parseCombinators_h() {
3832 // TODO(brianwilkerson) Failed to use all tokens.
3833 super.test_parseCombinators_h();
3834 }
3835
3836 @override
3837 @failingTest
3838 void test_parseCombinators_hs() {
3839 // TODO(brianwilkerson) Failed to use all tokens.
3840 super.test_parseCombinators_hs();
3841 }
3842
3843 @override
3844 @failingTest
3845 void test_parseCombinators_hshs() {
3846 // TODO(brianwilkerson) Failed to use all tokens.
3847 super.test_parseCombinators_hshs();
3848 }
3849
3850 @override
3851 @failingTest
3852 void test_parseCombinators_s() {
3853 // TODO(brianwilkerson) Failed to use all tokens.
3854 super.test_parseCombinators_s();
3855 }
3856
3857 @override
3858 @failingTest
3859 void test_parseCommentAndMetadata_c() {
3860 // TODO(brianwilkerson) exception:
3861 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseComme ntAndMetadata'.
3862 super.test_parseCommentAndMetadata_c();
3863 }
3864
3865 @override
3866 @failingTest
3867 void test_parseCommentAndMetadata_cmc() {
3868 // TODO(brianwilkerson) exception:
3869 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseComme ntAndMetadata'.
3870 super.test_parseCommentAndMetadata_cmc();
3871 }
3872
3873 @override
3874 @failingTest
3875 void test_parseCommentAndMetadata_cmcm() {
3876 // TODO(brianwilkerson) exception:
3877 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseComme ntAndMetadata'.
3878 super.test_parseCommentAndMetadata_cmcm();
3879 }
3880
3881 @override
3882 @failingTest
3883 void test_parseCommentAndMetadata_cmm() {
3884 // TODO(brianwilkerson) exception:
3885 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseComme ntAndMetadata'.
3886 super.test_parseCommentAndMetadata_cmm();
3887 }
3888
3889 @override
3890 @failingTest
3891 void test_parseCommentAndMetadata_m() {
3892 // TODO(brianwilkerson) exception:
3893 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseComme ntAndMetadata'.
3894 super.test_parseCommentAndMetadata_m();
3895 }
3896
3897 @override
3898 @failingTest
3899 void test_parseCommentAndMetadata_mcm() { 3858 void test_parseCommentAndMetadata_mcm() {
3900 // TODO(brianwilkerson) exception: 3859 // TODO(brianwilkerson) Does not find comment if not before first annotation
3901 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseComme ntAndMetadata'.
3902 super.test_parseCommentAndMetadata_mcm(); 3860 super.test_parseCommentAndMetadata_mcm();
3903 } 3861 }
3904 3862
3905 @override 3863 @override
3906 @failingTest 3864 @failingTest
3907 void test_parseCommentAndMetadata_mcmc() { 3865 void test_parseCommentAndMetadata_mcmc() {
3908 // TODO(brianwilkerson) exception: 3866 // TODO(brianwilkerson) Does not find comment if not before first annotation
3909 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseComme ntAndMetadata'.
3910 super.test_parseCommentAndMetadata_mcmc(); 3867 super.test_parseCommentAndMetadata_mcmc();
3911 } 3868 }
3912 3869
3913 @override 3870 @override
3914 @failingTest 3871 @failingTest
3915 void test_parseCommentAndMetadata_mm() {
3916 // TODO(brianwilkerson) exception:
3917 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseComme ntAndMetadata'.
3918 super.test_parseCommentAndMetadata_mm();
3919 }
3920
3921 @override
3922 @failingTest
3923 void test_parseCommentAndMetadata_none() {
3924 // TODO(brianwilkerson) exception:
3925 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseComme ntAndMetadata'.
3926 super.test_parseCommentAndMetadata_none();
3927 }
3928
3929 @override
3930 @failingTest
3931 void test_parseCommentAndMetadata_singleLine() {
3932 // TODO(brianwilkerson) exception:
3933 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseComme ntAndMetadata'.
3934 super.test_parseCommentAndMetadata_singleLine();
3935 }
3936
3937 @override
3938 @failingTest
3939 void test_parseConfiguration_noOperator_dottedIdentifier() {
3940 // TODO(brianwilkerson) Missing right parenthesis.
3941 super.test_parseConfiguration_noOperator_dottedIdentifier();
3942 }
3943
3944 @override
3945 @failingTest
3946 void test_parseConfiguration_noOperator_simpleIdentifier() {
3947 // TODO(brianwilkerson) Missing right parenthesis.
3948 super.test_parseConfiguration_noOperator_simpleIdentifier();
3949 }
3950
3951 @override
3952 @failingTest
3953 void test_parseConfiguration_operator_dottedIdentifier() {
3954 // TODO(brianwilkerson) Missing right parenthesis.
3955 super.test_parseConfiguration_operator_dottedIdentifier();
3956 }
3957
3958 @override
3959 @failingTest
3960 void test_parseConfiguration_operator_simpleIdentifier() {
3961 // TODO(brianwilkerson) Missing right parenthesis.
3962 super.test_parseConfiguration_operator_simpleIdentifier();
3963 }
3964
3965 @override
3966 @failingTest
3967 void test_parseConstructorName_named_noPrefix() { 3872 void test_parseConstructorName_named_noPrefix() {
3968 // TODO(brianwilkerson) exception: 3873 // TODO(brianwilkerson) exception:
3969 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseConst ructorName'. 3874 // NoSuchMethodError: Class 'ParserProxy' has no instance method 'parseConst ructorName'.
3970 super.test_parseConstructorName_named_noPrefix(); 3875 super.test_parseConstructorName_named_noPrefix();
3971 } 3876 }
3972 3877
3973 @override 3878 @override
3974 @failingTest 3879 @failingTest
3975 void test_parseConstructorName_named_prefixed() { 3880 void test_parseConstructorName_named_prefixed() {
3976 // TODO(brianwilkerson) exception: 3881 // TODO(brianwilkerson) exception:
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
4390 @override 4295 @override
4391 @failingTest 4296 @failingTest
4392 void test_parseReturnType_void() { 4297 void test_parseReturnType_void() {
4393 // TODO(brianwilkerson) Test isn't passing in enough context. 4298 // TODO(brianwilkerson) Test isn't passing in enough context.
4394 // Type 'void' can't be used here because it isn't a return type. 4299 // Type 'void' can't be used here because it isn't a return type.
4395 super.test_parseReturnType_void(); 4300 super.test_parseReturnType_void();
4396 } 4301 }
4397 4302
4398 @override 4303 @override
4399 @failingTest 4304 @failingTest
4400 void test_parseTypeAnnotation_function_noReturnType_noParameters() {
4401 // TODO(brianwilkerson) Failed to use all tokens.
4402 super.test_parseTypeAnnotation_function_noReturnType_noParameters();
4403 }
4404
4405 @override
4406 @failingTest
4407 void test_parseTypeAnnotation_function_noReturnType_parameters() {
4408 // TODO(brianwilkerson) Failed to use all tokens.
4409 super.test_parseTypeAnnotation_function_noReturnType_parameters();
4410 }
4411
4412 @override
4413 @failingTest
4414 void test_parseTypeAnnotation_function_returnType_classFunction() {
4415 // TODO(brianwilkerson) Failed to use all tokens.
4416 super.test_parseTypeAnnotation_function_returnType_classFunction();
4417 }
4418
4419 @override
4420 @failingTest
4421 void test_parseTypeAnnotation_function_returnType_function() {
4422 // TODO(brianwilkerson) Failed to use all tokens.
4423 super.test_parseTypeAnnotation_function_returnType_function();
4424 }
4425
4426 @override
4427 @failingTest
4428 void test_parseTypeAnnotation_function_returnType_simple() {
4429 // TODO(brianwilkerson) Failed to use all tokens.
4430 super.test_parseTypeAnnotation_function_returnType_simple();
4431 }
4432
4433 @override
4434 @failingTest
4435 void test_parseTypeAnnotation_function_returnType_withArguments() {
4436 // TODO(brianwilkerson) Failed to use all tokens.
4437 super.test_parseTypeAnnotation_function_returnType_withArguments();
4438 }
4439
4440 @override
4441 @failingTest
4442 void test_parseTypeAnnotation_named() {
4443 // TODO(brianwilkerson) Failed to use all tokens.
4444 super.test_parseTypeAnnotation_named();
4445 }
4446
4447 @override
4448 @failingTest
4449 void test_parseTypeArgumentList_empty() { 4305 void test_parseTypeArgumentList_empty() {
4450 // TODO(brianwilkerson) reportUnrecoverableErrorWithToken 4306 // TODO(brianwilkerson) reportUnrecoverableErrorWithToken
4451 super.test_parseTypeArgumentList_empty(); 4307 super.test_parseTypeArgumentList_empty();
4452 } 4308 }
4453 4309
4454 @override 4310 @override
4455 @failingTest 4311 @failingTest
4456 void test_parseTypeArgumentList_multiple() { 4312 void test_parseTypeArgumentList_multiple() {
4457 // TODO(brianwilkerson) exception: 4313 // TODO(brianwilkerson) exception:
4458 // type 'TypeParameterListImpl' is not a subtype of type 'TypeArgumentList ' in type cast where 4314 // type 'TypeParameterListImpl' is not a subtype of type 'TypeArgumentList ' in type cast where
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
4802 @override 4658 @override
4803 @failingTest 4659 @failingTest
4804 void test_parseDirectives_mixed() { 4660 void test_parseDirectives_mixed() {
4805 // TODO(paulberry,ahe): This test verifies the analyzer parser's ability to 4661 // TODO(paulberry,ahe): This test verifies the analyzer parser's ability to
4806 // stop parsing as soon as the first non-directive is encountered; this is 4662 // stop parsing as soon as the first non-directive is encountered; this is
4807 // useful for quickly traversing an import graph. Consider adding a similar 4663 // useful for quickly traversing an import graph. Consider adding a similar
4808 // ability to Fasta's parser. 4664 // ability to Fasta's parser.
4809 super.test_parseDirectives_mixed(); 4665 super.test_parseDirectives_mixed();
4810 } 4666 }
4811 } 4667 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698