@@ -449,55 +449,76 @@ mod tests {
449
449
assert ! ( navs. is_empty( ) , "didn't expect this to resolve anywhere: {navs:?}" )
450
450
}
451
451
452
+ fn check_name ( expected_name : & str , ra_fixture : & str ) {
453
+ let ( analysis, position, _) = fixture:: annotations ( ra_fixture) ;
454
+ let navs = analysis. goto_definition ( position) . unwrap ( ) . expect ( "no definition found" ) . info ;
455
+ assert ! ( navs. len( ) < 2 , "expected single navigation target but encountered {}" , navs. len( ) ) ;
456
+ let Some ( target) = navs. into_iter ( ) . next ( ) else {
457
+ panic ! ( "expected single navigation target but encountered none" ) ;
458
+ } ;
459
+ assert_eq ! ( target. name, SmolStr :: new_inline( expected_name) ) ;
460
+ }
461
+
452
462
#[ test]
453
- fn goto_def_range_inclusive_0 ( ) {
454
- let ra_fixture = r#"
463
+ fn goto_def_range ( ) {
464
+ check_name ( "Range" , r#"
455
465
//- minicore: range
456
- fn f(a: usize, b: usize) {
457
- for _ in a.$0.=b {
458
-
466
+ let x = 0.$0.1;
467
+ "#
468
+ ) ;
459
469
}
470
+
471
+ #[ test]
472
+ fn goto_def_range_from ( ) {
473
+ check_name ( "RangeFrom" , r#"
474
+ //- minicore: range
475
+ fn f(arr: &[i32]) -> &[i32] {
476
+ &arr[0.$0.]
460
477
}
461
- "# ;
462
- let ( analysis, position, _) = fixture:: annotations ( ra_fixture) ;
463
- let mut navs =
464
- analysis. goto_definition ( position) . unwrap ( ) . expect ( "no definition found" ) . info ;
465
- let Some ( target) = navs. pop ( ) else { panic ! ( "no target found" ) } ;
466
- assert_eq ! ( target. name, SmolStr :: new_inline( "RangeInclusive" ) ) ;
478
+ "#
479
+ ) ;
467
480
}
468
481
469
482
#[ test]
470
- fn goto_def_range_inclusive_1 ( ) {
471
- let ra_fixture = r#"
483
+ fn goto_def_range_inclusive ( ) {
484
+ check_name ( "RangeInclusive" , r#"
472
485
//- minicore: range
473
- fn f(a: usize, b: usize) {
474
- for _ in a..$0=b {
475
-
486
+ let x = 0.$0.=1;
487
+ "#
488
+ ) ;
476
489
}
490
+
491
+ #[ test]
492
+ fn goto_def_range_full ( ) {
493
+ check_name ( "RangeFull" , r#"
494
+ //- minicore: range
495
+ fn f(arr: &[i32]) -> &[i32] {
496
+ &arr[.$0.]
477
497
}
478
- "# ;
479
- let ( analysis, position, _) = fixture:: annotations ( ra_fixture) ;
480
- let mut navs =
481
- analysis. goto_definition ( position) . unwrap ( ) . expect ( "no definition found" ) . info ;
482
- let Some ( target) = navs. pop ( ) else { panic ! ( "no target found" ) } ;
483
- assert_eq ! ( target. name, SmolStr :: new_inline( "RangeInclusive" ) ) ;
498
+ "#
499
+ ) ;
484
500
}
485
501
486
502
#[ test]
487
- fn goto_def_range ( ) {
488
- let ra_fixture = r#"
503
+ fn goto_def_range_to ( ) {
504
+ check_name ( "RangeTo" , r#"
489
505
//- minicore: range
490
- fn f(a: usize, b: usize) {
491
- for _ in a.$0.b {
492
-
506
+ fn f(arr: &[i32]) -> &[i32] {
507
+ &arr[.$0.10]
508
+ }
509
+ "#
510
+ ) ;
493
511
}
512
+
513
+ #[ test]
514
+ fn goto_def_range_to_inclusive ( ) {
515
+ check_name ( "RangeToInclusive" , r#"
516
+ //- minicore: range
517
+ fn f(arr: &[i32]) -> &[i32] {
518
+ &arr[.$0.=10]
494
519
}
495
- "# ;
496
- let ( analysis, position, _) = fixture:: annotations ( ra_fixture) ;
497
- let mut navs =
498
- analysis. goto_definition ( position) . unwrap ( ) . expect ( "no definition found" ) . info ;
499
- let Some ( target) = navs. pop ( ) else { panic ! ( "no target found" ) } ;
500
- assert_eq ! ( target. name, SmolStr :: new_inline( "Range" ) ) ;
520
+ "#
521
+ ) ;
501
522
}
502
523
503
524
#[ test]
0 commit comments