From e89700f9678d3797c09f0a397b7b67fe9c6f5e9f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 28 Nov 2018 16:19:01 +0300 Subject: Move hir tests to hit --- crates/ra_analysis/src/lib.rs | 109 ------------------------------------------ 1 file changed, 109 deletions(-) (limited to 'crates/ra_analysis/src/lib.rs') diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 350a6d627..12df580ba 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs @@ -317,112 +317,3 @@ fn analysis_is_send() { fn is_send() {} is_send::(); } - -//TODO: move to hir -#[cfg(test)] -mod hir_namres_tests { - use std::sync::Arc; - use ra_db::FilesDatabase; - use ra_syntax::SmolStr; - use hir::{self, db::HirDatabase}; - - use crate::{ - AnalysisChange, - mock_analysis::{MockAnalysis, analysis_and_position}, -}; - - fn item_map(fixture: &str) -> (Arc, hir::ModuleId) { - let (analysis, pos) = analysis_and_position(fixture); - let db = analysis.imp.db; - let source_root = db.file_source_root(pos.file_id); - let descr = hir::Module::guess_from_position(&*db, pos) - .unwrap() - .unwrap(); - let module_id = descr.module_id; - (db.item_map(source_root).unwrap(), module_id) - } - - #[test] - fn test_item_map() { - let (item_map, module_id) = item_map( - " - //- /lib.rs - mod foo; - - use crate::foo::bar::Baz; - <|> - - //- /foo/mod.rs - pub mod bar; - - //- /foo/bar.rs - pub struct Baz; - ", - ); - let name = SmolStr::from("Baz"); - let resolution = &item_map.per_module[&module_id].items[&name]; - assert!(resolution.def_id.is_some()); - } - - #[test] - fn typing_inside_a_function_should_not_invalidate_item_map() { - let mock_analysis = MockAnalysis::with_files( - " - //- /lib.rs - mod foo; - - use crate::foo::bar::Baz; - - fn foo() -> i32 { - 1 + 1 - } - //- /foo/mod.rs - pub mod bar; - - //- /foo/bar.rs - pub struct Baz; - ", - ); - - let file_id = mock_analysis.id_of("/lib.rs"); - let mut host = mock_analysis.analysis_host(); - - let source_root = host.analysis().imp.db.file_source_root(file_id); - - { - let db = host.analysis().imp.db; - let events = db.log_executed(|| { - db.item_map(source_root).unwrap(); - }); - assert!(format!("{:?}", events).contains("item_map")) - } - - let mut change = AnalysisChange::new(); - - change.change_file( - file_id, - " - mod foo; - - use crate::foo::bar::Baz; - - fn foo() -> i32 { 92 } - " - .to_string(), - ); - - host.apply_change(change); - - { - let db = host.analysis().imp.db; - let events = db.log_executed(|| { - db.item_map(source_root).unwrap(); - }); - assert!( - !format!("{:?}", events).contains("_item_map"), - "{:#?}", - events - ) - } - } -} -- cgit v1.2.3