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

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

Issue 247053004: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.parser_test; 8 library engine.parser_test;
9 9
10 import 'package:analyzer/src/generated/java_core.dart'; 10 import 'package:analyzer/src/generated/java_core.dart';
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 } 1923 }
1924 1924
1925 void test_parseDirective_partOf() { 1925 void test_parseDirective_partOf() {
1926 PartOfDirective directive = ParserTestCase.parse("parseDirective", <Object> [emptyCommentAndMetadata()], "part of l;"); 1926 PartOfDirective directive = ParserTestCase.parse("parseDirective", <Object> [emptyCommentAndMetadata()], "part of l;");
1927 JUnitTestCase.assertNotNull(directive.partToken); 1927 JUnitTestCase.assertNotNull(directive.partToken);
1928 JUnitTestCase.assertNotNull(directive.ofToken); 1928 JUnitTestCase.assertNotNull(directive.ofToken);
1929 JUnitTestCase.assertNotNull(directive.libraryName); 1929 JUnitTestCase.assertNotNull(directive.libraryName);
1930 JUnitTestCase.assertNotNull(directive.semicolon); 1930 JUnitTestCase.assertNotNull(directive.semicolon);
1931 } 1931 }
1932 1932
1933 void test_parseDirectives_complete() {
1934 CompilationUnit unit = _parseDirectives("#! /bin/dart\nlibrary l;\nclass A { }", []);
1935 JUnitTestCase.assertNotNull(unit.scriptTag);
1936 EngineTestCase.assertSizeOfList(1, unit.directives);
1937 }
1938
1939 void test_parseDirectives_empty() {
1940 CompilationUnit unit = _parseDirectives("", []);
1941 JUnitTestCase.assertNull(unit.scriptTag);
1942 EngineTestCase.assertSizeOfList(0, unit.directives);
1943 }
1944
1945 void test_parseDirectives_mixed() {
1946 CompilationUnit unit = _parseDirectives("library l; class A {} part 'foo.dar t';", []);
1947 JUnitTestCase.assertNull(unit.scriptTag);
1948 EngineTestCase.assertSizeOfList(1, unit.directives);
1949 }
1950
1951 void test_parseDirectives_multiple() {
1952 CompilationUnit unit = _parseDirectives("library l;\npart 'a.dart';", []);
1953 JUnitTestCase.assertNull(unit.scriptTag);
1954 EngineTestCase.assertSizeOfList(2, unit.directives);
1955 }
1956
1957 void test_parseDirectives_script() {
1958 CompilationUnit unit = _parseDirectives("#! /bin/dart", []);
1959 JUnitTestCase.assertNotNull(unit.scriptTag);
1960 EngineTestCase.assertSizeOfList(0, unit.directives);
1961 }
1962
1963 void test_parseDirectives_single() {
1964 CompilationUnit unit = _parseDirectives("library l;", []);
1965 JUnitTestCase.assertNull(unit.scriptTag);
1966 EngineTestCase.assertSizeOfList(1, unit.directives);
1967 }
1968
1969 void test_parseDirectives_topLevelDeclaration() {
1970 CompilationUnit unit = _parseDirectives("class A {}", []);
1971 JUnitTestCase.assertNull(unit.scriptTag);
1972 EngineTestCase.assertSizeOfList(0, unit.directives);
1973 }
1974
1933 void test_parseDocumentationComment_block() { 1975 void test_parseDocumentationComment_block() {
1934 Comment comment = ParserTestCase.parse4("parseDocumentationComment", "/** */ class", []); 1976 Comment comment = ParserTestCase.parse4("parseDocumentationComment", "/** */ class", []);
1935 JUnitTestCase.assertFalse(comment.isBlock); 1977 JUnitTestCase.assertFalse(comment.isBlock);
1936 JUnitTestCase.assertTrue(comment.isDocumentation); 1978 JUnitTestCase.assertTrue(comment.isDocumentation);
1937 JUnitTestCase.assertFalse(comment.isEndOfLine); 1979 JUnitTestCase.assertFalse(comment.isEndOfLine);
1938 } 1980 }
1939 1981
1940 void test_parseDocumentationComment_block_withReference() { 1982 void test_parseDocumentationComment_block_withReference() {
1941 Comment comment = ParserTestCase.parse4("parseDocumentationComment", "/** [a ] */ class", []); 1983 Comment comment = ParserTestCase.parse4("parseDocumentationComment", "/** [a ] */ class", []);
1942 JUnitTestCase.assertFalse(comment.isBlock); 1984 JUnitTestCase.assertFalse(comment.isBlock);
(...skipping 2658 matching lines...) Expand 10 before | Expand all | Expand 10 after
4601 * @param source the source to be scanned to produce the token stream being te sted 4643 * @param source the source to be scanned to produce the token stream being te sted
4602 * @return the result of invoking the method 4644 * @return the result of invoking the method
4603 * @throws Exception if the method could not be invoked or throws an exception 4645 * @throws Exception if the method could not be invoked or throws an exception
4604 */ 4646 */
4605 bool _isSwitchMember(String source) { 4647 bool _isSwitchMember(String source) {
4606 GatheringErrorListener listener = new GatheringErrorListener(); 4648 GatheringErrorListener listener = new GatheringErrorListener();
4607 return ParserTestCase.invokeParserMethod2("isSwitchMember", source, listener ) as bool; 4649 return ParserTestCase.invokeParserMethod2("isSwitchMember", source, listener ) as bool;
4608 } 4650 }
4609 4651
4610 /** 4652 /**
4653 * Parse the given source as a compilation unit.
4654 *
4655 * @param source the source to be parsed
4656 * @param errorCodes the error codes of the errors that are expected to be fou nd
4657 * @return the compilation unit that was parsed
4658 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do
4659 * not match those that are expected, or if the result would have be en `null`
4660 */
4661 CompilationUnit _parseDirectives(String source, List<ErrorCode> errorCodes) {
4662 GatheringErrorListener listener = new GatheringErrorListener();
4663 Scanner scanner = new Scanner(null, new CharSequenceReader(source), listener );
4664 listener.setLineInfo(new TestSource(), scanner.lineStarts);
4665 Token token = scanner.tokenize();
4666 Parser parser = new Parser(null, listener);
4667 CompilationUnit unit = parser.parseDirectives(token);
4668 JUnitTestCase.assertNotNull(unit);
4669 EngineTestCase.assertSizeOfList(0, unit.declarations);
4670 listener.assertErrorsWithCodes(errorCodes);
4671 return unit;
4672 }
4673
4674 /**
4611 * Invoke a "skip" method in [Parser]. The method is assumed to take a token a s it's 4675 * Invoke a "skip" method in [Parser]. The method is assumed to take a token a s it's
4612 * parameter and is given the first token in the scanned source. 4676 * parameter and is given the first token in the scanned source.
4613 * 4677 *
4614 * @param methodName the name of the method that should be invoked 4678 * @param methodName the name of the method that should be invoked
4615 * @param source the source to be processed by the method 4679 * @param source the source to be processed by the method
4616 * @return the result of invoking the method 4680 * @return the result of invoking the method
4617 * @throws Exception if the method could not be invoked or throws an exception 4681 * @throws Exception if the method could not be invoked or throws an exception
4618 * @throws AssertionFailedError if the result is `null` 4682 * @throws AssertionFailedError if the result is `null`
4619 */ 4683 */
4620 Token _skip(String methodName, String source) { 4684 Token _skip(String methodName, String source) {
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
5606 runJUnitTest(__test, __test.test_parseDirective_library); 5670 runJUnitTest(__test, __test.test_parseDirective_library);
5607 }); 5671 });
5608 _ut.test('test_parseDirective_part', () { 5672 _ut.test('test_parseDirective_part', () {
5609 final __test = new SimpleParserTest(); 5673 final __test = new SimpleParserTest();
5610 runJUnitTest(__test, __test.test_parseDirective_part); 5674 runJUnitTest(__test, __test.test_parseDirective_part);
5611 }); 5675 });
5612 _ut.test('test_parseDirective_partOf', () { 5676 _ut.test('test_parseDirective_partOf', () {
5613 final __test = new SimpleParserTest(); 5677 final __test = new SimpleParserTest();
5614 runJUnitTest(__test, __test.test_parseDirective_partOf); 5678 runJUnitTest(__test, __test.test_parseDirective_partOf);
5615 }); 5679 });
5680 _ut.test('test_parseDirectives_complete', () {
5681 final __test = new SimpleParserTest();
5682 runJUnitTest(__test, __test.test_parseDirectives_complete);
5683 });
5684 _ut.test('test_parseDirectives_empty', () {
5685 final __test = new SimpleParserTest();
5686 runJUnitTest(__test, __test.test_parseDirectives_empty);
5687 });
5688 _ut.test('test_parseDirectives_mixed', () {
5689 final __test = new SimpleParserTest();
5690 runJUnitTest(__test, __test.test_parseDirectives_mixed);
5691 });
5692 _ut.test('test_parseDirectives_multiple', () {
5693 final __test = new SimpleParserTest();
5694 runJUnitTest(__test, __test.test_parseDirectives_multiple);
5695 });
5696 _ut.test('test_parseDirectives_script', () {
5697 final __test = new SimpleParserTest();
5698 runJUnitTest(__test, __test.test_parseDirectives_script);
5699 });
5700 _ut.test('test_parseDirectives_single', () {
5701 final __test = new SimpleParserTest();
5702 runJUnitTest(__test, __test.test_parseDirectives_single);
5703 });
5704 _ut.test('test_parseDirectives_topLevelDeclaration', () {
5705 final __test = new SimpleParserTest();
5706 runJUnitTest(__test, __test.test_parseDirectives_topLevelDeclaration);
5707 });
5616 _ut.test('test_parseDoStatement', () { 5708 _ut.test('test_parseDoStatement', () {
5617 final __test = new SimpleParserTest(); 5709 final __test = new SimpleParserTest();
5618 runJUnitTest(__test, __test.test_parseDoStatement); 5710 runJUnitTest(__test, __test.test_parseDoStatement);
5619 }); 5711 });
5620 _ut.test('test_parseDocumentationComment_block', () { 5712 _ut.test('test_parseDocumentationComment_block', () {
5621 final __test = new SimpleParserTest(); 5713 final __test = new SimpleParserTest();
5622 runJUnitTest(__test, __test.test_parseDocumentationComment_block); 5714 runJUnitTest(__test, __test.test_parseDocumentationComment_block);
5623 }); 5715 });
5624 _ut.test('test_parseDocumentationComment_block_withReference', () { 5716 _ut.test('test_parseDocumentationComment_block_withReference', () {
5625 final __test = new SimpleParserTest(); 5717 final __test = new SimpleParserTest();
(...skipping 6243 matching lines...) Expand 10 before | Expand all | Expand 10 after
11869 11961
11870 main() { 11962 main() {
11871 ComplexParserTest.dartSuite(); 11963 ComplexParserTest.dartSuite();
11872 ErrorParserTest.dartSuite(); 11964 ErrorParserTest.dartSuite();
11873 IncrementalParserTest.dartSuite(); 11965 IncrementalParserTest.dartSuite();
11874 NonErrorParserTest.dartSuite(); 11966 NonErrorParserTest.dartSuite();
11875 RecoveryParserTest.dartSuite(); 11967 RecoveryParserTest.dartSuite();
11876 ResolutionCopierTest.dartSuite(); 11968 ResolutionCopierTest.dartSuite();
11877 SimpleParserTest.dartSuite(); 11969 SimpleParserTest.dartSuite();
11878 } 11970 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698