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

Unified Diff: pkg/front_end/test/scanner_fasta_test.dart

Issue 2777153002: move synthetic fasta closers into the token stream (Closed)
Patch Set: rebase Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/token.dart ('k') | pkg/front_end/test/scanner_replacement_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/test/scanner_fasta_test.dart
diff --git a/pkg/front_end/test/scanner_fasta_test.dart b/pkg/front_end/test/scanner_fasta_test.dart
index 050672d7f0c39151aa3bc2e95cd87fbea978baf9..2bb559aaa212099c74256eaf47749f5e0a017128 100644
--- a/pkg/front_end/test/scanner_fasta_test.dart
+++ b/pkg/front_end/test/scanner_fasta_test.dart
@@ -190,6 +190,38 @@ class ScannerTest_Fasta extends ScannerTestBase {
@override
@failingTest
+ void test_incomplete_string_interpolation() {
+ // TODO(danrubel): fix ToAnalyzerTokenStreamConverter_WithListener
+ // to handle synthetic closers in token stream
+ super.test_incomplete_string_interpolation();
+ }
+
+ @override
+ void test_mismatched_opener_in_interpolation() {
+ // When openers and closers are mismatched,
+ // fasta favors considering the opener to be mismatched
+ // and inserts synthetic closers as needed.
+ // r'"${({(}}"' is parsed as r'"${({()})}"'
+ // where both ')' are synthetic
+ var stringStart = _scan(r'"${({(}}"');
+ var interpolationStart = stringStart.next as BeginToken;
+ var openParen1 = interpolationStart.next as BeginToken;
+ var openBrace = openParen1.next as BeginToken;
+ var openParen2 = openBrace.next as BeginToken;
+ var closeParen2 = openParen2.next;
+ var closeBrace = closeParen2.next;
+ var closeParen1 = closeBrace.next;
+ var interpolationEnd = closeParen1.next;
+ var stringEnd = interpolationEnd.next;
+ expect(stringEnd.next.type, TokenType.EOF);
+ expect(interpolationStart.endToken, same(interpolationEnd));
+ expect(openParen1.endToken, same(closeParen1));
+ expect(openBrace.endToken, same(closeBrace));
+ expect(openParen2.endToken, same(closeParen2));
+ }
+
+ @override
+ @failingTest
void test_string_multi_unterminated() {
// TODO(paulberry,ahe): bad error recovery.
super.test_string_multi_unterminated();
@@ -257,6 +289,31 @@ class ScannerTest_Fasta extends ScannerTestBase {
// TODO(paulberry,ahe): bad error recovery.
super.test_string_simple_unterminated_interpolation_identifier();
}
+
+ @override
+ void test_unmatched_openers() {
+ var openBrace = _scan('{[(') as BeginToken;
+ var openBracket = openBrace.next as BeginToken;
+ var openParen = openBracket.next as BeginToken;
+ var closeParen = openParen.next;
+ var closeBracket = closeParen.next;
+ var closeBrace = closeBracket.next;
+ expect(closeBrace.next.type, TokenType.EOF);
+ expect(openBrace.endToken, same(closeBrace));
+ expect(openBracket.endToken, same(closeBracket));
+ expect(openParen.endToken, same(closeParen));
+ }
+
+ Token _scan(String source,
+ {bool genericMethodComments: false,
+ bool lazyAssignmentOperators: false}) {
+ ErrorListener listener = new ErrorListener();
+ Token token = scanWithListener(source, listener,
+ genericMethodComments: genericMethodComments,
+ lazyAssignmentOperators: lazyAssignmentOperators);
+ listener.assertNoErrors();
+ return token;
+ }
}
/// Base class for scanner tests that examine the token stream in Fasta format.
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/token.dart ('k') | pkg/front_end/test/scanner_replacement_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698