diff options
Diffstat (limited to 'crates/ra_analysis/tests')
-rw-r--r-- | crates/ra_analysis/tests/test/main.rs (renamed from crates/ra_analysis/tests/tests.rs) | 35 | ||||
-rw-r--r-- | crates/ra_analysis/tests/test/runnables.rs (renamed from crates/ra_analysis/tests/runnables.rs) | 11 | ||||
-rw-r--r-- | crates/ra_analysis/tests/test/type_of.rs (renamed from crates/ra_analysis/tests/type_of.rs) | 4 |
3 files changed, 30 insertions, 20 deletions
diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/test/main.rs index bcf29d29c..beeae1e19 100644 --- a/crates/ra_analysis/tests/tests.rs +++ b/crates/ra_analysis/tests/test/main.rs | |||
@@ -1,9 +1,12 @@ | |||
1 | mod runnables; | ||
2 | mod type_of; | ||
3 | |||
1 | use ra_syntax::TextRange; | 4 | use ra_syntax::TextRange; |
2 | use test_utils::{assert_eq_dbg, assert_eq_text}; | 5 | use test_utils::{assert_eq_dbg, assert_eq_text}; |
3 | 6 | ||
4 | use ra_analysis::{ | 7 | use ra_analysis::{ |
5 | mock_analysis::{analysis_and_position, single_file, single_file_with_position, MockAnalysis}, | 8 | mock_analysis::{analysis_and_position, single_file, single_file_with_position, MockAnalysis}, |
6 | AnalysisChange, CrateGraph, FileId, FnSignatureInfo, | 9 | AnalysisChange, CrateGraph, FileId, FnSignatureInfo, Query |
7 | }; | 10 | }; |
8 | 11 | ||
9 | fn get_signature(text: &str) -> (FnSignatureInfo, Option<usize>) { | 12 | fn get_signature(text: &str) -> (FnSignatureInfo, Option<usize>) { |
@@ -135,14 +138,14 @@ fn test_resolve_parent_module_for_inline() { | |||
135 | fn test_resolve_crate_root() { | 138 | fn test_resolve_crate_root() { |
136 | let mock = MockAnalysis::with_files( | 139 | let mock = MockAnalysis::with_files( |
137 | " | 140 | " |
138 | //- /lib.rs | 141 | //- /bar.rs |
139 | mod foo; | 142 | mod foo; |
140 | //- /foo.rs | 143 | //- /bar/foo.rs |
141 | // emtpy <|> | 144 | // emtpy <|> |
142 | ", | 145 | ", |
143 | ); | 146 | ); |
144 | let root_file = mock.id_of("/lib.rs"); | 147 | let root_file = mock.id_of("/bar.rs"); |
145 | let mod_file = mock.id_of("/foo.rs"); | 148 | let mod_file = mock.id_of("/bar/foo.rs"); |
146 | let mut host = mock.analysis_host(); | 149 | let mut host = mock.analysis_host(); |
147 | assert!(host.analysis().crate_for(mod_file).unwrap().is_empty()); | 150 | assert!(host.analysis().crate_for(mod_file).unwrap().is_empty()); |
148 | 151 | ||
@@ -246,7 +249,8 @@ fn bar() { | |||
246 | fn test_fn_signature_with_docs_simple() { | 249 | fn test_fn_signature_with_docs_simple() { |
247 | let (desc, param) = get_signature( | 250 | let (desc, param) = get_signature( |
248 | r#" | 251 | r#" |
249 | // test | 252 | /// test |
253 | // non-doc-comment | ||
250 | fn foo(j: u32) -> u32 { | 254 | fn foo(j: u32) -> u32 { |
251 | j | 255 | j |
252 | } | 256 | } |
@@ -528,10 +532,11 @@ fn test_rename_for_mut_param() { | |||
528 | }"#, | 532 | }"#, |
529 | ); | 533 | ); |
530 | } | 534 | } |
535 | |||
531 | fn test_rename(text: &str, new_name: &str, expected: &str) { | 536 | fn test_rename(text: &str, new_name: &str, expected: &str) { |
532 | let (analysis, position) = single_file_with_position(text); | 537 | let (analysis, position) = single_file_with_position(text); |
533 | let edits = analysis.rename(position, new_name).unwrap(); | 538 | let edits = analysis.rename(position, new_name).unwrap(); |
534 | let mut text_edit_bulder = ra_text_edit::TextEditBuilder::new(); | 539 | let mut text_edit_bulder = ra_text_edit::TextEditBuilder::default(); |
535 | let mut file_id: Option<FileId> = None; | 540 | let mut file_id: Option<FileId> = None; |
536 | for edit in edits { | 541 | for edit in edits { |
537 | file_id = Some(edit.file_id); | 542 | file_id = Some(edit.file_id); |
@@ -544,3 +549,19 @@ fn test_rename(text: &str, new_name: &str, expected: &str) { | |||
544 | .apply(&*analysis.file_text(file_id.unwrap())); | 549 | .apply(&*analysis.file_text(file_id.unwrap())); |
545 | assert_eq_text!(expected, &*result); | 550 | assert_eq_text!(expected, &*result); |
546 | } | 551 | } |
552 | |||
553 | #[test] | ||
554 | fn world_symbols_include_stuff_from_macros() { | ||
555 | let (analysis, _) = single_file( | ||
556 | " | ||
557 | salsa::query_group! { | ||
558 | pub trait HirDatabase: SyntaxDatabase {} | ||
559 | } | ||
560 | ", | ||
561 | ); | ||
562 | |||
563 | let mut symbols = analysis.symbol_search(Query::new("Hir".into())).unwrap(); | ||
564 | let s = symbols.pop().unwrap(); | ||
565 | assert_eq!(s.name(), "HirDatabase"); | ||
566 | assert_eq!(s.range(), TextRange::from_to(33.into(), 44.into())); | ||
567 | } | ||
diff --git a/crates/ra_analysis/tests/runnables.rs b/crates/ra_analysis/tests/test/runnables.rs index 9e5342c46..e6e0afbc3 100644 --- a/crates/ra_analysis/tests/runnables.rs +++ b/crates/ra_analysis/tests/test/runnables.rs | |||
@@ -1,15 +1,6 @@ | |||
1 | extern crate ra_analysis; | ||
2 | extern crate ra_editor; | ||
3 | extern crate ra_syntax; | ||
4 | extern crate relative_path; | ||
5 | extern crate rustc_hash; | ||
6 | extern crate test_utils; | ||
7 | |||
8 | use test_utils::assert_eq_dbg; | 1 | use test_utils::assert_eq_dbg; |
9 | 2 | ||
10 | use ra_analysis::{ | 3 | use ra_analysis::mock_analysis::analysis_and_position; |
11 | mock_analysis::{analysis_and_position}, | ||
12 | }; | ||
13 | 4 | ||
14 | #[test] | 5 | #[test] |
15 | fn test_runnables() { | 6 | fn test_runnables() { |
diff --git a/crates/ra_analysis/tests/type_of.rs b/crates/ra_analysis/tests/test/type_of.rs index 375f808bb..9d15b52a8 100644 --- a/crates/ra_analysis/tests/type_of.rs +++ b/crates/ra_analysis/tests/test/type_of.rs | |||
@@ -1,6 +1,4 @@ | |||
1 | use ra_analysis::{ | 1 | use ra_analysis::mock_analysis::single_file_with_range; |
2 | mock_analysis::{single_file_with_range}, | ||
3 | }; | ||
4 | 2 | ||
5 | #[test] | 3 | #[test] |
6 | fn test_type_of_for_function() { | 4 | fn test_type_of_for_function() { |