File tree Expand file tree Collapse file tree 3 files changed +35
-8
lines changed Expand file tree Collapse file tree 3 files changed +35
-8
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ ra_cfg = { path = "../ra_cfg" }
2828ra_fmt = { path = " ../ra_fmt" }
2929ra_prof = { path = " ../ra_prof" }
3030test_utils = { path = " ../test_utils" }
31+ expect = { path = " ../expect" }
3132ra_assists = { path = " ../ra_assists" }
3233ra_ssr = { path = " ../ra_ssr" }
3334
Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ pub(crate) fn reference_definition(
103103
104104#[ cfg( test) ]
105105mod tests {
106+ use expect:: { expect, Expect } ;
106107 use test_utils:: assert_eq_text;
107108
108109 use crate :: mock_analysis:: analysis_and_position;
@@ -142,16 +143,40 @@ mod tests {
142143 nav. assert_match ( expected) ;
143144 }
144145
146+ fn check ( ra_fixture : & str , expect : Expect ) {
147+ let ( analysis, pos) = analysis_and_position ( ra_fixture) ;
148+
149+ let mut navs = analysis. goto_definition ( pos) . unwrap ( ) . unwrap ( ) . info ;
150+ if navs. len ( ) == 0 {
151+ panic ! ( "unresolved reference" )
152+ }
153+ assert_eq ! ( navs. len( ) , 1 ) ;
154+
155+ let nav = navs. pop ( ) . unwrap ( ) ;
156+ let file_text = analysis. file_text ( nav. file_id ( ) ) . unwrap ( ) ;
157+
158+ let mut actual = nav. debug_render ( ) ;
159+ actual += "\n " ;
160+ actual += & file_text[ nav. full_range ( ) ] . to_string ( ) ;
161+ if let Some ( focus) = nav. focus_range ( ) {
162+ actual += "|" ;
163+ actual += & file_text[ focus] ;
164+ actual += "\n " ;
165+ }
166+ expect. assert_eq ( & actual) ;
167+ }
168+
145169 #[ test]
146170 fn goto_def_in_items ( ) {
147- check_goto (
148- "
149- //- /lib.rs
150- struct Foo;
151- enum E { X(Foo<|>) }
152- " ,
153- "Foo STRUCT_DEF FileId(1) 0..11 7..10" ,
154- "struct Foo;|Foo" ,
171+ check (
172+ r#"
173+ struct Foo;
174+ enum E { X(Foo<|>) }
175+ "# ,
176+ expect ! [ [ r#"
177+ Foo STRUCT_DEF FileId(1) 0..11 7..10
178+ struct Foo;|Foo
179+ "# ] ] ,
155180 ) ;
156181 }
157182
You can’t perform that action at this time.
0 commit comments