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

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

Issue 1615963003: Issue 25522. Insert a synthetic '>' for incomplete type arguments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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) 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.parser_test; 5 library analyzer.test.generated.parser_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/visitor.dart'; 8 import 'package:analyzer/dart/ast/visitor.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 3692 matching lines...) Expand 10 before | Expand all | Expand 10 after
3703 expect(statement.toSource(), 'String v;'); 3703 expect(statement.toSource(), 'String v;');
3704 } 3704 }
3705 3705
3706 void test_incompleteLocalVariable_parameterizedType() { 3706 void test_incompleteLocalVariable_parameterizedType() {
3707 Statement statement = ParserTestCase 3707 Statement statement = ParserTestCase
3708 .parseStatement('List<String> v {}', [ParserErrorCode.EXPECTED_TOKEN]); 3708 .parseStatement('List<String> v {}', [ParserErrorCode.EXPECTED_TOKEN]);
3709 expect(statement, new isInstanceOf<VariableDeclarationStatement>()); 3709 expect(statement, new isInstanceOf<VariableDeclarationStatement>());
3710 expect(statement.toSource(), 'List<String> v;'); 3710 expect(statement.toSource(), 'List<String> v;');
3711 } 3711 }
3712 3712
3713 void test_incompleteParameterizedType_field() {
Brian Wilkerson 2016/01/21 19:25:12 The method _expectGT is also used for type paramet
scheglov 2016/01/21 21:03:47 Done.
3714 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3715 r'''
3716 class C {
3717 final List<int f;
3718 }''',
3719 [ParserErrorCode.EXPECTED_TOKEN]);
3720 // one class
3721 List<CompilationUnitMember> declarations = unit.declarations;
3722 expect(declarations, hasLength(1));
3723 ClassDeclaration classDecl = declarations[0] as ClassDeclaration;
3724 // one field declaration
3725 List<ClassMember> members = classDecl.members;
3726 expect(members, hasLength(1));
3727 FieldDeclaration fieldDecl = members[0] as FieldDeclaration;
3728 // one field
3729 VariableDeclarationList fieldList = fieldDecl.fields;
3730 List<VariableDeclaration> fields = fieldList.variables;
3731 expect(fields, hasLength(1));
3732 VariableDeclaration field = fields[0];
3733 expect(field.name.name, 'f');
3734 // validate the type
3735 TypeArgumentList typeArguments = fieldList.type.typeArguments;
3736 expect(typeArguments.arguments, hasLength(1));
3737 // synthetic '>'
3738 Token token = typeArguments.endToken;
3739 expect(token.type, TokenType.GT);
3740 expect(token.isSynthetic, isTrue);
3741 }
3742
3713 void test_invalidFunctionBodyModifier() { 3743 void test_invalidFunctionBodyModifier() {
3714 ParserTestCase.parseCompilationUnit( 3744 ParserTestCase.parseCompilationUnit(
3715 "f() sync {}", [ParserErrorCode.MISSING_STAR_AFTER_SYNC]); 3745 "f() sync {}", [ParserErrorCode.MISSING_STAR_AFTER_SYNC]);
3716 } 3746 }
3717 3747
3718 void test_isExpression_noType() { 3748 void test_isExpression_noType() {
3719 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3749 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3720 "class Bar<T extends Foo> {m(x){if (x is ) return;if (x is !)}}", [ 3750 "class Bar<T extends Foo> {m(x){if (x is ) return;if (x is !)}}", [
3721 ParserErrorCode.EXPECTED_TYPE_NAME, 3751 ParserErrorCode.EXPECTED_TYPE_NAME,
3722 ParserErrorCode.EXPECTED_TYPE_NAME, 3752 ParserErrorCode.EXPECTED_TYPE_NAME,
(...skipping 7721 matching lines...) Expand 10 before | Expand all | Expand 10 after
11444 new Scanner(null, new CharSequenceReader(source), listener); 11474 new Scanner(null, new CharSequenceReader(source), listener);
11445 Token tokenStream = scanner.tokenize(); 11475 Token tokenStream = scanner.tokenize();
11446 // 11476 //
11447 // Parse the source. 11477 // Parse the source.
11448 // 11478 //
11449 Parser parser = new Parser(null, listener); 11479 Parser parser = new Parser(null, listener);
11450 return invokeParserMethodImpl( 11480 return invokeParserMethodImpl(
11451 parser, methodName, <Object>[tokenStream], tokenStream) as Token; 11481 parser, methodName, <Object>[tokenStream], tokenStream) as Token;
11452 } 11482 }
11453 } 11483 }
OLDNEW
« pkg/analyzer/lib/src/generated/parser.dart ('K') | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698