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

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

Issue 2914213003: fix unterminated interpolation expression handling (Closed)
Patch Set: Created 3 years, 7 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/array_based_scanner.dart ('k') | no next file » | 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 60ae3c3847d1a0bf0580bcc1fff5fe00dd84fbf3..67f3582c546c195628afee01b191120bb7e9cb62 100644
--- a/pkg/front_end/test/scanner_fasta_test.dart
+++ b/pkg/front_end/test/scanner_fasta_test.dart
@@ -329,6 +329,62 @@ abstract class ScannerTest_Fasta_Base {
expect((token as fasta.ErrorToken).errorCode, same(codeUnterminatedString));
}
+ void test_string_simple_unterminated_interpolation_block2() {
+ Token token = scan(r'"foo ${bar(baz[');
+ expectToken(token, TokenType.STRING, 0, 5, lexeme: '"foo ');
+
+ token = token.next;
+ expectToken(token, TokenType.STRING_INTERPOLATION_EXPRESSION, 5, 2);
+ BeginToken interpolationStart = token;
+
+ token = token.next;
+ expectToken(token, TokenType.IDENTIFIER, 7, 3, lexeme: 'bar');
+
+ token = token.next;
+ expectToken(token, TokenType.OPEN_PAREN, 10, 1);
+ BeginToken openParen = token;
+
+ token = token.next;
+ expectToken(token, TokenType.IDENTIFIER, 11, 3, lexeme: 'baz');
+
+ token = token.next;
+ expectToken(token, TokenType.OPEN_SQUARE_BRACKET, 14, 1);
+ BeginToken openSquareBracket = token;
+
+ token = token.next;
+ expectToken(token, TokenType.CLOSE_SQUARE_BRACKET, 15, 0,
+ isSynthetic: true, lexeme: ']');
+ expect(openSquareBracket.endToken, same(token));
+
+ token = token.next;
+ expect((token as fasta.ErrorToken).errorCode, same(codeUnmatchedToken));
+ expect((token as fasta.UnmatchedToken).begin, same(openSquareBracket));
+
+ token = token.next;
+ expectToken(token, TokenType.CLOSE_PAREN, 15, 0,
+ isSynthetic: true, lexeme: ')');
+ expect(openParen.endToken, same(token));
+
+ token = token.next;
+ expect((token as fasta.ErrorToken).errorCode, same(codeUnmatchedToken));
+ expect((token as fasta.UnmatchedToken).begin, same(openParen));
+
+ token = token.next;
+ expectToken(token, TokenType.CLOSE_CURLY_BRACKET, 15, 0,
+ isSynthetic: true, lexeme: '}');
+ expect(interpolationStart.endToken, same(token));
+
+ token = token.next;
+ expect((token as fasta.ErrorToken).errorCode, same(codeUnmatchedToken));
+ expect((token as fasta.UnmatchedToken).begin, same(interpolationStart));
+
+ token = token.next;
+ expectToken(token, TokenType.STRING, 15, 0, isSynthetic: true, lexeme: '"');
+
+ token = token.next;
+ expect((token as fasta.ErrorToken).errorCode, same(codeUnterminatedString));
+ }
+
void test_string_simple_missing_interpolation_identifier() {
Token token = scan(r'"foo $');
expectToken(token, TokenType.STRING, 0, 5, lexeme: '"foo ');
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698