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

Side by Side Diff: pkg/analysis_server/test/analysis/notification_highlights_test.dart

Issue 668943004: Semantic highlight async/await/sync/yield. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/computer/computer_highlights.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library test.analysis.notification.highlights; 5 library test.analysis.notification.highlights;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/constants.dart'; 9 import 'package:analysis_server/src/constants.dart';
10 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 p as int; 154 p as int;
155 var as = 42; 155 var as = 42;
156 }'''); 156 }''');
157 return prepareHighlights().then((_) { 157 return prepareHighlights().then((_) {
158 assertHasRegion(HighlightRegionType.BUILT_IN, 'as math'); 158 assertHasRegion(HighlightRegionType.BUILT_IN, 'as math');
159 assertHasRegion(HighlightRegionType.BUILT_IN, 'as int'); 159 assertHasRegion(HighlightRegionType.BUILT_IN, 'as int');
160 assertNoRegion(HighlightRegionType.BUILT_IN, 'as = 42'); 160 assertNoRegion(HighlightRegionType.BUILT_IN, 'as = 42');
161 }); 161 });
162 } 162 }
163 163
164 test_BUILT_IN_async() {
165 addTestFile('''
166 fa() async {}
167 fb() async* {}
168 main() {
169 bool async = false;
170 }
171 ''');
172 return prepareHighlights().then((_) {
173 assertHasStringRegion(HighlightRegionType.BUILT_IN, 'async');
174 assertHasStringRegion(HighlightRegionType.BUILT_IN, 'async*');
175 assertNoRegion(HighlightRegionType.BUILT_IN, 'async = false');
176 });
177 }
178
179 test_BUILT_IN_await() {
180 addTestFile('''
181 main() async {
182 await 42;
183 }
184 ''');
185 return prepareHighlights().then((_) {
186 assertHasRegion(HighlightRegionType.BUILT_IN, 'await 42');
187 });
188 }
189
164 test_BUILT_IN_deferred() { 190 test_BUILT_IN_deferred() {
165 addTestFile(''' 191 addTestFile('''
166 import 'dart:math' deferred as math; 192 import 'dart:math' deferred as math;
167 main() { 193 main() {
168 var deferred = 42; 194 var deferred = 42;
169 }'''); 195 }''');
170 return prepareHighlights().then((_) { 196 return prepareHighlights().then((_) {
171 assertHasRegion(HighlightRegionType.BUILT_IN, 'deferred as math'); 197 assertHasRegion(HighlightRegionType.BUILT_IN, 'deferred as math');
172 assertNoRegion(HighlightRegionType.BUILT_IN, 'deferred = 42'); 198 assertNoRegion(HighlightRegionType.BUILT_IN, 'deferred = 42');
173 }); 199 });
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 main() { 419 main() {
394 var static = 42; 420 var static = 42;
395 }'''); 421 }''');
396 return prepareHighlights().then((_) { 422 return prepareHighlights().then((_) {
397 assertHasRegion(HighlightRegionType.BUILT_IN, 'static aaa;'); 423 assertHasRegion(HighlightRegionType.BUILT_IN, 'static aaa;');
398 assertHasRegion(HighlightRegionType.BUILT_IN, 'static bbb()'); 424 assertHasRegion(HighlightRegionType.BUILT_IN, 'static bbb()');
399 assertNoRegion(HighlightRegionType.BUILT_IN, 'static = 42'); 425 assertNoRegion(HighlightRegionType.BUILT_IN, 'static = 42');
400 }); 426 });
401 } 427 }
402 428
429 test_BUILT_IN_sync() {
430 addTestFile('''
431 fa() sync {}
432 fb() sync* {}
433 main() {
434 bool sync = false;
435 }
436 ''');
437 return prepareHighlights().then((_) {
438 assertHasStringRegion(HighlightRegionType.BUILT_IN, 'sync');
439 assertHasStringRegion(HighlightRegionType.BUILT_IN, 'sync*');
440 assertNoRegion(HighlightRegionType.BUILT_IN, 'sync = false');
441 });
442 }
443
403 test_BUILT_IN_typedef() { 444 test_BUILT_IN_typedef() {
404 addTestFile(''' 445 addTestFile('''
405 typedef A(); 446 typedef A();
406 main() { 447 main() {
407 var typedef = 42; 448 var typedef = 42;
408 }'''); 449 }''');
409 return prepareHighlights().then((_) { 450 return prepareHighlights().then((_) {
410 assertHasRegion(HighlightRegionType.BUILT_IN, 'typedef A();'); 451 assertHasRegion(HighlightRegionType.BUILT_IN, 'typedef A();');
411 assertNoRegion(HighlightRegionType.BUILT_IN, 'typedef = 42'); 452 assertNoRegion(HighlightRegionType.BUILT_IN, 'typedef = 42');
412 }); 453 });
413 } 454 }
414 455
456 test_BUILT_IN_yield() {
457 addTestFile('''
458 main() async* {
459 yield 42;
460 }
461 ''');
462 return prepareHighlights().then((_) {
463 assertHasRegion(HighlightRegionType.BUILT_IN, 'yield 42');
464 });
465 }
466
467 test_BUILT_IN_yieldStar() {
468 addTestFile('''
469 main() async* {
470 yield* [];
471 }
472 ''');
473 return prepareHighlights().then((_) {
474 assertHasStringRegion(HighlightRegionType.BUILT_IN, 'yield*');
475 });
476 }
477
415 test_CLASS() { 478 test_CLASS() {
416 addTestFile(''' 479 addTestFile('''
417 class AAA {} 480 class AAA {}
418 AAA aaa; 481 AAA aaa;
419 '''); 482 ''');
420 return prepareHighlights().then((_) { 483 return prepareHighlights().then((_) {
421 assertHasRegion(HighlightRegionType.CLASS, 'AAA {}'); 484 assertHasRegion(HighlightRegionType.CLASS, 'AAA {}');
422 assertHasRegion(HighlightRegionType.CLASS, 'AAA aaa'); 485 assertHasRegion(HighlightRegionType.CLASS, 'AAA aaa');
423 }); 486 });
424 } 487 }
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 void test_toString() { 1024 void test_toString() {
962 expect(HighlightRegionType.CLASS.toString(), 'HighlightRegionType.CLASS'); 1025 expect(HighlightRegionType.CLASS.toString(), 'HighlightRegionType.CLASS');
963 } 1026 }
964 1027
965 void test_valueOf_unknown() { 1028 void test_valueOf_unknown() {
966 expect(() { 1029 expect(() {
967 new HighlightRegionType('no-such-type'); 1030 new HighlightRegionType('no-such-type');
968 }, throws); 1031 }, throws);
969 } 1032 }
970 } 1033 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/computer/computer_highlights.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698