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

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

Issue 2803563003: enhance analyzer to parse uppercase and built-in/pseudo keywords (Closed)
Patch Set: rebase Created 3 years, 8 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/scanner/token.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 'package:front_end/src/fasta/scanner/string_scanner.dart'; 5 import 'package:front_end/src/fasta/scanner/string_scanner.dart';
6 import 'package:front_end/src/fasta/scanner/keyword.dart' as fasta; 6 import 'package:front_end/src/fasta/scanner/keyword.dart' as fasta;
7 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; 7 import 'package:front_end/src/fasta/scanner/token.dart' as fasta;
8 import 'package:front_end/src/scanner/token.dart'; 8 import 'package:front_end/src/scanner/token.dart';
9 import 'package:front_end/src/scanner/reader.dart' as analyzer; 9 import 'package:front_end/src/scanner/reader.dart' as analyzer;
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 var token = scanner.tokenize(); 152 var token = scanner.tokenize();
153 expect(token.matchesAny([TokenType.KEYWORD]), true); 153 expect(token.matchesAny([TokenType.KEYWORD]), true);
154 expect(token.matchesAny([TokenType.AMPERSAND, TokenType.KEYWORD]), true); 154 expect(token.matchesAny([TokenType.AMPERSAND, TokenType.KEYWORD]), true);
155 expect(token.matchesAny([TokenType.AMPERSAND]), false); 155 expect(token.matchesAny([TokenType.AMPERSAND]), false);
156 } 156 }
157 157
158 /// Return all fasta and all analyzer keywords 158 /// Return all fasta and all analyzer keywords
159 List<Keyword> get _allKeywords => 159 List<Keyword> get _allKeywords =>
160 new List.from(Keyword.values)..addAll(fasta.Keyword.values); 160 new List.from(Keyword.values)..addAll(fasta.Keyword.values);
161 161
162 void test_all_keywords() {
163 var keywords = new Set<fasta.Keyword>.from(fasta.Keyword.values);
164 for (Keyword kw in Keyword.values) {
165 expect(keywords.remove(kw), isTrue, reason: kw.name);
166 }
167 expect(keywords, isEmpty);
168 }
169
162 void test_built_in_keywords() { 170 void test_built_in_keywords() {
163 var builtInKeywords = new Set<Keyword>.from([ 171 var builtInKeywords = new Set<Keyword>.from([
164 Keyword.ABSTRACT, 172 Keyword.ABSTRACT,
165 Keyword.AS, 173 Keyword.AS,
166 Keyword.COVARIANT, 174 Keyword.COVARIANT,
167 Keyword.DEFERRED, 175 Keyword.DEFERRED,
168 Keyword.DYNAMIC, 176 Keyword.DYNAMIC,
169 Keyword.EXPORT, 177 Keyword.EXPORT,
170 Keyword.EXTERNAL, 178 Keyword.EXTERNAL,
171 Keyword.FACTORY, 179 Keyword.FACTORY,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // General tokens 226 // General tokens
219 token = token.next; 227 token = token.next;
220 expect(token.lexeme, '&'); 228 expect(token.lexeme, '&');
221 expect(token.value(), '&'); 229 expect(token.value(), '&');
222 // String tokens 230 // String tokens
223 token = token.next; 231 token = token.next;
224 expect(token.lexeme, '"home"'); 232 expect(token.lexeme, '"home"');
225 expect(token.value(), '"home"'); 233 expect(token.value(), '"home"');
226 } 234 }
227 } 235 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/scanner/token.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698