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/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 @@
1mod runnables;
2mod type_of;
3
1use ra_syntax::TextRange; 4use ra_syntax::TextRange;
2use test_utils::{assert_eq_dbg, assert_eq_text}; 5use test_utils::{assert_eq_dbg, assert_eq_text};
3 6
4use ra_analysis::{ 7use 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
9fn get_signature(text: &str) -> (FnSignatureInfo, Option<usize>) { 12fn get_signature(text: &str) -> (FnSignatureInfo, Option<usize>) {
@@ -135,14 +138,14 @@ fn test_resolve_parent_module_for_inline() {
135fn test_resolve_crate_root() { 138fn 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() {
246fn test_fn_signature_with_docs_simple() { 249fn 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
250fn foo(j: u32) -> u32 { 254fn 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
531fn test_rename(text: &str, new_name: &str, expected: &str) { 536fn 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]
554fn world_symbols_include_stuff_from_macros() {
555 let (analysis, _) = single_file(
556 "
557salsa::query_group! {
558pub 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 @@
1extern crate ra_analysis;
2extern crate ra_editor;
3extern crate ra_syntax;
4extern crate relative_path;
5extern crate rustc_hash;
6extern crate test_utils;
7
8use test_utils::assert_eq_dbg; 1use test_utils::assert_eq_dbg;
9 2
10use ra_analysis::{ 3use ra_analysis::mock_analysis::analysis_and_position;
11 mock_analysis::{analysis_and_position},
12};
13 4
14#[test] 5#[test]
15fn test_runnables() { 6fn 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 @@
1use ra_analysis::{ 1use ra_analysis::mock_analysis::single_file_with_range;
2 mock_analysis::{single_file_with_range},
3};
4 2
5#[test] 3#[test]
6fn test_type_of_for_function() { 4fn test_type_of_for_function() {