aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/tests')
-rw-r--r--crates/ra_analysis/tests/tests.rs45
1 files changed, 26 insertions, 19 deletions
diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs
index c2754c8e4..c605d34f0 100644
--- a/crates/ra_analysis/tests/tests.rs
+++ b/crates/ra_analysis/tests/tests.rs
@@ -15,10 +15,7 @@ use ra_analysis::{
15 15
16fn get_signature(text: &str) -> (FnDescriptor, Option<usize>) { 16fn get_signature(text: &str) -> (FnDescriptor, Option<usize>) {
17 let (analysis, position) = single_file_with_position(text); 17 let (analysis, position) = single_file_with_position(text);
18 analysis 18 analysis.resolve_callable(position).unwrap().unwrap()
19 .resolve_callable(position.file_id, position.offset)
20 .unwrap()
21 .unwrap()
22} 19}
23 20
24#[test] 21#[test]
@@ -32,9 +29,7 @@ fn test_resolve_module() {
32 ", 29 ",
33 ); 30 );
34 31
35 let symbols = analysis 32 let symbols = analysis.approximately_resolve_symbol(pos).unwrap();
36 .approximately_resolve_symbol(pos.file_id, pos.offset)
37 .unwrap();
38 assert_eq_dbg( 33 assert_eq_dbg(
39 r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#, 34 r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#,
40 &symbols, 35 &symbols,
@@ -49,9 +44,7 @@ fn test_resolve_module() {
49 ", 44 ",
50 ); 45 );
51 46
52 let symbols = analysis 47 let symbols = analysis.approximately_resolve_symbol(pos).unwrap();
53 .approximately_resolve_symbol(pos.file_id, pos.offset)
54 .unwrap();
55 assert_eq_dbg( 48 assert_eq_dbg(
56 r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#, 49 r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#,
57 &symbols, 50 &symbols,
@@ -92,9 +85,28 @@ fn test_resolve_parent_module() {
92 <|>// empty 85 <|>// empty
93 ", 86 ",
94 ); 87 );
95 let symbols = analysis.parent_module(pos.file_id).unwrap(); 88 let symbols = analysis.parent_module(pos).unwrap();
96 assert_eq_dbg( 89 assert_eq_dbg(
97 r#"[(FileId(1), FileSymbol { name: "foo", node_range: [0; 8), kind: MODULE })]"#, 90 r#"[(FileId(1), FileSymbol { name: "foo", node_range: [4; 7), kind: MODULE })]"#,
91 &symbols,
92 );
93}
94
95#[test]
96fn test_resolve_parent_module_for_inline() {
97 let (analysis, pos) = analysis_and_position(
98 "
99 //- /lib.rs
100 mod foo {
101 mod bar {
102 mod baz { <|> }
103 }
104 }
105 ",
106 );
107 let symbols = analysis.parent_module(pos).unwrap();
108 assert_eq_dbg(
109 r#"[(FileId(1), FileSymbol { name: "bar", node_range: [18; 21), kind: MODULE })]"#,
98 &symbols, 110 &symbols,
99 ); 111 );
100} 112}
@@ -378,9 +390,7 @@ By default this method stops actor's `Context`."#
378 390
379fn get_all_refs(text: &str) -> Vec<(FileId, TextRange)> { 391fn get_all_refs(text: &str) -> Vec<(FileId, TextRange)> {
380 let (analysis, position) = single_file_with_position(text); 392 let (analysis, position) = single_file_with_position(text);
381 analysis 393 analysis.find_all_refs(position).unwrap()
382 .find_all_refs(position.file_id, position.offset)
383 .unwrap()
384} 394}
385 395
386#[test] 396#[test]
@@ -435,10 +445,7 @@ fn test_complete_crate_path() {
435 use crate::Sp<|> 445 use crate::Sp<|>
436 ", 446 ",
437 ); 447 );
438 let completions = analysis 448 let completions = analysis.completions(position).unwrap().unwrap();
439 .completions(position.file_id, position.offset)
440 .unwrap()
441 .unwrap();
442 assert_eq_dbg( 449 assert_eq_dbg(
443 r#"[CompletionItem { label: "foo", lookup: None, snippet: None }, 450 r#"[CompletionItem { label: "foo", lookup: None, snippet: None },
444 CompletionItem { label: "Spam", lookup: None, snippet: None }]"#, 451 CompletionItem { label: "Spam", lookup: None, snippet: None }]"#,