| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 @override | 129 @override |
| 130 Token scanWithListener(String source, ErrorListener listener, | 130 Token scanWithListener(String source, ErrorListener listener, |
| 131 {bool genericMethodComments: false, | 131 {bool genericMethodComments: false, |
| 132 bool lazyAssignmentOperators: false}) { | 132 bool lazyAssignmentOperators: false}) { |
| 133 Scanner scanner = | 133 Scanner scanner = |
| 134 new _TestScanner(new CharSequenceReader(source), listener); | 134 new _TestScanner(new CharSequenceReader(source), listener); |
| 135 scanner.scanGenericMethodComments = genericMethodComments; | 135 scanner.scanGenericMethodComments = genericMethodComments; |
| 136 scanner.scanLazyAssignmentOperators = lazyAssignmentOperators; | 136 scanner.scanLazyAssignmentOperators = lazyAssignmentOperators; |
| 137 return scanner.tokenize(); | 137 return scanner.tokenize(); |
| 138 } | 138 } |
| 139 | |
| 140 @override | |
| 141 @failingTest | |
| 142 void test_incomplete_string_interpolation() { | |
| 143 super.test_incomplete_string_interpolation(); | |
| 144 } | |
| 145 } | 139 } |
| 146 | 140 |
| 147 abstract class ScannerTestBase { | 141 abstract class ScannerTestBase { |
| 142 bool usingFasta = false; |
| 143 |
| 148 Token scanWithListener(String source, ErrorListener listener, | 144 Token scanWithListener(String source, ErrorListener listener, |
| 149 {bool genericMethodComments: false, bool lazyAssignmentOperators: false}); | 145 {bool genericMethodComments: false, bool lazyAssignmentOperators: false}); |
| 150 | 146 |
| 151 void test_ampersand() { | 147 void test_ampersand() { |
| 152 _assertToken(TokenType.AMPERSAND, "&"); | 148 _assertToken(TokenType.AMPERSAND, "&"); |
| 153 } | 149 } |
| 154 | 150 |
| 155 void test_ampersand_ampersand() { | 151 void test_ampersand_ampersand() { |
| 156 _assertToken(TokenType.AMPERSAND_AMPERSAND, "&&"); | 152 _assertToken(TokenType.AMPERSAND_AMPERSAND, "&&"); |
| 157 } | 153 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 void test_illegalChar_nbsp() { | 423 void test_illegalChar_nbsp() { |
| 428 _assertError(ScannerErrorCode.ILLEGAL_CHARACTER, 0, "\u00A0", [0xa0]); | 424 _assertError(ScannerErrorCode.ILLEGAL_CHARACTER, 0, "\u00A0", [0xa0]); |
| 429 } | 425 } |
| 430 | 426 |
| 431 void test_illegalChar_notLetter() { | 427 void test_illegalChar_notLetter() { |
| 432 _assertError(ScannerErrorCode.ILLEGAL_CHARACTER, 0, "\u0312", [0x312]); | 428 _assertError(ScannerErrorCode.ILLEGAL_CHARACTER, 0, "\u0312", [0x312]); |
| 433 } | 429 } |
| 434 | 430 |
| 435 void test_incomplete_string_interpolation() { | 431 void test_incomplete_string_interpolation() { |
| 436 // https://code.google.com/p/dart/issues/detail?id=18073 | 432 // https://code.google.com/p/dart/issues/detail?id=18073 |
| 437 _assertErrorAndTokens( | 433 List<Token> expectedTokens = [ |
| 438 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 9, "\"foo \${bar", [ | |
| 439 new StringToken(TokenType.STRING, "\"foo ", 0), | 434 new StringToken(TokenType.STRING, "\"foo ", 0), |
| 440 new StringToken(TokenType.STRING_INTERPOLATION_EXPRESSION, "\${", 5), | 435 new StringToken(TokenType.STRING_INTERPOLATION_EXPRESSION, "\${", 5), |
| 441 new StringToken(TokenType.IDENTIFIER, "bar", 7) | 436 new StringToken(TokenType.IDENTIFIER, "bar", 7), |
| 442 ]); | 437 ]; |
| 438 if (usingFasta) { |
| 439 // fasta inserts synthetic closers |
| 440 expectedTokens.addAll([ |
| 441 new SyntheticToken(TokenType.CLOSE_CURLY_BRACKET, 10), |
| 442 ]); |
| 443 } else { |
| 444 expectedTokens.addAll([ |
| 445 new StringToken(TokenType.STRING, "", 10), |
| 446 ]); |
| 447 } |
| 448 _assertErrorAndTokens(ScannerErrorCode.UNTERMINATED_STRING_LITERAL, 9, |
| 449 "\"foo \${bar", expectedTokens); |
| 443 } | 450 } |
| 444 | 451 |
| 445 void test_index() { | 452 void test_index() { |
| 446 _assertToken(TokenType.INDEX, "[]"); | 453 _assertToken(TokenType.INDEX, "[]"); |
| 447 } | 454 } |
| 448 | 455 |
| 449 void test_index_eq() { | 456 void test_index_eq() { |
| 450 _assertToken(TokenType.INDEX_EQ, "[]="); | 457 _assertToken(TokenType.INDEX_EQ, "[]="); |
| 451 } | 458 } |
| 452 | 459 |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 _TestScanner(CharacterReader reader, [this.listener]) : super.create(reader); | 1506 _TestScanner(CharacterReader reader, [this.listener]) : super.create(reader); |
| 1500 | 1507 |
| 1501 @override | 1508 @override |
| 1502 void reportError( | 1509 void reportError( |
| 1503 ScannerErrorCode errorCode, int offset, List<Object> arguments) { | 1510 ScannerErrorCode errorCode, int offset, List<Object> arguments) { |
| 1504 if (listener != null) { | 1511 if (listener != null) { |
| 1505 listener.errors.add(new TestError(offset, errorCode, arguments)); | 1512 listener.errors.add(new TestError(offset, errorCode, arguments)); |
| 1506 } | 1513 } |
| 1507 } | 1514 } |
| 1508 } | 1515 } |
| OLD | NEW |