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

Unified Diff: pkg/analysis_server/test/analysis/notification_navigation_test.dart

Issue 649853004: Issue 21377. Specify that navigation regions are sorted and implement it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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/analysis_server/test/analysis/notification_navigation_test.dart
diff --git a/pkg/analysis_server/test/analysis/notification_navigation_test.dart b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
index 00ce0c9e7b8bc6d1ac096e57559bed95e88998c5..386c0ff13397ffef0d11b4b3c25c941dfdfa723e 100644
--- a/pkg/analysis_server/test/analysis/notification_navigation_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
@@ -123,6 +123,17 @@ class AnalysisNotificationNavigationTest extends AbstractAnalysisTest {
findRegion(offset, length, false);
}
+ void assertRegionsSorted() {
+ int lastEnd = -1;
+ for (NavigationRegion region in regions) {
+ int offset = region.offset;
+ if (offset < lastEnd) {
+ fail('$lastEnd was expected to be > $offset in\n' + regions.join('\n'));
+ }
+ lastEnd = offset + region.length;
+ }
+ }
+
/**
* Finds the navigation region with the given [offset] and [length].
* If [length] is `-1`, then it is ignored.
@@ -156,7 +167,9 @@ class AnalysisNotificationNavigationTest extends AbstractAnalysisTest {
Future prepareNavigation() {
addAnalysisSubscription(AnalysisService.NAVIGATION, testFile);
- return waitForTasksFinished();
+ return waitForTasksFinished().then((_) {
+ assertRegionsSorted();
+ });
}
void processNotification(Notification notification) {
@@ -283,6 +296,19 @@ main() {
});
}
+ test_identifier_whenStrayImportDirective() {
+ addTestFile('''
+main() {
+ int aaa = 42;
+ print(aaa);
+}
+import 'dart:math';
+''');
+ return prepareNavigation().then((_) {
+ assertHasRegionTarget('aaa);', 'aaa = 42');
+ });
+ }
+
test_instanceCreation_implicit() {
addTestFile('''
class A {
@@ -308,7 +334,7 @@ main() {
''');
return prepareNavigation().then((_) {
{
- findRegion(findOffset('new '), 'new '.length, true);
+ findRegion(findOffset('new '), 'new'.length, true);
assertHasTarget('named() {}');
}
{
@@ -333,7 +359,7 @@ main() {
''');
return prepareNavigation().then((_) {
{
- findRegion(findOffset('new '), 'new '.length, true);
+ findRegion(findOffset('new '), 'new'.length, true);
assertHasTarget('A() {}', 0);
}
{

Powered by Google App Engine
This is Rietveld 408576698