From a3fee2bda04be27a63d9298f6e97555c904df4da Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 26 Mar 2019 19:54:52 +0300 Subject: more realistic test for incrementality --- crates/ra_hir/src/nameres/tests/incremental.rs | 27 +++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir') diff --git a/crates/ra_hir/src/nameres/tests/incremental.rs b/crates/ra_hir/src/nameres/tests/incremental.rs index a059634e2..001f76ac3 100644 --- a/crates/ra_hir/src/nameres/tests/incremental.rs +++ b/crates/ra_hir/src/nameres/tests/incremental.rs @@ -92,12 +92,14 @@ fn adding_inner_items_should_not_invalidate_def_map() { #[test] fn typing_inside_a_macro_should_not_invalidate_def_map() { - check_def_map_is_not_recomputed( + let (mut db, pos) = MockDatabase::with_position( " //- /lib.rs macro_rules! m { ($ident:ident) => { - struct Foo; + fn f() { + $ident + $ident; + }; } } mod foo; @@ -109,8 +111,23 @@ fn typing_inside_a_macro_should_not_invalidate_def_map() { <|> m!(X); ", - " - m!(Y); - ", ); + { + let events = db.log_executed(|| { + let module = crate::source_binder::module_from_file_id(&db, pos.file_id).unwrap(); + let decls = module.declarations(&db); + assert_eq!(decls.len(), 1); + }); + assert!(format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) + } + db.set_file_text(pos.file_id, Arc::new("m!(Y);".to_string())); + + { + let events = db.log_executed(|| { + let module = crate::source_binder::module_from_file_id(&db, pos.file_id).unwrap(); + let decls = module.declarations(&db); + assert_eq!(decls.len(), 1); + }); + assert!(!format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) + } } -- cgit v1.2.3