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

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

Issue 2701513006: Begin adding top-level function declaration support to AstBuilder. (Closed)
Patch Set: Created 3 years, 10 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/standard_ast_factory.dart'; 8 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
9 import 'package:analyzer/dart/ast/token.dart'; 9 import 'package:analyzer/dart/ast/token.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 13382 matching lines...) Expand 10 before | Expand all | Expand 10 after
13393 createParser('const int x = 0;'); 13393 createParser('const int x = 0;');
13394 CompilationUnitMember member = parseFullCompilationUnitMember(); 13394 CompilationUnitMember member = parseFullCompilationUnitMember();
13395 expect(member, isNotNull); 13395 expect(member, isNotNull);
13396 assertNoErrors(); 13396 assertNoErrors();
13397 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); 13397 expect(member, new isInstanceOf<TopLevelVariableDeclaration>());
13398 TopLevelVariableDeclaration declaration = member; 13398 TopLevelVariableDeclaration declaration = member;
13399 expect(declaration.semicolon, isNotNull); 13399 expect(declaration.semicolon, isNotNull);
13400 expect(declaration.variables, isNotNull); 13400 expect(declaration.variables, isNotNull);
13401 } 13401 }
13402 13402
13403 void test_parseCompilationUnitMember_expressionFunctionBody_tokens() {
13404 createParser('f() => 0;');
13405 var f = parseFullCompilationUnitMember() as FunctionDeclaration;
13406 var body = f.functionExpression.body as ExpressionFunctionBody;
13407 expect(body.functionDefinition.lexeme, '=>');
13408 expect(body.semicolon.lexeme, ';');
13409 }
13410
13403 void test_parseCompilationUnitMember_finalVariable() { 13411 void test_parseCompilationUnitMember_finalVariable() {
13404 createParser('final x = 0;'); 13412 createParser('final x = 0;');
13405 CompilationUnitMember member = parseFullCompilationUnitMember(); 13413 CompilationUnitMember member = parseFullCompilationUnitMember();
13406 expect(member, isNotNull); 13414 expect(member, isNotNull);
13407 assertNoErrors(); 13415 assertNoErrors();
13408 expect(member, new isInstanceOf<TopLevelVariableDeclaration>()); 13416 expect(member, new isInstanceOf<TopLevelVariableDeclaration>());
13409 TopLevelVariableDeclaration declaration = member; 13417 TopLevelVariableDeclaration declaration = member;
13410 expect(declaration.semicolon, isNotNull); 13418 expect(declaration.semicolon, isNotNull);
13411 expect(declaration.variables, isNotNull); 13419 expect(declaration.variables, isNotNull);
13412 } 13420 }
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
14509 expect(typeAlias.name, isNotNull); 14517 expect(typeAlias.name, isNotNull);
14510 expect(typeAlias.typeParameters, isNull); 14518 expect(typeAlias.typeParameters, isNull);
14511 expect(typeAlias.semicolon, isNotNull); 14519 expect(typeAlias.semicolon, isNotNull);
14512 GenericFunctionType functionType = typeAlias.functionType; 14520 GenericFunctionType functionType = typeAlias.functionType;
14513 expect(functionType, isNotNull); 14521 expect(functionType, isNotNull);
14514 expect(functionType.parameters, isNotNull); 14522 expect(functionType.parameters, isNotNull);
14515 expect(functionType.returnType, isNotNull); 14523 expect(functionType.returnType, isNotNull);
14516 expect(functionType.typeParameters, isNull); 14524 expect(functionType.typeParameters, isNull);
14517 } 14525 }
14518 } 14526 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698