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

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

Issue 2757113002: fasta.Token implement analyzer.Token (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/scanner/token.dart ('k') | pkg/front_end/test/scanner_roundtrip_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/test/precedence_info_test.dart
diff --git a/pkg/front_end/test/precedence_info_test.dart b/pkg/front_end/test/precedence_info_test.dart
index 56d2915640b7c469e4783e5506b3f2d0b9dee1ff..41c38bbdb7ba12ec406efcce4a43b4921ecca73e 100644
--- a/pkg/front_end/test/precedence_info_test.dart
+++ b/pkg/front_end/test/precedence_info_test.dart
@@ -112,6 +112,12 @@ class PrecedenceInfoTest {
for (TokenType tt in allTokenTypes) {
assertLexeme(tt.lexeme);
}
+ assertLexeme('1.0'); // DOUBLE
+ assertLexeme('0xA'); // HEXADECIMAL
+ assertLexeme('1'); // INT
+ assertLexeme('var'); // KEYWORD
+ assertLexeme('#!/'); // SCRIPT_TAG
+ assertLexeme('"foo"'); // STRING
if (includeLazyAssignmentOperators) {
assertLexeme('&&=');
assertLexeme('||=');
@@ -455,4 +461,54 @@ class PrecedenceInfoTest {
}
});
}
+
+ void test_identity() {
+ var exceptions = <TokenType>[
+ // Null lexeme - no corresponding PrecedenceInfo
+ TokenType.MULTI_LINE_COMMENT,
+ TokenType.SINGLE_LINE_COMMENT,
+ TokenType.GENERIC_METHOD_TYPE_LIST,
+ TokenType.GENERIC_METHOD_TYPE_ASSIGN,
+
+ // Manually compared below
+ TokenType.DOUBLE,
+ TokenType.HEXADECIMAL,
+ TokenType.INT,
+ TokenType.KEYWORD,
+ TokenType.SCRIPT_TAG,
+ TokenType.STRING,
+ TokenType.STRING_INTERPOLATION_EXPRESSION,
+ TokenType.STRING_INTERPOLATION_IDENTIFIER,
+ ];
+
+ void assertLexeme(String source, TokenType tt) {
+ var scanner = new StringScanner(source, includeComments: true);
+ var token = scanner.tokenize();
+ expect(token.type, same(tt), reason: source);
+ }
+
+ for (TokenType tt in allTokenTypes) {
+ if (!exceptions.contains(tt)) {
+ assertLexeme(tt.lexeme, tt);
+ }
+ }
+ expect(DOUBLE_INFO, same(TokenType.DOUBLE));
+ expect(HEXADECIMAL_INFO, same(TokenType.HEXADECIMAL));
+ expect(INT_INFO, same(TokenType.INT));
+ expect(KEYWORD_INFO, same(TokenType.KEYWORD));
+ expect(SCRIPT_INFO, same(TokenType.SCRIPT_TAG));
+ expect(STRING_INFO, same(TokenType.STRING));
+
+ assertLexeme('1.0', TokenType.DOUBLE);
+ assertLexeme('0xA', TokenType.HEXADECIMAL);
+ assertLexeme('1', TokenType.INT);
+ assertLexeme('var', TokenType.KEYWORD);
+ assertLexeme('#!/', TokenType.SCRIPT_TAG);
+ assertLexeme('"foo"',TokenType.STRING);
+
+ expect(STRING_INTERPOLATION_INFO,
+ same(TokenType.STRING_INTERPOLATION_EXPRESSION));
+ expect(STRING_INTERPOLATION_IDENTIFIER_INFO,
+ same(TokenType.STRING_INTERPOLATION_IDENTIFIER));
+ }
}
« no previous file with comments | « pkg/front_end/lib/src/scanner/token.dart ('k') | pkg/front_end/test/scanner_roundtrip_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698