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

Side by Side Diff: pkg/analyzer_experimental/test/generated/scanner_test.dart

Issue 17932005: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Disable resolver tests Created 7 years, 5 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine.scanner_test; 3 library engine.scanner_test;
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'package:analyzer_experimental/src/generated/java_core.dart'; 5 import 'package:analyzer_experimental/src/generated/java_core.dart';
6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 6 import 'package:analyzer_experimental/src/generated/java_engine.dart';
7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 7 import 'package:analyzer_experimental/src/generated/java_junit.dart';
8 import 'package:analyzer_experimental/src/generated/source.dart'; 8 import 'package:analyzer_experimental/src/generated/source.dart';
9 import 'package:analyzer_experimental/src/generated/error.dart'; 9 import 'package:analyzer_experimental/src/generated/error.dart';
10 import 'package:analyzer_experimental/src/generated/scanner.dart'; 10 import 'package:analyzer_experimental/src/generated/scanner.dart';
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 runJUnitTest(__test, __test.test_hexidecimal); 332 runJUnitTest(__test, __test.test_hexidecimal);
333 }); 333 });
334 _ut.test('test_hexidecimal_missingDigit', () { 334 _ut.test('test_hexidecimal_missingDigit', () {
335 final __test = new CharBufferScannerTest(); 335 final __test = new CharBufferScannerTest();
336 runJUnitTest(__test, __test.test_hexidecimal_missingDigit); 336 runJUnitTest(__test, __test.test_hexidecimal_missingDigit);
337 }); 337 });
338 _ut.test('test_identifier', () { 338 _ut.test('test_identifier', () {
339 final __test = new CharBufferScannerTest(); 339 final __test = new CharBufferScannerTest();
340 runJUnitTest(__test, __test.test_identifier); 340 runJUnitTest(__test, __test.test_identifier);
341 }); 341 });
342 _ut.test('test_illegalChar', () { 342 _ut.test('test_illegalChar_cyrillicLetter_middle', () {
343 final __test = new CharBufferScannerTest(); 343 final __test = new CharBufferScannerTest();
344 runJUnitTest(__test, __test.test_illegalChar); 344 runJUnitTest(__test, __test.test_illegalChar_cyrillicLetter_middle);
345 });
346 _ut.test('test_illegalChar_cyrillicLetter_start', () {
347 final __test = new CharBufferScannerTest();
348 runJUnitTest(__test, __test.test_illegalChar_cyrillicLetter_start);
349 });
350 _ut.test('test_illegalChar_notLetter', () {
351 final __test = new CharBufferScannerTest();
352 runJUnitTest(__test, __test.test_illegalChar_notLetter);
345 }); 353 });
346 _ut.test('test_index', () { 354 _ut.test('test_index', () {
347 final __test = new CharBufferScannerTest(); 355 final __test = new CharBufferScannerTest();
348 runJUnitTest(__test, __test.test_index); 356 runJUnitTest(__test, __test.test_index);
349 }); 357 });
350 _ut.test('test_index_eq', () { 358 _ut.test('test_index_eq', () {
351 final __test = new CharBufferScannerTest(); 359 final __test = new CharBufferScannerTest();
352 runJUnitTest(__test, __test.test_index_eq); 360 runJUnitTest(__test, __test.test_index_eq);
353 }); 361 });
354 _ut.test('test_int', () { 362 _ut.test('test_int', () {
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 runJUnitTest(__test, __test.test_hexidecimal); 1011 runJUnitTest(__test, __test.test_hexidecimal);
1004 }); 1012 });
1005 _ut.test('test_hexidecimal_missingDigit', () { 1013 _ut.test('test_hexidecimal_missingDigit', () {
1006 final __test = new StringScannerTest(); 1014 final __test = new StringScannerTest();
1007 runJUnitTest(__test, __test.test_hexidecimal_missingDigit); 1015 runJUnitTest(__test, __test.test_hexidecimal_missingDigit);
1008 }); 1016 });
1009 _ut.test('test_identifier', () { 1017 _ut.test('test_identifier', () {
1010 final __test = new StringScannerTest(); 1018 final __test = new StringScannerTest();
1011 runJUnitTest(__test, __test.test_identifier); 1019 runJUnitTest(__test, __test.test_identifier);
1012 }); 1020 });
1013 _ut.test('test_illegalChar', () { 1021 _ut.test('test_illegalChar_cyrillicLetter_middle', () {
1014 final __test = new StringScannerTest(); 1022 final __test = new StringScannerTest();
1015 runJUnitTest(__test, __test.test_illegalChar); 1023 runJUnitTest(__test, __test.test_illegalChar_cyrillicLetter_middle);
1024 });
1025 _ut.test('test_illegalChar_cyrillicLetter_start', () {
1026 final __test = new StringScannerTest();
1027 runJUnitTest(__test, __test.test_illegalChar_cyrillicLetter_start);
1028 });
1029 _ut.test('test_illegalChar_notLetter', () {
1030 final __test = new StringScannerTest();
1031 runJUnitTest(__test, __test.test_illegalChar_notLetter);
1016 }); 1032 });
1017 _ut.test('test_index', () { 1033 _ut.test('test_index', () {
1018 final __test = new StringScannerTest(); 1034 final __test = new StringScannerTest();
1019 runJUnitTest(__test, __test.test_index); 1035 runJUnitTest(__test, __test.test_index);
1020 }); 1036 });
1021 _ut.test('test_index_eq', () { 1037 _ut.test('test_index_eq', () {
1022 final __test = new StringScannerTest(); 1038 final __test = new StringScannerTest();
1023 runJUnitTest(__test, __test.test_index_eq); 1039 runJUnitTest(__test, __test.test_index_eq);
1024 }); 1040 });
1025 _ut.test('test_int', () { 1041 _ut.test('test_int', () {
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 } 1490 }
1475 } 1491 }
1476 /** 1492 /**
1477 * Instances of the class `TokenStreamValidator` are used to validate the correc t construction 1493 * Instances of the class `TokenStreamValidator` are used to validate the correc t construction
1478 * of a stream of tokens. 1494 * of a stream of tokens.
1479 */ 1495 */
1480 class TokenStreamValidator { 1496 class TokenStreamValidator {
1481 1497
1482 /** 1498 /**
1483 * Validate that the stream of tokens that starts with the given token is corr ect. 1499 * Validate that the stream of tokens that starts with the given token is corr ect.
1500 *
1484 * @param token the first token in the stream of tokens to be validated 1501 * @param token the first token in the stream of tokens to be validated
1485 */ 1502 */
1486 void validate(Token token) { 1503 void validate(Token token) {
1487 JavaStringBuilder builder = new JavaStringBuilder(); 1504 JavaStringBuilder builder = new JavaStringBuilder();
1488 validateStream(builder, token); 1505 validateStream(builder, token);
1489 if (builder.length > 0) { 1506 if (builder.length > 0) {
1490 JUnitTestCase.fail(builder.toString()); 1507 JUnitTestCase.fail(builder.toString());
1491 } 1508 }
1492 } 1509 }
1493 void validateStream(JavaStringBuilder builder, Token token) { 1510 void validateStream(JavaStringBuilder builder, Token token) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 } 1689 }
1673 void test_hexidecimal() { 1690 void test_hexidecimal() {
1674 assertToken(TokenType.HEXADECIMAL, "0x1A2B3C"); 1691 assertToken(TokenType.HEXADECIMAL, "0x1A2B3C");
1675 } 1692 }
1676 void test_hexidecimal_missingDigit() { 1693 void test_hexidecimal_missingDigit() {
1677 assertError(ScannerErrorCode.MISSING_HEX_DIGIT, 1, "0x"); 1694 assertError(ScannerErrorCode.MISSING_HEX_DIGIT, 1, "0x");
1678 } 1695 }
1679 void test_identifier() { 1696 void test_identifier() {
1680 assertToken(TokenType.IDENTIFIER, "result"); 1697 assertToken(TokenType.IDENTIFIER, "result");
1681 } 1698 }
1682 void test_illegalChar() { 1699 void test_illegalChar_cyrillicLetter_middle() {
1700 assertError(ScannerErrorCode.ILLEGAL_CHARACTER, 0, "Shche\u0433lov");
1701 }
1702 void test_illegalChar_cyrillicLetter_start() {
1703 assertError(ScannerErrorCode.ILLEGAL_CHARACTER, 0, "\u0429");
1704 }
1705 void test_illegalChar_notLetter() {
1683 assertError(ScannerErrorCode.ILLEGAL_CHARACTER, 0, "\u0312"); 1706 assertError(ScannerErrorCode.ILLEGAL_CHARACTER, 0, "\u0312");
1684 } 1707 }
1685 void test_index() { 1708 void test_index() {
1686 assertToken(TokenType.INDEX, "[]"); 1709 assertToken(TokenType.INDEX, "[]");
1687 } 1710 }
1688 void test_index_eq() { 1711 void test_index_eq() {
1689 assertToken(TokenType.INDEX_EQ, "[]="); 1712 assertToken(TokenType.INDEX_EQ, "[]=");
1690 } 1713 }
1691 void test_int() { 1714 void test_int() {
1692 assertToken(TokenType.INT, "123"); 1715 assertToken(TokenType.INT, "123");
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 Token comment = token.precedingComments; 2062 Token comment = token.precedingComments;
2040 JUnitTestCase.assertNotNull(comment); 2063 JUnitTestCase.assertNotNull(comment);
2041 JUnitTestCase.assertEquals(commentType, comment.type); 2064 JUnitTestCase.assertEquals(commentType, comment.type);
2042 JUnitTestCase.assertEquals(0, comment.offset); 2065 JUnitTestCase.assertEquals(0, comment.offset);
2043 JUnitTestCase.assertEquals(source.length, comment.length); 2066 JUnitTestCase.assertEquals(source.length, comment.length);
2044 JUnitTestCase.assertEquals(source, comment.lexeme); 2067 JUnitTestCase.assertEquals(source, comment.lexeme);
2045 } 2068 }
2046 2069
2047 /** 2070 /**
2048 * Assert that scanning the given source produces an error with the given code . 2071 * Assert that scanning the given source produces an error with the given code .
2072 *
2049 * @param illegalCharacter 2073 * @param illegalCharacter
2050 * @param i 2074 * @param i
2051 * @param source the source to be scanned to produce the error 2075 * @param source the source to be scanned to produce the error
2052 */ 2076 */
2053 void assertError(ScannerErrorCode expectedError, int expectedOffset, String so urce) { 2077 void assertError(ScannerErrorCode expectedError, int expectedOffset, String so urce) {
2054 GatheringErrorListener listener = new GatheringErrorListener(); 2078 GatheringErrorListener listener = new GatheringErrorListener();
2055 scan(source, listener); 2079 scan(source, listener);
2056 listener.assertErrors([new AnalysisError.con2(null, expectedOffset, 1, expec tedError, [(source.codeUnitAt(expectedOffset) as int)])]); 2080 listener.assertErrors([new AnalysisError.con2(null, expectedOffset, 1, expec tedError, [(source.codeUnitAt(expectedOffset) as int)])]);
2057 } 2081 }
2058 2082
2059 /** 2083 /**
2060 * Assert that when scanned the given source contains a single keyword token w ith the same lexeme 2084 * Assert that when scanned the given source contains a single keyword token w ith the same lexeme
2061 * as the original source. 2085 * as the original source.
2086 *
2062 * @param source the source to be scanned 2087 * @param source the source to be scanned
2063 */ 2088 */
2064 void assertKeywordToken(String source) { 2089 void assertKeywordToken(String source) {
2065 Token token = scan2(source); 2090 Token token = scan2(source);
2066 JUnitTestCase.assertNotNull(token); 2091 JUnitTestCase.assertNotNull(token);
2067 JUnitTestCase.assertEquals(TokenType.KEYWORD, token.type); 2092 JUnitTestCase.assertEquals(TokenType.KEYWORD, token.type);
2068 JUnitTestCase.assertEquals(0, token.offset); 2093 JUnitTestCase.assertEquals(0, token.offset);
2069 JUnitTestCase.assertEquals(source.length, token.length); 2094 JUnitTestCase.assertEquals(source.length, token.length);
2070 JUnitTestCase.assertEquals(source, token.lexeme); 2095 JUnitTestCase.assertEquals(source, token.lexeme);
2071 Object value = token.value(); 2096 Object value = token.value();
(...skipping 18 matching lines...) Expand all
2090 JUnitTestCase.assertNotNull(info); 2115 JUnitTestCase.assertNotNull(info);
2091 for (AbstractScannerTest_ExpectedLocation expectedLocation in expectedLocati ons) { 2116 for (AbstractScannerTest_ExpectedLocation expectedLocation in expectedLocati ons) {
2092 LineInfo_Location location = info.getLocation(expectedLocation._offset); 2117 LineInfo_Location location = info.getLocation(expectedLocation._offset);
2093 JUnitTestCase.assertEquals(expectedLocation._lineNumber, location.lineNumb er); 2118 JUnitTestCase.assertEquals(expectedLocation._lineNumber, location.lineNumb er);
2094 JUnitTestCase.assertEquals(expectedLocation._columnNumber, location.column Number); 2119 JUnitTestCase.assertEquals(expectedLocation._columnNumber, location.column Number);
2095 } 2120 }
2096 } 2121 }
2097 2122
2098 /** 2123 /**
2099 * Assert that the token scanned from the given source has the expected type. 2124 * Assert that the token scanned from the given source has the expected type.
2125 *
2100 * @param expectedType the expected type of the token 2126 * @param expectedType the expected type of the token
2101 * @param source the source to be scanned to produce the actual token 2127 * @param source the source to be scanned to produce the actual token
2102 */ 2128 */
2103 Token assertToken(TokenType expectedType, String source) { 2129 Token assertToken(TokenType expectedType, String source) {
2104 Token originalToken = scan2(source); 2130 Token originalToken = scan2(source);
2105 JUnitTestCase.assertNotNull(originalToken); 2131 JUnitTestCase.assertNotNull(originalToken);
2106 JUnitTestCase.assertEquals(expectedType, originalToken.type); 2132 JUnitTestCase.assertEquals(expectedType, originalToken.type);
2107 JUnitTestCase.assertEquals(0, originalToken.offset); 2133 JUnitTestCase.assertEquals(0, originalToken.offset);
2108 JUnitTestCase.assertEquals(source.length, originalToken.length); 2134 JUnitTestCase.assertEquals(source.length, originalToken.length);
2109 JUnitTestCase.assertEquals(source, originalToken.lexeme); 2135 JUnitTestCase.assertEquals(source, originalToken.lexeme);
(...skipping 14 matching lines...) Expand all
2124 JUnitTestCase.assertEquals(1, tokenWithSpaces.offset); 2150 JUnitTestCase.assertEquals(1, tokenWithSpaces.offset);
2125 JUnitTestCase.assertEquals(source.length, tokenWithSpaces.length); 2151 JUnitTestCase.assertEquals(source.length, tokenWithSpaces.length);
2126 JUnitTestCase.assertEquals(source, tokenWithSpaces.lexeme); 2152 JUnitTestCase.assertEquals(source, tokenWithSpaces.lexeme);
2127 JUnitTestCase.assertEquals(TokenType.EOF, originalToken.next.type); 2153 JUnitTestCase.assertEquals(TokenType.EOF, originalToken.next.type);
2128 return originalToken; 2154 return originalToken;
2129 } 2155 }
2130 2156
2131 /** 2157 /**
2132 * Assert that when scanned the given source contains a sequence of tokens ide ntical to the given 2158 * Assert that when scanned the given source contains a sequence of tokens ide ntical to the given
2133 * tokens. 2159 * tokens.
2160 *
2134 * @param source the source to be scanned 2161 * @param source the source to be scanned
2135 * @param expectedTokens the tokens that are expected to be in the source 2162 * @param expectedTokens the tokens that are expected to be in the source
2136 */ 2163 */
2137 void assertTokens(String source, List<Token> expectedTokens) { 2164 void assertTokens(String source, List<Token> expectedTokens) {
2138 Token token = scan2(source); 2165 Token token = scan2(source);
2139 JUnitTestCase.assertNotNull(token); 2166 JUnitTestCase.assertNotNull(token);
2140 for (int i = 0; i < expectedTokens.length; i++) { 2167 for (int i = 0; i < expectedTokens.length; i++) {
2141 Token expectedToken = expectedTokens[i]; 2168 Token expectedToken = expectedTokens[i];
2142 JUnitTestCase.assertEqualsMsg("Wrong type for token ${i}", expectedToken.t ype, token.type); 2169 JUnitTestCase.assertEqualsMsg("Wrong type for token ${i}", expectedToken.t ype, token.type);
2143 JUnitTestCase.assertEqualsMsg("Wrong offset for token ${i}", expectedToken .offset, token.offset); 2170 JUnitTestCase.assertEqualsMsg("Wrong offset for token ${i}", expectedToken .offset, token.offset);
(...skipping 24 matching lines...) Expand all
2168 this._lineNumber = lineNumber; 2195 this._lineNumber = lineNumber;
2169 this._columnNumber = columnNumber; 2196 this._columnNumber = columnNumber;
2170 } 2197 }
2171 } 2198 }
2172 main() { 2199 main() {
2173 CharBufferScannerTest.dartSuite(); 2200 CharBufferScannerTest.dartSuite();
2174 KeywordStateTest.dartSuite(); 2201 KeywordStateTest.dartSuite();
2175 StringScannerTest.dartSuite(); 2202 StringScannerTest.dartSuite();
2176 TokenTypeTest.dartSuite(); 2203 TokenTypeTest.dartSuite();
2177 } 2204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698