mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
internal: improve feedback for relevance tests
This commit is contained in:
parent
fbb9d69758
commit
9b3292541c
1 changed files with 14 additions and 9 deletions
|
@ -330,6 +330,8 @@ fn compute_ref_match(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::cmp;
|
||||||
|
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
|
@ -352,9 +354,12 @@ mod tests {
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn check_relevance_for_kinds(kinds: &[CompletionKind], ra_fixture: &str, expect: Expect) {
|
fn check_relevance_for_kinds(kinds: &[CompletionKind], ra_fixture: &str, expect: Expect) {
|
||||||
let actual = get_all_items(TEST_CONFIG, ra_fixture)
|
let mut actual = get_all_items(TEST_CONFIG, ra_fixture);
|
||||||
|
actual.retain(|it| kinds.contains(&it.completion_kind));
|
||||||
|
actual.sort_by_key(|it| cmp::Reverse(it.relevance().score()));
|
||||||
|
|
||||||
|
let actual = actual
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|it| kinds.contains(&it.completion_kind))
|
|
||||||
.flat_map(|it| {
|
.flat_map(|it| {
|
||||||
let mut items = vec![];
|
let mut items = vec![];
|
||||||
|
|
||||||
|
@ -921,9 +926,9 @@ fn test(bar: u32) { }
|
||||||
fn foo(s: S) { test(s.$0) }
|
fn foo(s: S) { test(s.$0) }
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
fd foo []
|
|
||||||
fd bar [type+name]
|
fd bar [type+name]
|
||||||
fd baz [type]
|
fd baz [type]
|
||||||
|
fd foo []
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -937,9 +942,9 @@ struct B { x: (), y: f32, bar: u32 }
|
||||||
fn foo(a: A) { B { bar: a.$0 }; }
|
fn foo(a: A) { B { bar: a.$0 }; }
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
fd foo []
|
|
||||||
fd bar [type+name]
|
fd bar [type+name]
|
||||||
fd baz [type]
|
fd baz [type]
|
||||||
|
fd foo []
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -967,9 +972,9 @@ fn f(foo: i64) { }
|
||||||
fn foo(a: A) { f(B { bar: a.$0 }); }
|
fn foo(a: A) { f(B { bar: a.$0 }); }
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
fd foo []
|
|
||||||
fd bar [type+name]
|
fd bar [type+name]
|
||||||
fd baz [type]
|
fd baz [type]
|
||||||
|
fd foo []
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1015,9 +1020,9 @@ fn bar() -> u8 { 0 }
|
||||||
fn f() { A { bar: b$0 }; }
|
fn f() { A { bar: b$0 }; }
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
|
fn bar() [type+name]
|
||||||
fn baz() [type]
|
fn baz() [type]
|
||||||
st A []
|
st A []
|
||||||
fn bar() [type+name]
|
|
||||||
fn f() []
|
fn f() []
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
@ -1340,9 +1345,9 @@ fn foo() {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
|
lc foo [type+local]
|
||||||
ev Foo::A(…) [type_could_unify]
|
ev Foo::A(…) [type_could_unify]
|
||||||
ev Foo::B [type_could_unify]
|
ev Foo::B [type_could_unify]
|
||||||
lc foo [type+local]
|
|
||||||
en Foo []
|
en Foo []
|
||||||
fn baz() []
|
fn baz() []
|
||||||
fn bar() []
|
fn bar() []
|
||||||
|
@ -1373,9 +1378,10 @@ fn main() {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
|
sn not [snippet]
|
||||||
|
me not() (ops::Not) [type_could_unify]
|
||||||
sn if []
|
sn if []
|
||||||
sn while []
|
sn while []
|
||||||
sn not [snippet]
|
|
||||||
sn ref []
|
sn ref []
|
||||||
sn refm []
|
sn refm []
|
||||||
sn match []
|
sn match []
|
||||||
|
@ -1386,7 +1392,6 @@ fn main() {
|
||||||
sn dbg []
|
sn dbg []
|
||||||
sn dbgr []
|
sn dbgr []
|
||||||
sn call []
|
sn call []
|
||||||
me not() (ops::Not) [type_could_unify]
|
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue