mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
add tests for full signatures
This commit is contained in:
parent
6b487ed4be
commit
9f3d627681
@ -2,10 +2,15 @@
|
|||||||
|
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
|
|
||||||
use crate::tests::{
|
use crate::{
|
||||||
check_edit, completion_list, completion_list_no_kw, completion_list_with_trigger_character,
|
tests::{
|
||||||
|
check_edit, completion_list, completion_list_no_kw, completion_list_with_trigger_character,
|
||||||
|
},
|
||||||
|
CompletionItemKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::{do_completion_with_config, TEST_CONFIG};
|
||||||
|
|
||||||
fn check_no_kw(ra_fixture: &str, expect: Expect) {
|
fn check_no_kw(ra_fixture: &str, expect: Expect) {
|
||||||
let actual = completion_list_no_kw(ra_fixture);
|
let actual = completion_list_no_kw(ra_fixture);
|
||||||
expect.assert_eq(&actual)
|
expect.assert_eq(&actual)
|
||||||
@ -1303,3 +1308,67 @@ struct Foo<T: PartialOrd
|
|||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn check_signatures(src: &str, kind: CompletionItemKind, reduced: Expect, full: Expect) {
|
||||||
|
const FULL_SIGNATURES_CONFIG: crate::CompletionConfig = {
|
||||||
|
let mut x = TEST_CONFIG;
|
||||||
|
x.full_function_signatures = true;
|
||||||
|
x
|
||||||
|
};
|
||||||
|
|
||||||
|
// reduced signature
|
||||||
|
let completion = do_completion_with_config(TEST_CONFIG, src, kind);
|
||||||
|
assert!(completion[0].detail.is_some());
|
||||||
|
reduced.assert_eq(completion[0].detail.as_ref().unwrap());
|
||||||
|
|
||||||
|
// full signature
|
||||||
|
let completion = do_completion_with_config(FULL_SIGNATURES_CONFIG, src, kind);
|
||||||
|
assert!(completion[0].detail.is_some());
|
||||||
|
full.assert_eq(completion[0].detail.as_ref().unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn respects_full_function_signatures() {
|
||||||
|
check_signatures(
|
||||||
|
r#"
|
||||||
|
pub fn foo<'x, T>(x: &'x mut T) -> u8 where T: Clone, { 0u8 }
|
||||||
|
fn main() { fo$0 }
|
||||||
|
"#,
|
||||||
|
CompletionItemKind::SymbolKind(ide_db::SymbolKind::Function),
|
||||||
|
expect!("fn(&mut T) -> u8"),
|
||||||
|
expect!("pub fn foo<'x, T>(x: &'x mut T) -> u8 where T: Clone,"),
|
||||||
|
);
|
||||||
|
|
||||||
|
check_signatures(
|
||||||
|
r#"
|
||||||
|
struct Foo;
|
||||||
|
struct Bar;
|
||||||
|
impl Bar {
|
||||||
|
pub const fn baz(x: Foo) -> ! { loop {} };
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() { Bar::b$0 }
|
||||||
|
"#,
|
||||||
|
CompletionItemKind::SymbolKind(ide_db::SymbolKind::Function),
|
||||||
|
expect!("const fn(Foo) -> !"),
|
||||||
|
expect!("pub const fn baz(x: Foo) -> !"),
|
||||||
|
);
|
||||||
|
|
||||||
|
check_signatures(
|
||||||
|
r#"
|
||||||
|
struct Foo;
|
||||||
|
struct Bar;
|
||||||
|
impl Bar {
|
||||||
|
pub const fn baz<'foo>(&'foo mut self, x: &'foo Foo) -> ! { loop {} };
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut bar = Bar;
|
||||||
|
bar.b$0
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
CompletionItemKind::Method,
|
||||||
|
expect!("const fn(&'foo mut self, &Foo) -> !"),
|
||||||
|
expect!("pub const fn baz<'foo>(&'foo mut self, x: &'foo Foo) -> !"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user