OLD | NEW |
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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 "void 2 void", [ParserErrorCode.EXPECTED_EXECUTABLE]); | 946 "void 2 void", [ParserErrorCode.EXPECTED_EXECUTABLE]); |
947 } | 947 } |
948 | 948 |
949 void test_expectedExecutable_topLevel_beforeType() { | 949 void test_expectedExecutable_topLevel_beforeType() { |
950 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], | 950 parse3("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
951 "4 score", [ParserErrorCode.EXPECTED_EXECUTABLE]); | 951 "4 score", [ParserErrorCode.EXPECTED_EXECUTABLE]); |
952 } | 952 } |
953 | 953 |
954 void test_expectedExecutable_topLevel_eof() { | 954 void test_expectedExecutable_topLevel_eof() { |
955 parse2("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], | 955 parse2("parseCompilationUnitMember", <Object>[emptyCommentAndMetadata()], |
956 "x", [ | 956 "x", |
957 new AnalysisError.con2(null, 0, 1, ParserErrorCode.EXPECTED_EXECUTABLE) | 957 [new AnalysisError(null, 0, 1, ParserErrorCode.EXPECTED_EXECUTABLE)]); |
958 ]); | |
959 } | 958 } |
960 | 959 |
961 void test_expectedInterpolationIdentifier() { | 960 void test_expectedInterpolationIdentifier() { |
962 parse4( | 961 parse4( |
963 "parseStringLiteral", "'\$x\$'", [ParserErrorCode.MISSING_IDENTIFIER]); | 962 "parseStringLiteral", "'\$x\$'", [ParserErrorCode.MISSING_IDENTIFIER]); |
964 } | 963 } |
965 | 964 |
966 void test_expectedInterpolationIdentifier_emptyString() { | 965 void test_expectedInterpolationIdentifier_emptyString() { |
967 // The scanner inserts an empty string token between the two $'s; we need to | 966 // The scanner inserts an empty string token between the two $'s; we need to |
968 // make sure that the MISSING_IDENTIFIER error that is generated has a | 967 // make sure that the MISSING_IDENTIFIER error that is generated has a |
969 // nonzero width so that it will show up in the editor UI. | 968 // nonzero width so that it will show up in the editor UI. |
970 parse2("parseStringLiteral", <Object>[], "'\$\$foo'", [ | 969 parse2("parseStringLiteral", <Object>[], "'\$\$foo'", |
971 new AnalysisError.con2(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER) | 970 [new AnalysisError(null, 2, 1, ParserErrorCode.MISSING_IDENTIFIER)]); |
972 ]); | |
973 } | 971 } |
974 | 972 |
975 void test_expectedStringLiteral() { | 973 void test_expectedStringLiteral() { |
976 StringLiteral expression = parse4( | 974 StringLiteral expression = parse4( |
977 "parseStringLiteral", "1", [ParserErrorCode.EXPECTED_STRING_LITERAL]); | 975 "parseStringLiteral", "1", [ParserErrorCode.EXPECTED_STRING_LITERAL]); |
978 expect(expression.isSynthetic, isTrue); | 976 expect(expression.isSynthetic, isTrue); |
979 } | 977 } |
980 | 978 |
981 void test_expectedToken_commaMissingInArgumentList() { | 979 void test_expectedToken_commaMissingInArgumentList() { |
982 parse4("parseArgumentList", "(x, y z)", [ParserErrorCode.EXPECTED_TOKEN]); | 980 parse4("parseArgumentList", "(x, y z)", [ParserErrorCode.EXPECTED_TOKEN]); |
(...skipping 9277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10260 new Scanner(null, new CharSequenceReader(source), listener); | 10258 new Scanner(null, new CharSequenceReader(source), listener); |
10261 Token tokenStream = scanner.tokenize(); | 10259 Token tokenStream = scanner.tokenize(); |
10262 // | 10260 // |
10263 // Parse the source. | 10261 // Parse the source. |
10264 // | 10262 // |
10265 Parser parser = new Parser(null, listener); | 10263 Parser parser = new Parser(null, listener); |
10266 return invokeParserMethodImpl( | 10264 return invokeParserMethodImpl( |
10267 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 10265 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
10268 } | 10266 } |
10269 } | 10267 } |
OLD | NEW |