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

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

Issue 2492633002: Create AST structure for asserts in constructor initializers (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/error/error.dart'; 10 import 'package:analyzer/error/error.dart';
(...skipping 7828 matching lines...) Expand 10 before | Expand all | Expand 10 after
7839 7839
7840 void test_parseConstructor_assert() { 7840 void test_parseConstructor_assert() {
7841 enableAssertInitializer = true; 7841 enableAssertInitializer = true;
7842 createParser('C(x, y) : _x = x, assert (x < y), _y = y;'); 7842 createParser('C(x, y) : _x = x, assert (x < y), _y = y;');
7843 ClassMember member = parser.parseClassMember('C'); 7843 ClassMember member = parser.parseClassMember('C');
7844 expectNotNullIfNoErrors(member); 7844 expectNotNullIfNoErrors(member);
7845 listener.assertNoErrors(); 7845 listener.assertNoErrors();
7846 expect(member, new isInstanceOf<ConstructorDeclaration>()); 7846 expect(member, new isInstanceOf<ConstructorDeclaration>());
7847 ConstructorDeclaration constructor = member as ConstructorDeclaration; 7847 ConstructorDeclaration constructor = member as ConstructorDeclaration;
7848 NodeList<ConstructorInitializer> initializers = constructor.initializers; 7848 NodeList<ConstructorInitializer> initializers = constructor.initializers;
7849 expect(initializers, hasLength(2)); 7849 expect(initializers, hasLength(3));
7850 ConstructorInitializer initializer = initializers[1];
7851 expect(initializer, new isInstanceOf<AssertInitializer>());
7852 AssertInitializer assertInitializer = initializer;
7853 expect(assertInitializer.condition, isNotNull);
7854 expect(assertInitializer.message, isNull);
7850 } 7855 }
7851 7856
7852 void test_parseConstructor_with_pseudo_function_literal() { 7857 void test_parseConstructor_with_pseudo_function_literal() {
7853 // "(b) {}" should not be misinterpreted as a function literal even though 7858 // "(b) {}" should not be misinterpreted as a function literal even though
7854 // it looks like one. 7859 // it looks like one.
7855 createParser('C() : a = (b) {}'); 7860 createParser('C() : a = (b) {}');
7856 ClassMember member = parser.parseClassMember('C'); 7861 ClassMember member = parser.parseClassMember('C');
7857 expectNotNullIfNoErrors(member); 7862 expectNotNullIfNoErrors(member);
7858 listener.assertNoErrors(); 7863 listener.assertNoErrors();
7859 expect(member, new isInstanceOf<ConstructorDeclaration>()); 7864 expect(member, new isInstanceOf<ConstructorDeclaration>());
(...skipping 5614 matching lines...) Expand 10 before | Expand all | Expand 10 after
13474 CompilationUnit _parseDirectives(String source, 13479 CompilationUnit _parseDirectives(String source,
13475 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { 13480 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) {
13476 createParser(source); 13481 createParser(source);
13477 CompilationUnit unit = parser.parseDirectives2(); 13482 CompilationUnit unit = parser.parseDirectives2();
13478 expect(unit, isNotNull); 13483 expect(unit, isNotNull);
13479 expect(unit.declarations, hasLength(0)); 13484 expect(unit.declarations, hasLength(0));
13480 listener.assertErrorsWithCodes(errorCodes); 13485 listener.assertErrorsWithCodes(errorCodes);
13481 return unit; 13486 return unit;
13482 } 13487 }
13483 } 13488 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698