1060: more realistic test for incrementality r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-03-26 16:55:19 +00:00
commit 1011e37f3a

View File

@ -92,12 +92,14 @@ fn adding_inner_items_should_not_invalidate_def_map() {
#[test] #[test]
fn typing_inside_a_macro_should_not_invalidate_def_map() { 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 //- /lib.rs
macro_rules! m { macro_rules! m {
($ident:ident) => { ($ident:ident) => {
struct Foo; fn f() {
$ident + $ident;
};
} }
} }
mod foo; mod foo;
@ -109,8 +111,23 @@ fn typing_inside_a_macro_should_not_invalidate_def_map() {
<|> <|>
m!(X); 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)
}
} }