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

Side by Side Diff: pkg/front_end/test/scanner_replacement_test.dart

Issue 3004573002: remove old fasta missing exponent recovery (Closed)
Patch Set: Created 3 years, 3 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
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/recover.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 'dart:convert' show UTF8; 5 import 'dart:convert' show UTF8;
6 6
7 import 'package:front_end/src/fasta/scanner/recover.dart' 7 import 'package:front_end/src/fasta/scanner/recover.dart'
8 show defaultRecoveryStrategy; 8 show defaultRecoveryStrategy;
9 import 'package:front_end/src/fasta/scanner.dart' as fasta; 9 import 'package:front_end/src/fasta/scanner.dart' as fasta;
10 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; 10 import 'package:front_end/src/fasta/scanner/token.dart' as fasta;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 fasta.Token close = open.next; 83 fasta.Token close = open.next;
84 expect(close.next.isEof, isTrue); 84 expect(close.next.isEof, isTrue);
85 expect(open.endGroup, close); 85 expect(open.endGroup, close);
86 expect(open.isSynthetic, isFalse); 86 expect(open.isSynthetic, isFalse);
87 expect(close.isSynthetic, isTrue); 87 expect(close.isSynthetic, isTrue);
88 listener.assertErrors([ 88 listener.assertErrors([
89 new TestError(0, ScannerErrorCode.EXPECTED_TOKEN, [expectedCloser]), 89 new TestError(0, ScannerErrorCode.EXPECTED_TOKEN, [expectedCloser]),
90 ]); 90 ]);
91 } 91 }
92 92
93 void test_double_error() {
94 String source = "3457e";
95 ErrorListener listener = new ErrorListener();
96 analyzer.Token token = scanWithListener(source, listener);
97 expect(token.type, analyzer.TokenType.DOUBLE);
98 expect(token.offset, 0);
99 expect(token.isSynthetic, isTrue);
100 // the invalid token is updated to be valid ...
101 expect(token.lexeme, source + "0");
102 // ... but the length does *not* include the additional character
103 // so as to be true to the original source.
104 expect(token.length, source.length);
105 expect(token.next.isEof, isTrue);
106 expect(listener.errors, hasLength(1));
107 TestError error = listener.errors[0];
108 expect(error.errorCode, ScannerErrorCode.MISSING_DIGIT);
109 expect(error.offset, source.length - 1);
110 }
111
93 void test_lt() { 112 void test_lt() {
94 // fasta does not automatically insert a closer for '<' 113 // fasta does not automatically insert a closer for '<'
95 // because it could be part of an expression rather than an opener 114 // because it could be part of an expression rather than an opener
96 analyzer.BeginToken lt = _scan('<'); 115 analyzer.BeginToken lt = _scan('<');
97 expect(lt.next.isEof, isTrue); 116 expect(lt.next.isEof, isTrue);
98 expect(lt.isSynthetic, isFalse); 117 expect(lt.isSynthetic, isFalse);
99 } 118 }
100 119
101 void test_lt_gt() { 120 void test_lt_gt() {
102 _assertOpenClosePair('< >'); 121 _assertOpenClosePair('< >');
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } else if (token is fasta.UnmatchedToken) { 279 } else if (token is fasta.UnmatchedToken) {
261 expect(lastClosedGroup?.endGroup?.next, same(token), 280 expect(lastClosedGroup?.endGroup?.next, same(token),
262 reason: 'Unexpected error token for group: $lastClosedGroup'); 281 reason: 'Unexpected error token for group: $lastClosedGroup');
263 expect(token.begin, lastClosedGroup); 282 expect(token.begin, lastClosedGroup);
264 } 283 }
265 token = token.next; 284 token = token.next;
266 } 285 }
267 expect(openerStack, isEmpty, reason: 'Missing closers'); 286 expect(openerStack, isEmpty, reason: 'Missing closers');
268 } 287 }
269 } 288 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/recover.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698