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

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

Issue 2682423003: Unify fasta->analyzer token translation logic. (Closed)
Patch Set: Created 3 years, 10 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
Index: pkg/front_end/test/scanner_test.dart
diff --git a/pkg/front_end/test/scanner_test.dart b/pkg/front_end/test/scanner_test.dart
index 2a46caf3531d7ffb3098f4e4e7c8b09fec87f061..aea7bf5f7e609571c698aef6a87c8797dc8896f1 100644
--- a/pkg/front_end/test/scanner_test.dart
+++ b/pkg/front_end/test/scanner_test.dart
@@ -165,6 +165,14 @@ abstract class ScannerTestBase {
_assertToken(TokenType.AMPERSAND_EQ, "&=");
}
+ void test_async_star() {
+ Token token = _scan("async*");
+ expect(token.type, TokenType.IDENTIFIER);
+ expect(token.lexeme, 'async');
+ expect(token.next.type, TokenType.STAR);
+ expect(token.next.next.type, TokenType.EOF);
+ }
+
void test_at() {
_assertToken(TokenType.AT, "@");
}
@@ -445,6 +453,14 @@ abstract class ScannerTestBase {
_assertKeywordToken("assert");
}
+ void test_keyword_async() {
+ _assertIdentifierToken("async");
+ }
+
+ void test_keyword_await() {
+ _assertIdentifierToken("await");
+ }
+
void test_keyword_break() {
_assertKeywordToken("break");
}
@@ -589,6 +605,10 @@ abstract class ScannerTestBase {
_assertKeywordToken("switch");
}
+ void test_keyword_sync() {
+ _assertIdentifierToken("sync");
+ }
+
void test_keyword_this() {
_assertKeywordToken("this");
}
@@ -1013,6 +1033,14 @@ abstract class ScannerTestBase {
]);
}
+ void test_sync_star() {
+ Token token = _scan("sync*");
+ expect(token.type, TokenType.IDENTIFIER);
+ expect(token.lexeme, 'sync');
+ expect(token.next.type, TokenType.STAR);
+ expect(token.next.next.type, TokenType.EOF);
+ }
+
void test_tilde() {
_assertToken(TokenType.TILDE, "~");
}
@@ -1094,6 +1122,26 @@ abstract class ScannerTestBase {
}
/**
+ * Assert that when scanned the given [source] contains a single identifier
+ * token with the same lexeme as the original source.
+ */
+ void _assertIdentifierToken(String source) {
+ void check(String s, int expectedOffset) {
+ Token token = _scan(s);
+ expect(token, isNotNull);
+ expect(token.type, TokenType.IDENTIFIER);
+ expect(token.offset, expectedOffset);
+ expect(token.length, source.length);
+ expect(token.lexeme, source);
+ expect(token.value(), source);
+ expect(token.next.type, TokenType.EOF);
+ }
+
+ check(source, 0);
+ check(' $source ', 1);
+ }
+
+ /**
* Assert that when scanned the given [source] contains a single keyword token
* with the same lexeme as the original source.
*/

Powered by Google App Engine
This is Rietveld 408576698