Minor incremental tests cleanup

This commit is contained in:
Aleksey Kladov 2020-03-26 15:44:31 +01:00
parent ece8fa81bb
commit b7aaefb5a4
2 changed files with 10 additions and 10 deletions

View file

@ -28,9 +28,9 @@ pub trait WithFixture: Default + SourceDatabaseExt + 'static {
db db
} }
fn with_position(fixture: &str) -> (Self, FilePosition) { fn with_position(ra_fixture: &str) -> (Self, FilePosition) {
let mut db = Self::default(); let mut db = Self::default();
let pos = with_files(&mut db, fixture); let pos = with_files(&mut db, ra_fixture);
(db, pos.unwrap()) (db, pos.unwrap())
} }

View file

@ -4,8 +4,8 @@ use ra_db::SourceDatabaseExt;
use super::*; use super::*;
fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) { fn check_def_map_is_not_recomputed(ra_fixture_initial: &str, ra_fixture_change: &str) {
let (mut db, pos) = TestDB::with_position(initial); let (mut db, pos) = TestDB::with_position(ra_fixture_initial);
let krate = db.test_crate(); let krate = db.test_crate();
{ {
let events = db.log_executed(|| { let events = db.log_executed(|| {
@ -13,7 +13,7 @@ fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) {
}); });
assert!(format!("{:?}", events).contains("crate_def_map"), "{:#?}", events) assert!(format!("{:?}", events).contains("crate_def_map"), "{:#?}", events)
} }
db.set_file_text(pos.file_id, Arc::new(file_change.to_string())); db.set_file_text(pos.file_id, Arc::new(ra_fixture_change.to_string()));
{ {
let events = db.log_executed(|| { let events = db.log_executed(|| {
@ -26,7 +26,7 @@ fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) {
#[test] #[test]
fn typing_inside_a_function_should_not_invalidate_def_map() { fn typing_inside_a_function_should_not_invalidate_def_map() {
check_def_map_is_not_recomputed( check_def_map_is_not_recomputed(
" r"
//- /lib.rs //- /lib.rs
mod foo;<|> mod foo;<|>
@ -41,7 +41,7 @@ fn typing_inside_a_function_should_not_invalidate_def_map() {
//- /foo/bar.rs //- /foo/bar.rs
pub struct Baz; pub struct Baz;
", ",
" r"
mod foo; mod foo;
use crate::foo::bar::Baz; use crate::foo::bar::Baz;
@ -54,7 +54,7 @@ fn typing_inside_a_function_should_not_invalidate_def_map() {
#[test] #[test]
fn adding_inner_items_should_not_invalidate_def_map() { fn adding_inner_items_should_not_invalidate_def_map() {
check_def_map_is_not_recomputed( check_def_map_is_not_recomputed(
" r"
//- /lib.rs //- /lib.rs
struct S { a: i32} struct S { a: i32}
enum E { A } enum E { A }
@ -72,7 +72,7 @@ fn adding_inner_items_should_not_invalidate_def_map() {
//- /foo/bar.rs //- /foo/bar.rs
pub struct Baz; pub struct Baz;
", ",
" r"
struct S { a: i32, b: () } struct S { a: i32, b: () }
enum E { A, B } enum E { A, B }
trait T { trait T {
@ -92,7 +92,7 @@ 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() {
let (mut db, pos) = TestDB::with_position( let (mut db, pos) = TestDB::with_position(
" r"
//- /lib.rs //- /lib.rs
macro_rules! m { macro_rules! m {
($ident:ident) => { ($ident:ident) => {