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

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

Issue 1083093002: Don't permit annotations inside variable declarations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a bogus comment. Created 5 years, 8 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 | Annotate | Revision Log
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 engine.parser_test; 5 library engine.parser_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 BinaryExpression expression = parseExpression("x << y + z"); 478 BinaryExpression expression = parseExpression("x << y + z");
479 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, 479 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
480 BinaryExpression, expression.rightOperand); 480 BinaryExpression, expression.rightOperand);
481 } 481 }
482 482
483 void test_shiftExpression_super() { 483 void test_shiftExpression_super() {
484 BinaryExpression expression = parseExpression("super >> 4 << 3"); 484 BinaryExpression expression = parseExpression("super >> 4 << 3");
485 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, 485 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
486 BinaryExpression, expression.leftOperand); 486 BinaryExpression, expression.leftOperand);
487 } 487 }
488
489 void test_topLevelVariable_withMetadata() {
490 ParserTestCase.parseCompilationUnit("String @A string;");
491 }
492 } 488 }
493 489
494 /** 490 /**
495 * The class `ErrorParserTest` defines parser tests that test the parsing of cod e to ensure 491 * The class `ErrorParserTest` defines parser tests that test the parsing of cod e to ensure
496 * that errors are correctly reported, and in some cases, not reported. 492 * that errors are correctly reported, and in some cases, not reported.
497 */ 493 */
498 @reflectiveTest 494 @reflectiveTest
499 class ErrorParserTest extends ParserTestCase { 495 class ErrorParserTest extends ParserTestCase {
500 void fail_expectedListOrMapLiteral() { 496 void fail_expectedListOrMapLiteral() {
501 // It isn't clear that this test can ever pass. The parser is currently 497 // It isn't clear that this test can ever pass. The parser is currently
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 "bool operator +(bool x, bool y) => x | y;", 1888 "bool operator +(bool x, bool y) => x | y;",
1893 [ParserErrorCode.TOP_LEVEL_OPERATOR]); 1889 [ParserErrorCode.TOP_LEVEL_OPERATOR]);
1894 } 1890 }
1895 1891
1896 void test_topLevelOperator_withVoid() { 1892 void test_topLevelOperator_withVoid() {
1897 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], 1893 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()],
1898 "void operator +(bool x, bool y) => x | y;", 1894 "void operator +(bool x, bool y) => x | y;",
1899 [ParserErrorCode.TOP_LEVEL_OPERATOR]); 1895 [ParserErrorCode.TOP_LEVEL_OPERATOR]);
1900 } 1896 }
1901 1897
1898 void test_topLevelVariable_withMetadata() {
1899 ParserTestCase.parseCompilationUnit("String @A string;", [
1900 ParserErrorCode.MISSING_IDENTIFIER,
1901 ParserErrorCode.EXPECTED_TOKEN,
1902 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE
1903 ]);
1904 }
1905
1902 void test_typedefInClass_withoutReturnType() { 1906 void test_typedefInClass_withoutReturnType() {
1903 ParserTestCase.parseCompilationUnit( 1907 ParserTestCase.parseCompilationUnit(
1904 "class C { typedef F(x); }", [ParserErrorCode.TYPEDEF_IN_CLASS]); 1908 "class C { typedef F(x); }", [ParserErrorCode.TYPEDEF_IN_CLASS]);
1905 } 1909 }
1906 1910
1907 void test_typedefInClass_withReturnType() { 1911 void test_typedefInClass_withReturnType() {
1908 ParserTestCase.parseCompilationUnit("class C { typedef int F(int x); }", 1912 ParserTestCase.parseCompilationUnit("class C { typedef int F(int x); }",
1909 [ParserErrorCode.TYPEDEF_IN_CLASS]); 1913 [ParserErrorCode.TYPEDEF_IN_CLASS]);
1910 } 1914 }
1911 1915
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
3264 expect(vars, hasLength(1)); 3268 expect(vars, hasLength(1));
3265 expect(vars[0].name.name, "v"); 3269 expect(vars[0].name.name, "v");
3266 } 3270 }
3267 3271
3268 void test_functionExpression_named() { 3272 void test_functionExpression_named() {
3269 parseExpression("m(f() => 0);", [ParserErrorCode.EXPECTED_TOKEN]); 3273 parseExpression("m(f() => 0);", [ParserErrorCode.EXPECTED_TOKEN]);
3270 } 3274 }
3271 3275
3272 void test_importDirectivePartial_as() { 3276 void test_importDirectivePartial_as() {
3273 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3277 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3274 "import 'b.dart' d as b;", 3278 "import 'b.dart' d as b;", [ParserErrorCode.UNEXPECTED_TOKEN]);
3275 [ParserErrorCode.UNEXPECTED_TOKEN]);
3276 ImportDirective importDirective = unit.childEntities.first; 3279 ImportDirective importDirective = unit.childEntities.first;
3277 expect(importDirective.asKeyword, isNotNull); 3280 expect(importDirective.asKeyword, isNotNull);
3278 expect(unit.directives, hasLength(1)); 3281 expect(unit.directives, hasLength(1));
3279 expect(unit.declarations, hasLength(0)); 3282 expect(unit.declarations, hasLength(0));
3280 } 3283 }
3281 3284
3282 void test_importDirectivePartial_show() { 3285 void test_importDirectivePartial_hide() {
3283 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3286 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3284 "import 'b.dart' d show foo;", 3287 "import 'b.dart' d hide foo;", [ParserErrorCode.UNEXPECTED_TOKEN]);
3285 [ParserErrorCode.UNEXPECTED_TOKEN]);
3286 ImportDirective importDirective = unit.childEntities.first; 3288 ImportDirective importDirective = unit.childEntities.first;
3287 expect(importDirective.combinators, hasLength(1)); 3289 expect(importDirective.combinators, hasLength(1));
3288 expect(unit.directives, hasLength(1)); 3290 expect(unit.directives, hasLength(1));
3289 expect(unit.declarations, hasLength(0)); 3291 expect(unit.declarations, hasLength(0));
3290 } 3292 }
3291 3293
3292 void test_importDirectivePartial_hide() { 3294 void test_importDirectivePartial_show() {
3293 CompilationUnit unit = ParserTestCase.parseCompilationUnit( 3295 CompilationUnit unit = ParserTestCase.parseCompilationUnit(
3294 "import 'b.dart' d hide foo;", 3296 "import 'b.dart' d show foo;", [ParserErrorCode.UNEXPECTED_TOKEN]);
3295 [ParserErrorCode.UNEXPECTED_TOKEN]);
3296 ImportDirective importDirective = unit.childEntities.first; 3297 ImportDirective importDirective = unit.childEntities.first;
3297 expect(importDirective.combinators, hasLength(1)); 3298 expect(importDirective.combinators, hasLength(1));
3298 expect(unit.directives, hasLength(1)); 3299 expect(unit.directives, hasLength(1));
3299 expect(unit.declarations, hasLength(0)); 3300 expect(unit.declarations, hasLength(0));
3300 } 3301 }
3301 3302
3302 void test_incomplete_conditionalExpression() { 3303 void test_incomplete_conditionalExpression() {
3303 parseExpression("x ? 0", [ 3304 parseExpression("x ? 0", [
3304 ParserErrorCode.EXPECTED_TOKEN, 3305 ParserErrorCode.EXPECTED_TOKEN,
3305 ParserErrorCode.MISSING_IDENTIFIER 3306 ParserErrorCode.MISSING_IDENTIFIER
(...skipping 6944 matching lines...) Expand 10 before | Expand all | Expand 10 after
10250 new Scanner(null, new CharSequenceReader(source), listener); 10251 new Scanner(null, new CharSequenceReader(source), listener);
10251 Token tokenStream = scanner.tokenize(); 10252 Token tokenStream = scanner.tokenize();
10252 // 10253 //
10253 // Parse the source. 10254 // Parse the source.
10254 // 10255 //
10255 Parser parser = new Parser(null, listener); 10256 Parser parser = new Parser(null, listener);
10256 return invokeParserMethodImpl( 10257 return invokeParserMethodImpl(
10257 parser, methodName, <Object>[tokenStream], tokenStream) as Token; 10258 parser, methodName, <Object>[tokenStream], tokenStream) as Token;
10258 } 10259 }
10259 } 10260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698