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

Side by Side Diff: pkg/analysis_server/test/analysis_notification_highlights_test.dart

Issue 363363002: Add failing test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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.domain.analysis.notification.highlights; 5 library test.domain.analysis.notification.highlights;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/computer/computer_highlights.dart'; 10 import 'package:analysis_server/src/computer/computer_highlights.dart';
(...skipping 16 matching lines...) Expand all
27 class _AnalysisNotificationHighlightsTest extends AbstractAnalysisTest { 27 class _AnalysisNotificationHighlightsTest extends AbstractAnalysisTest {
28 List<_HighlightRegion> regions; 28 List<_HighlightRegion> regions;
29 29
30 void assertHasRawRegion(HighlightType type, int offset, int length) { 30 void assertHasRawRegion(HighlightType type, int offset, int length) {
31 for (_HighlightRegion region in regions) { 31 for (_HighlightRegion region in regions) {
32 if (region.offset == offset && region.length == length && region.type == 32 if (region.offset == offset && region.length == length && region.type ==
33 type.name) { 33 type.name) {
34 return; 34 return;
35 } 35 }
36 } 36 }
37 fail('Expected to find (offset=$offset; length=$length; type=$type) in\n' 37 StringBuffer buffer = new StringBuffer();
38 '${regions.join('\n')}'); 38 buffer.write('Expected to find (type=');
39 buffer.write(type.name);
40 buffer.write('; offset=');
41 buffer.write(offset);
42 buffer.write('; length=');
43 buffer.write(length);
44 buffer.write(') in\n');
45 for (_HighlightRegion region in regions) {
46 buffer.write(' (type=');
47 buffer.write(region.type);
48 buffer.write('; offset=');
49 buffer.write(region.offset);
50 buffer.write('; length=');
51 buffer.write(region.length);
52 buffer.write(') in\n');
53 }
54 fail(buffer.toString());
39 } 55 }
40 56
41 void assertHasRegion(HighlightType type, String search, [int length = -1]) { 57 void assertHasRegion(HighlightType type, String search, [int length = -1]) {
42 int offset = findOffset(search); 58 int offset = findOffset(search);
43 length = findRegionLength(search, length); 59 length = findRegionLength(search, length);
44 assertHasRawRegion(type, offset, length); 60 assertHasRawRegion(type, offset, length);
45 } 61 }
46 62
47 void assertNoRawRegion(HighlightType type, int offset, int length) { 63 void assertNoRawRegion(HighlightType type, int offset, int length) {
48 for (_HighlightRegion region in regions) { 64 for (_HighlightRegion region in regions) {
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 447
432 test_CLASS_notVoid() { 448 test_CLASS_notVoid() {
433 addTestFile(''' 449 addTestFile('''
434 void f() {} 450 void f() {}
435 '''); 451 ''');
436 return prepareHighlights(() { 452 return prepareHighlights(() {
437 assertNoRegion(HighlightType.CLASS, 'void f()'); 453 assertNoRegion(HighlightType.CLASS, 'void f()');
438 }); 454 });
439 } 455 }
440 456
457 test_COMMENT() {
458 addTestFile('''
459 /**
460 * documentation comment
461 */
462 void main() {
463 // end-of-line comment
464 my_function(1);
465 }
466
467 void my_function(String a) {
468 /* block comment */
469 }
470 ''');
471 return prepareHighlights(() {
472 // TODO(brianwilkerson) Make this test pass.
473 // assertHasRegion(HighlightType.COMMENT_END_OF_LINE, '//', 22);
474 // assertHasRegion(HighlightType.COMMENT_BLOCK, '/* b', 19);
475 // assertHasRegion(HighlightType.COMMENT_DOCUMENTATION, '/**', 32);
476 });
477 }
478
441 test_CONSTRUCTOR() { 479 test_CONSTRUCTOR() {
442 addTestFile(''' 480 addTestFile('''
443 class AAA { 481 class AAA {
444 AAA() {} 482 AAA() {}
445 AAA.name(p) {} 483 AAA.name(p) {}
446 } 484 }
447 main() { 485 main() {
448 new AAA(); 486 new AAA();
449 new AAA.name(42); 487 new AAA.name(42);
450 } 488 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 final int length; 798 final int length;
761 final int offset; 799 final int offset;
762 final String type; 800 final String type;
763 801
764 _HighlightRegion(this.type, this.offset, this.length); 802 _HighlightRegion(this.type, this.offset, this.length);
765 803
766 factory _HighlightRegion.fromJson(Map<String, Object> map) { 804 factory _HighlightRegion.fromJson(Map<String, Object> map) {
767 return new _HighlightRegion(map[TYPE], map[OFFSET], map[LENGTH]); 805 return new _HighlightRegion(map[TYPE], map[OFFSET], map[LENGTH]);
768 } 806 }
769 } 807 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698