| 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 // 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.scanner_test; | 8 library engine.scanner_test; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/java_core.dart'; | 10 import 'package:analyzer/src/generated/java_core.dart'; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 void _validateStream(JavaStringBuilder builder, Token token) { | 258 void _validateStream(JavaStringBuilder builder, Token token) { |
| 259 if (token == null) { | 259 if (token == null) { |
| 260 return; | 260 return; |
| 261 } | 261 } |
| 262 Token previousToken = null; | 262 Token previousToken = null; |
| 263 int previousEnd = -1; | 263 int previousEnd = -1; |
| 264 Token currentToken = token; | 264 Token currentToken = token; |
| 265 while (currentToken != null && currentToken.type != TokenType.EOF) { | 265 while (currentToken != null && currentToken.type != TokenType.EOF) { |
| 266 _validateStream(builder, currentToken.precedingComments); | 266 _validateStream(builder, currentToken.precedingComments); |
| 267 TokenType type = currentToken.type; | 267 TokenType type = currentToken.type; |
| 268 if (identical(type, TokenType.OPEN_CURLY_BRACKET) || identical(type, Token
Type.OPEN_PAREN) || identical(type, TokenType.OPEN_SQUARE_BRACKET) || identical(
type, TokenType.STRING_INTERPOLATION_EXPRESSION)) { | 268 if (type == TokenType.OPEN_CURLY_BRACKET || type == TokenType.OPEN_PAREN |
| type == TokenType.OPEN_SQUARE_BRACKET || type == TokenType.STRING_INTERPOLATIO
N_EXPRESSION) { |
| 269 if (currentToken is! BeginToken) { | 269 if (currentToken is! BeginToken) { |
| 270 builder.append("\r\nExpected BeginToken, found "); | 270 builder.append("\r\nExpected BeginToken, found "); |
| 271 builder.append(currentToken.runtimeType.toString()); | 271 builder.append(currentToken.runtimeType.toString()); |
| 272 builder.append(" "); | 272 builder.append(" "); |
| 273 _writeToken(builder, currentToken); | 273 _writeToken(builder, currentToken); |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 int currentStart = currentToken.offset; | 276 int currentStart = currentToken.offset; |
| 277 int currentLength = currentToken.length; | 277 int currentLength = currentToken.length; |
| 278 int currentEnd = currentStart + currentLength - 1; | 278 int currentEnd = currentStart + currentLength - 1; |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 * @param expectedType the expected type of the token | 1138 * @param expectedType the expected type of the token |
| 1139 * @param source the source to be scanned to produce the actual token | 1139 * @param source the source to be scanned to produce the actual token |
| 1140 */ | 1140 */ |
| 1141 Token _assertToken(TokenType expectedType, String source) { | 1141 Token _assertToken(TokenType expectedType, String source) { |
| 1142 Token originalToken = _scan(source); | 1142 Token originalToken = _scan(source); |
| 1143 JUnitTestCase.assertNotNull(originalToken); | 1143 JUnitTestCase.assertNotNull(originalToken); |
| 1144 JUnitTestCase.assertEquals(expectedType, originalToken.type); | 1144 JUnitTestCase.assertEquals(expectedType, originalToken.type); |
| 1145 JUnitTestCase.assertEquals(0, originalToken.offset); | 1145 JUnitTestCase.assertEquals(0, originalToken.offset); |
| 1146 JUnitTestCase.assertEquals(source.length, originalToken.length); | 1146 JUnitTestCase.assertEquals(source.length, originalToken.length); |
| 1147 JUnitTestCase.assertEquals(source, originalToken.lexeme); | 1147 JUnitTestCase.assertEquals(source, originalToken.lexeme); |
| 1148 if (identical(expectedType, TokenType.SCRIPT_TAG)) { | 1148 if (expectedType == TokenType.SCRIPT_TAG) { |
| 1149 // Adding space before the script tag is not allowed, and adding text at t
he end changes nothing. | 1149 // Adding space before the script tag is not allowed, and adding text at t
he end changes nothing. |
| 1150 return originalToken; | 1150 return originalToken; |
| 1151 } else if (identical(expectedType, TokenType.SINGLE_LINE_COMMENT)) { | 1151 } else if (expectedType == TokenType.SINGLE_LINE_COMMENT) { |
| 1152 // Adding space to an end-of-line comment changes the comment. | 1152 // Adding space to an end-of-line comment changes the comment. |
| 1153 Token tokenWithSpaces = _scan(" ${source}"); | 1153 Token tokenWithSpaces = _scan(" ${source}"); |
| 1154 JUnitTestCase.assertNotNull(tokenWithSpaces); | 1154 JUnitTestCase.assertNotNull(tokenWithSpaces); |
| 1155 JUnitTestCase.assertEquals(expectedType, tokenWithSpaces.type); | 1155 JUnitTestCase.assertEquals(expectedType, tokenWithSpaces.type); |
| 1156 JUnitTestCase.assertEquals(1, tokenWithSpaces.offset); | 1156 JUnitTestCase.assertEquals(1, tokenWithSpaces.offset); |
| 1157 JUnitTestCase.assertEquals(source.length, tokenWithSpaces.length); | 1157 JUnitTestCase.assertEquals(source.length, tokenWithSpaces.length); |
| 1158 JUnitTestCase.assertEquals(source, tokenWithSpaces.lexeme); | 1158 JUnitTestCase.assertEquals(source, tokenWithSpaces.lexeme); |
| 1159 return originalToken; | 1159 return originalToken; |
| 1160 } else if (identical(expectedType, TokenType.INT) || identical(expectedType,
TokenType.DOUBLE)) { | 1160 } else if (expectedType == TokenType.INT || expectedType == TokenType.DOUBLE
) { |
| 1161 Token tokenWithLowerD = _scan("${source}d"); | 1161 Token tokenWithLowerD = _scan("${source}d"); |
| 1162 JUnitTestCase.assertNotNull(tokenWithLowerD); | 1162 JUnitTestCase.assertNotNull(tokenWithLowerD); |
| 1163 JUnitTestCase.assertEquals(expectedType, tokenWithLowerD.type); | 1163 JUnitTestCase.assertEquals(expectedType, tokenWithLowerD.type); |
| 1164 JUnitTestCase.assertEquals(0, tokenWithLowerD.offset); | 1164 JUnitTestCase.assertEquals(0, tokenWithLowerD.offset); |
| 1165 JUnitTestCase.assertEquals(source.length, tokenWithLowerD.length); | 1165 JUnitTestCase.assertEquals(source.length, tokenWithLowerD.length); |
| 1166 JUnitTestCase.assertEquals(source, tokenWithLowerD.lexeme); | 1166 JUnitTestCase.assertEquals(source, tokenWithLowerD.lexeme); |
| 1167 Token tokenWithUpperD = _scan("${source}D"); | 1167 Token tokenWithUpperD = _scan("${source}D"); |
| 1168 JUnitTestCase.assertNotNull(tokenWithUpperD); | 1168 JUnitTestCase.assertNotNull(tokenWithUpperD); |
| 1169 JUnitTestCase.assertEquals(expectedType, tokenWithUpperD.type); | 1169 JUnitTestCase.assertEquals(expectedType, tokenWithUpperD.type); |
| 1170 JUnitTestCase.assertEquals(0, tokenWithUpperD.offset); | 1170 JUnitTestCase.assertEquals(0, tokenWithUpperD.offset); |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 }); | 1873 }); |
| 1874 }); | 1874 }); |
| 1875 } | 1875 } |
| 1876 } | 1876 } |
| 1877 | 1877 |
| 1878 /** | 1878 /** |
| 1879 * Instances of the class `ExpectedLocation` encode information about the expect
ed location | 1879 * Instances of the class `ExpectedLocation` encode information about the expect
ed location |
| 1880 * of a given offset in source code. | 1880 * of a given offset in source code. |
| 1881 */ | 1881 */ |
| 1882 class ScannerTest_ExpectedLocation { | 1882 class ScannerTest_ExpectedLocation { |
| 1883 int _offset = 0; | 1883 final int _offset; |
| 1884 | 1884 |
| 1885 int _lineNumber = 0; | 1885 final int _lineNumber; |
| 1886 | 1886 |
| 1887 int _columnNumber = 0; | 1887 final int _columnNumber; |
| 1888 | 1888 |
| 1889 ScannerTest_ExpectedLocation(int offset, int lineNumber, int columnNumber) { | 1889 ScannerTest_ExpectedLocation(this._offset, this._lineNumber, this._columnNumbe
r); |
| 1890 this._offset = offset; | |
| 1891 this._lineNumber = lineNumber; | |
| 1892 this._columnNumber = columnNumber; | |
| 1893 } | |
| 1894 } | 1890 } |
| 1895 | 1891 |
| 1896 class IncrementalScannerTest extends EngineTestCase { | 1892 class IncrementalScannerTest extends EngineTestCase { |
| 1897 /** | 1893 /** |
| 1898 * The first token from the token stream resulting from parsing the original s
ource, or | 1894 * The first token from the token stream resulting from parsing the original s
ource, or |
| 1899 * `null` if [scan] has not been invoked. | 1895 * `null` if [scan] has not been invoked. |
| 1900 */ | 1896 */ |
| 1901 Token _originalTokens; | 1897 Token _originalTokens; |
| 1902 | 1898 |
| 1903 /** | 1899 /** |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2414 } | 2410 } |
| 2415 } | 2411 } |
| 2416 | 2412 |
| 2417 main() { | 2413 main() { |
| 2418 CharSequenceReaderTest.dartSuite(); | 2414 CharSequenceReaderTest.dartSuite(); |
| 2419 IncrementalScannerTest.dartSuite(); | 2415 IncrementalScannerTest.dartSuite(); |
| 2420 KeywordStateTest.dartSuite(); | 2416 KeywordStateTest.dartSuite(); |
| 2421 ScannerTest.dartSuite(); | 2417 ScannerTest.dartSuite(); |
| 2422 TokenTypeTest.dartSuite(); | 2418 TokenTypeTest.dartSuite(); |
| 2423 } | 2419 } |
| OLD | NEW |