@@ -272,15 +272,20 @@ mod tests {
272
272
use super :: * ;
273
273
274
274
fn check ( ra_fixture : & str ) {
275
- let ( analysis, pos, annotations) = fixture:: annotations ( ra_fixture) ;
276
275
let config = HighlightRelatedConfig {
277
276
break_points : true ,
278
277
exit_points : true ,
279
278
references : true ,
280
279
yield_points : true ,
281
280
} ;
282
281
283
- let hls = analysis. highlight_related ( config, pos) . unwrap ( ) . unwrap ( ) ;
282
+ check_with_config ( ra_fixture, config) ;
283
+ }
284
+
285
+ fn check_with_config ( ra_fixture : & str , config : HighlightRelatedConfig ) {
286
+ let ( analysis, pos, annotations) = fixture:: annotations ( ra_fixture) ;
287
+
288
+ let hls = analysis. highlight_related ( config, pos) . unwrap ( ) . unwrap_or ( Vec :: default ( ) ) ;
284
289
285
290
let mut expected = annotations
286
291
. into_iter ( )
@@ -745,4 +750,187 @@ fn foo() {
745
750
"# ,
746
751
) ;
747
752
}
753
+
754
+ #[ test]
755
+ fn test_hl_disabled_ref_local ( ) {
756
+ let config = HighlightRelatedConfig {
757
+ references : false ,
758
+ break_points : true ,
759
+ exit_points : true ,
760
+ yield_points : true ,
761
+ } ;
762
+
763
+ let ra_fixture = r#"
764
+ fn foo() {
765
+ let x$0 = 5;
766
+ let y = x * 2;
767
+ }"# ;
768
+
769
+ check_with_config ( ra_fixture, config) ;
770
+ }
771
+
772
+ #[ test]
773
+ fn test_hl_disabled_ref_local_preserved_break ( ) {
774
+ let config = HighlightRelatedConfig {
775
+ references : false ,
776
+ break_points : true ,
777
+ exit_points : true ,
778
+ yield_points : true ,
779
+ } ;
780
+
781
+ let ra_fixture = r#"
782
+ fn foo() {
783
+ let x$0 = 5;
784
+ let y = x * 2;
785
+
786
+ loop {
787
+ break;
788
+ }
789
+ }"# ;
790
+
791
+ check_with_config ( ra_fixture, config. clone ( ) ) ;
792
+
793
+ let ra_fixture = r#"
794
+ fn foo() {
795
+ let x = 5;
796
+ let y = x * 2;
797
+
798
+ loop$0 {
799
+ // ^^^^
800
+ break;
801
+ // ^^^^^
802
+ }
803
+ }"# ;
804
+
805
+ check_with_config ( ra_fixture, config) ;
806
+ }
807
+
808
+ #[ test]
809
+ fn test_hl_disabled_ref_local_preserved_yield ( ) {
810
+ let config = HighlightRelatedConfig {
811
+ references : false ,
812
+ break_points : true ,
813
+ exit_points : true ,
814
+ yield_points : true ,
815
+ } ;
816
+
817
+ let ra_fixture = r#"
818
+ async fn foo() {
819
+ let x$0 = 5;
820
+ let y = x * 2;
821
+
822
+ 0.await;
823
+ }"# ;
824
+
825
+ check_with_config ( ra_fixture, config. clone ( ) ) ;
826
+
827
+ let ra_fixture = r#"
828
+ async fn foo() {
829
+ // ^^^^^
830
+ let x = 5;
831
+ let y = x * 2;
832
+
833
+ 0.await$0;
834
+ // ^^^^^
835
+ }"# ;
836
+
837
+ check_with_config ( ra_fixture, config) ;
838
+ }
839
+
840
+ #[ test]
841
+ fn test_hl_disabled_ref_local_preserved_exit ( ) {
842
+ let config = HighlightRelatedConfig {
843
+ references : false ,
844
+ break_points : true ,
845
+ exit_points : true ,
846
+ yield_points : true ,
847
+ } ;
848
+
849
+ let ra_fixture = r#"
850
+ fn foo() -> i32 {
851
+ let x$0 = 5;
852
+ let y = x * 2;
853
+
854
+ if true {
855
+ return y;
856
+ }
857
+
858
+ 0?
859
+ }"# ;
860
+
861
+ check_with_config ( ra_fixture, config. clone ( ) ) ;
862
+
863
+ let ra_fixture = r#"
864
+ fn foo() ->$0 i32 {
865
+ let x = 5;
866
+ let y = x * 2;
867
+
868
+ if true {
869
+ return y;
870
+ // ^^^^^^
871
+ }
872
+
873
+ 0?
874
+ // ^
875
+ "# ;
876
+
877
+ check_with_config ( ra_fixture, config) ;
878
+ }
879
+
880
+ #[ test]
881
+ fn test_hl_disabled_break ( ) {
882
+ let config = HighlightRelatedConfig {
883
+ references : true ,
884
+ break_points : false ,
885
+ exit_points : true ,
886
+ yield_points : true ,
887
+ } ;
888
+
889
+ let ra_fixture = r#"
890
+ fn foo() {
891
+ loop {
892
+ break$0;
893
+ }
894
+ }"# ;
895
+
896
+ check_with_config ( ra_fixture, config) ;
897
+ }
898
+
899
+ #[ test]
900
+ fn test_hl_disabled_yield ( ) {
901
+ let config = HighlightRelatedConfig {
902
+ references : true ,
903
+ break_points : true ,
904
+ exit_points : true ,
905
+ yield_points : false ,
906
+ } ;
907
+
908
+ let ra_fixture = r#"
909
+ async$0 fn foo() {
910
+ 0.await;
911
+ }"# ;
912
+
913
+ check_with_config ( ra_fixture, config) ;
914
+ }
915
+
916
+ #[ test]
917
+ fn test_hl_disabled_exit ( ) {
918
+ let config = HighlightRelatedConfig {
919
+ references : true ,
920
+ break_points : true ,
921
+ exit_points : false ,
922
+ yield_points : true ,
923
+ } ;
924
+
925
+ let ra_fixture = r#"
926
+ fn foo() ->$0 i32 {
927
+ if true {
928
+ return -1;
929
+ }
930
+
931
+ 42
932
+ }"# ;
933
+
934
+ check_with_config ( ra_fixture, config) ;
935
+ }
748
936
}
0 commit comments