| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:front_end/src/base/errors.dart'; | 5 import 'package:front_end/src/base/errors.dart'; |
| 6 import 'package:front_end/src/base/jenkins_smi_hash.dart'; | 6 import 'package:front_end/src/base/jenkins_smi_hash.dart'; |
| 7 import 'package:front_end/src/scanner/errors.dart'; | 7 import 'package:front_end/src/scanner/errors.dart'; |
| 8 import 'package:front_end/src/scanner/reader.dart'; | 8 import 'package:front_end/src/scanner/reader.dart'; |
| 9 import 'package:front_end/src/scanner/scanner.dart'; | 9 import 'package:front_end/src/scanner/scanner.dart'; |
| 10 import 'package:front_end/src/scanner/token.dart'; | 10 import 'package:front_end/src/scanner/token.dart'; |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 } | 810 } |
| 811 | 811 |
| 812 void test_open_paren() { | 812 void test_open_paren() { |
| 813 _assertToken(TokenType.OPEN_PAREN, "("); | 813 _assertToken(TokenType.OPEN_PAREN, "("); |
| 814 } | 814 } |
| 815 | 815 |
| 816 void test_open_square_bracket() { | 816 void test_open_square_bracket() { |
| 817 _assertToken(TokenType.OPEN_SQUARE_BRACKET, "["); | 817 _assertToken(TokenType.OPEN_SQUARE_BRACKET, "["); |
| 818 } | 818 } |
| 819 | 819 |
| 820 void test_openSquareBracket() { | |
| 821 _assertToken(TokenType.OPEN_SQUARE_BRACKET, "["); | |
| 822 } | |
| 823 | |
| 824 void test_percent() { | 820 void test_percent() { |
| 825 _assertToken(TokenType.PERCENT, "%"); | 821 _assertToken(TokenType.PERCENT, "%"); |
| 826 } | 822 } |
| 827 | 823 |
| 828 void test_percent_eq() { | 824 void test_percent_eq() { |
| 829 _assertToken(TokenType.PERCENT_EQ, "%="); | 825 _assertToken(TokenType.PERCENT_EQ, "%="); |
| 830 } | 826 } |
| 831 | 827 |
| 832 void test_period() { | 828 void test_period() { |
| 833 _assertToken(TokenType.PERIOD, "."); | 829 _assertToken(TokenType.PERIOD, "."); |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 expect(tokenWithUpperD.length, source.length); | 1353 expect(tokenWithUpperD.length, source.length); |
| 1358 expect(tokenWithUpperD.lexeme, source); | 1354 expect(tokenWithUpperD.lexeme, source); |
| 1359 } | 1355 } |
| 1360 Token tokenWithSpaces = | 1356 Token tokenWithSpaces = |
| 1361 _scan(" $source ", lazyAssignmentOperators: lazyAssignmentOperators); | 1357 _scan(" $source ", lazyAssignmentOperators: lazyAssignmentOperators); |
| 1362 expect(tokenWithSpaces, isNotNull); | 1358 expect(tokenWithSpaces, isNotNull); |
| 1363 expect(tokenWithSpaces.type, expectedType); | 1359 expect(tokenWithSpaces.type, expectedType); |
| 1364 expect(tokenWithSpaces.offset, 1); | 1360 expect(tokenWithSpaces.offset, 1); |
| 1365 expect(tokenWithSpaces.length, source.length); | 1361 expect(tokenWithSpaces.length, source.length); |
| 1366 expect(tokenWithSpaces.lexeme, source); | 1362 expect(tokenWithSpaces.lexeme, source); |
| 1367 expect(originalToken.next.type, TokenType.EOF); | 1363 |
| 1364 // Fasta inserts missing closers (']', '}', ')') |
| 1365 //expect(originalToken.next.type, TokenType.EOF); |
| 1368 return originalToken; | 1366 return originalToken; |
| 1369 } | 1367 } |
| 1370 | 1368 |
| 1371 /** | 1369 /** |
| 1372 * Assert that when scanned the given [source] contains a sequence of tokens | 1370 * Assert that when scanned the given [source] contains a sequence of tokens |
| 1373 * identical to the given list of [expectedTokens]. | 1371 * identical to the given list of [expectedTokens]. |
| 1374 */ | 1372 */ |
| 1375 void _assertTokens(String source, List<Token> expectedTokens) { | 1373 void _assertTokens(String source, List<Token> expectedTokens) { |
| 1376 Token token = _scan(source); | 1374 Token token = _scan(source); |
| 1377 _checkTokens(token, expectedTokens); | 1375 _checkTokens(token, expectedTokens); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 _TestScanner(CharacterReader reader, [this.listener]) : super(reader); | 1519 _TestScanner(CharacterReader reader, [this.listener]) : super(reader); |
| 1522 | 1520 |
| 1523 @override | 1521 @override |
| 1524 void reportError( | 1522 void reportError( |
| 1525 ScannerErrorCode errorCode, int offset, List<Object> arguments) { | 1523 ScannerErrorCode errorCode, int offset, List<Object> arguments) { |
| 1526 if (listener != null) { | 1524 if (listener != null) { |
| 1527 listener.errors.add(new TestError(offset, errorCode, arguments)); | 1525 listener.errors.add(new TestError(offset, errorCode, arguments)); |
| 1528 } | 1526 } |
| 1529 } | 1527 } |
| 1530 } | 1528 } |
| OLD | NEW |