| 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 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1934 emptyCommentAndMetadata(), | 1934 emptyCommentAndMetadata(), |
| 1935 null | 1935 null |
| 1936 ], "class C { int x; ; int y;}", [ParserErrorCode.UNEXPECTED_TOKEN]); | 1936 ], "class C { int x; ; int y;}", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 1937 } | 1937 } |
| 1938 | 1938 |
| 1939 void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() { | 1939 void test_unexpectedToken_semicolonBetweenCompilationUnitMembers() { |
| 1940 ParserTestCase.parseCompilationUnit( | 1940 ParserTestCase.parseCompilationUnit( |
| 1941 "int x; ; int y;", [ParserErrorCode.UNEXPECTED_TOKEN]); | 1941 "int x; ; int y;", [ParserErrorCode.UNEXPECTED_TOKEN]); |
| 1942 } | 1942 } |
| 1943 | 1943 |
| 1944 void test_unterminatedString_at_eof() { |
| 1945 // Although the "unterminated string" error message is produced by the |
| 1946 // scanner, we need to verify that the parser can handle the tokens |
| 1947 // produced by the scanner when an unterminated string is encountered. |
| 1948 ParserTestCase.parseCompilationUnit(r''' |
| 1949 void main() { |
| 1950 var x = "''', [ |
| 1951 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, |
| 1952 ParserErrorCode.EXPECTED_TOKEN, |
| 1953 ParserErrorCode.EXPECTED_TOKEN |
| 1954 ]); |
| 1955 } |
| 1956 |
| 1957 void test_unterminatedString_at_eol() { |
| 1958 // Although the "unterminated string" error message is produced by the |
| 1959 // scanner, we need to verify that the parser can handle the tokens |
| 1960 // produced by the scanner when an unterminated string is encountered. |
| 1961 ParserTestCase.parseCompilationUnit(r''' |
| 1962 void main() { |
| 1963 var x = " |
| 1964 ; |
| 1965 } |
| 1966 ''', [ScannerErrorCode.UNTERMINATED_STRING_LITERAL]); |
| 1967 } |
| 1968 |
| 1969 void test_unterminatedString_multiline_at_eof_3_quotes() { |
| 1970 // Although the "unterminated string" error message is produced by the |
| 1971 // scanner, we need to verify that the parser can handle the tokens |
| 1972 // produced by the scanner when an unterminated string is encountered. |
| 1973 ParserTestCase.parseCompilationUnit(r''' |
| 1974 void main() { |
| 1975 var x = """''', [ |
| 1976 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, |
| 1977 ParserErrorCode.EXPECTED_TOKEN, |
| 1978 ParserErrorCode.EXPECTED_TOKEN |
| 1979 ]); |
| 1980 } |
| 1981 |
| 1982 void test_unterminatedString_multiline_at_eof_4_quotes() { |
| 1983 // Although the "unterminated string" error message is produced by the |
| 1984 // scanner, we need to verify that the parser can handle the tokens |
| 1985 // produced by the scanner when an unterminated string is encountered. |
| 1986 ParserTestCase.parseCompilationUnit(r''' |
| 1987 void main() { |
| 1988 var x = """"''', [ |
| 1989 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, |
| 1990 ParserErrorCode.EXPECTED_TOKEN, |
| 1991 ParserErrorCode.EXPECTED_TOKEN |
| 1992 ]); |
| 1993 } |
| 1994 |
| 1995 void test_unterminatedString_multiline_at_eof_5_quotes() { |
| 1996 // Although the "unterminated string" error message is produced by the |
| 1997 // scanner, we need to verify that the parser can handle the tokens |
| 1998 // produced by the scanner when an unterminated string is encountered. |
| 1999 ParserTestCase.parseCompilationUnit(r''' |
| 2000 void main() { |
| 2001 var x = """""''', [ |
| 2002 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, |
| 2003 ParserErrorCode.EXPECTED_TOKEN, |
| 2004 ParserErrorCode.EXPECTED_TOKEN |
| 2005 ]); |
| 2006 } |
| 2007 |
| 1944 void test_useOfUnaryPlusOperator() { | 2008 void test_useOfUnaryPlusOperator() { |
| 1945 SimpleIdentifier expression = parse4( | 2009 SimpleIdentifier expression = parse4( |
| 1946 "parseUnaryExpression", "+x", [ParserErrorCode.MISSING_IDENTIFIER]); | 2010 "parseUnaryExpression", "+x", [ParserErrorCode.MISSING_IDENTIFIER]); |
| 1947 EngineTestCase.assertInstanceOf( | 2011 EngineTestCase.assertInstanceOf( |
| 1948 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression); | 2012 (obj) => obj is SimpleIdentifier, SimpleIdentifier, expression); |
| 1949 expect(expression.isSynthetic, isTrue); | 2013 expect(expression.isSynthetic, isTrue); |
| 1950 } | 2014 } |
| 1951 | 2015 |
| 1952 void test_varAndType_field() { | 2016 void test_varAndType_field() { |
| 1953 ParserTestCase.parseCompilationUnit( | 2017 ParserTestCase.parseCompilationUnit( |
| (...skipping 8193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10147 new Scanner(null, new CharSequenceReader(source), listener); | 10211 new Scanner(null, new CharSequenceReader(source), listener); |
| 10148 Token tokenStream = scanner.tokenize(); | 10212 Token tokenStream = scanner.tokenize(); |
| 10149 // | 10213 // |
| 10150 // Parse the source. | 10214 // Parse the source. |
| 10151 // | 10215 // |
| 10152 Parser parser = new Parser(null, listener); | 10216 Parser parser = new Parser(null, listener); |
| 10153 return invokeParserMethodImpl( | 10217 return invokeParserMethodImpl( |
| 10154 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 10218 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
| 10155 } | 10219 } |
| 10156 } | 10220 } |
| OLD | NEW |