| OLD | NEW |
| 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.navigation; | 5 library test.domain.analysis.notification.navigation; |
| 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'; |
| 11 import 'reflective_tests.dart'; | |
| 12 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 13 | 12 |
| 14 import 'analysis_abstract.dart'; | 13 import 'analysis_abstract.dart'; |
| 14 import 'reflective_tests.dart'; |
| 15 | 15 |
| 16 | 16 |
| 17 main() { | 17 main() { |
| 18 groupSep = ' | '; | 18 groupSep = ' | '; |
| 19 runReflectiveTests(AnalysisNotificationNavigationTest); | 19 runReflectiveTests(AnalysisNotificationNavigationTest); |
| 20 } | 20 } |
| 21 | 21 |
| 22 | 22 |
| 23 @ReflectiveTestCase() | 23 @ReflectiveTestCase() |
| 24 class AnalysisNotificationNavigationTest extends AbstractAnalysisTest { | 24 class AnalysisNotificationNavigationTest extends AbstractAnalysisTest { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 Location location = target.location; | 36 Location location = target.location; |
| 37 if (location.file == file && | 37 if (location.file == file && |
| 38 location.offset == offset && | 38 location.offset == offset && |
| 39 location.length == length) { | 39 location.length == length) { |
| 40 testTarget = target; | 40 testTarget = target; |
| 41 return; | 41 return; |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 fail( | 44 fail( |
| 45 'Expected to find target (file=$file; offset=$offset; length=$length) in
\n' | 45 'Expected to find target (file=$file; offset=$offset; length=$length) in
\n' |
| 46 '${testRegion} in\n' '${regions.join('\n')}'); | 46 '${testRegion} in\n' '${testTargets.join('\n')}'); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void assertHasOperatorRegion(String regionSearch, int regionLength, | 49 void assertHasOperatorRegion(String regionSearch, int regionLength, |
| 50 String targetSearch, int targetLength) { | 50 String targetSearch, int targetLength) { |
| 51 assertHasRegion(regionSearch, regionLength); | 51 assertHasRegion(regionSearch, regionLength); |
| 52 assertHasTarget(targetSearch, targetLength); | 52 assertHasTarget(targetSearch, targetLength); |
| 53 } | 53 } |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Validates that there is a region at the offset of [search] in [testFile]. | 56 * Validates that there is a region at the offset of [search] in [testFile]. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 261 |
| 262 test_instanceCreation_implicit() { | 262 test_instanceCreation_implicit() { |
| 263 addTestFile(''' | 263 addTestFile(''' |
| 264 class A { | 264 class A { |
| 265 } | 265 } |
| 266 main() { | 266 main() { |
| 267 new A(); | 267 new A(); |
| 268 } | 268 } |
| 269 '''); | 269 '''); |
| 270 return prepareNavigation().then((_) { | 270 return prepareNavigation().then((_) { |
| 271 assertHasRegionString('new A'); | 271 findRegion(findOffset('new A'), 'new A'.length, true); |
| 272 assertHasTarget('A {'); | 272 assertHasTarget('A {'); |
| 273 }); | 273 }); |
| 274 } | 274 } |
| 275 | 275 |
| 276 test_instanceCreation_named() { | 276 test_instanceCreation_named() { |
| 277 addTestFile(''' | 277 addTestFile(''' |
| 278 class A { | 278 class A { |
| 279 A.named() {} | 279 A.named() {} |
| 280 } | 280 } |
| 281 main() { | 281 main() { |
| 282 new A.named(); | 282 new A.named(); |
| 283 } | 283 } |
| 284 '''); | 284 '''); |
| 285 return prepareNavigation().then((_) { | 285 return prepareNavigation().then((_) { |
| 286 assertHasRegionString('new A.named'); | 286 { |
| 287 assertHasTarget('named() {}'); | 287 findRegion(findOffset('new '), 'new '.length, true); |
| 288 assertHasTarget('named() {}'); |
| 289 } |
| 290 { |
| 291 findRegion(findOffset('A.named();'), 'A'.length, true); |
| 292 assertHasTarget('A {'); |
| 293 } |
| 294 { |
| 295 findRegion(findOffset('.named();'), '.named'.length, true); |
| 296 assertHasTarget('named() {}'); |
| 297 } |
| 288 }); | 298 }); |
| 289 } | 299 } |
| 290 | 300 |
| 291 test_instanceCreation_unnamed() { | 301 test_instanceCreation_unnamed() { |
| 292 addTestFile(''' | 302 addTestFile(''' |
| 293 class A { | 303 class A { |
| 294 A() {} | 304 A() {} |
| 295 } | 305 } |
| 296 main() { | 306 main() { |
| 297 new A(); | 307 new A(); |
| 298 } | 308 } |
| 299 '''); | 309 '''); |
| 300 return prepareNavigation().then((_) { | 310 return prepareNavigation().then((_) { |
| 301 assertHasRegionString('new A'); | 311 { |
| 302 assertHasTarget("A() {}", 0); | 312 findRegion(findOffset('new '), 'new '.length, true); |
| 313 assertHasTarget('A() {}', 0); |
| 314 } |
| 315 { |
| 316 findRegion(findOffset('A();'), 'A'.length, true); |
| 317 assertHasTarget('A {'); |
| 318 } |
| 303 }); | 319 }); |
| 304 } | 320 } |
| 305 | 321 |
| 306 test_operator_arithmetic() { | 322 test_operator_arithmetic() { |
| 307 addTestFile(''' | 323 addTestFile(''' |
| 308 class A { | 324 class A { |
| 309 A operator +(other) => null; | 325 A operator +(other) => null; |
| 310 A operator -() => null; | 326 A operator -() => null; |
| 311 A operator -(other) => null; | 327 A operator -(other) => null; |
| 312 A operator *(other) => null; | 328 A operator *(other) => null; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 test_type_void() { | 487 test_type_void() { |
| 472 addTestFile(''' | 488 addTestFile(''' |
| 473 void main() { | 489 void main() { |
| 474 } | 490 } |
| 475 '''); | 491 '''); |
| 476 return prepareNavigation().then((_) { | 492 return prepareNavigation().then((_) { |
| 477 assertNoRegionAt('void'); | 493 assertNoRegionAt('void'); |
| 478 }); | 494 }); |
| 479 } | 495 } |
| 480 } | 496 } |
| OLD | NEW |