mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Start refactoring ide_completion tests
This commit is contained in:
parent
f38770cd26
commit
d338a80394
9 changed files with 306 additions and 251 deletions
172
crates/ide_completion/src/tests/item_list.rs
Normal file
172
crates/ide_completion/src/tests/item_list.rs
Normal file
|
@ -0,0 +1,172 @@
|
|||
use expect_test::expect;
|
||||
|
||||
use crate::tests::check;
|
||||
|
||||
#[test]
|
||||
fn in_mod_item_list() {
|
||||
check(
|
||||
r#"mod tests {
|
||||
$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
kw pub(crate)
|
||||
kw pub
|
||||
kw unsafe
|
||||
kw fn
|
||||
kw const
|
||||
kw type
|
||||
kw use
|
||||
kw impl
|
||||
kw trait
|
||||
kw static
|
||||
kw extern
|
||||
kw mod
|
||||
kw enum
|
||||
kw struct
|
||||
kw union
|
||||
sn tmod (Test module)
|
||||
sn tfn (Test function)
|
||||
sn macro_rules
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn in_source_file_item_list() {
|
||||
check(
|
||||
r#"
|
||||
enum Enum { Variant }
|
||||
struct MyStruct {}
|
||||
#[macro_export]
|
||||
macro_rules! foo {}
|
||||
mod bar {}
|
||||
const CONST: () = ();
|
||||
|
||||
$0"#,
|
||||
expect![[r##"
|
||||
kw pub(crate)
|
||||
kw pub
|
||||
kw unsafe
|
||||
kw fn
|
||||
kw const
|
||||
kw type
|
||||
kw use
|
||||
kw impl
|
||||
kw trait
|
||||
kw static
|
||||
kw extern
|
||||
kw mod
|
||||
kw enum
|
||||
kw struct
|
||||
kw union
|
||||
sn tmod (Test module)
|
||||
sn tfn (Test function)
|
||||
sn macro_rules
|
||||
md bar
|
||||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
"##]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn in_qualified_path() {
|
||||
check(
|
||||
r#"
|
||||
enum Enum { Variant }
|
||||
struct MyStruct {}
|
||||
#[macro_export]
|
||||
macro_rules! foo {}
|
||||
mod bar {}
|
||||
const CONST: () = ();
|
||||
|
||||
crate::$0"#,
|
||||
expect![[r##"
|
||||
kw pub(crate)
|
||||
kw pub
|
||||
kw unsafe
|
||||
kw fn
|
||||
kw const
|
||||
kw type
|
||||
kw use
|
||||
kw impl
|
||||
kw trait
|
||||
kw static
|
||||
kw extern
|
||||
kw mod
|
||||
kw enum
|
||||
kw struct
|
||||
kw union
|
||||
sn tmod (Test module)
|
||||
sn tfn (Test function)
|
||||
sn macro_rules
|
||||
md bar
|
||||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
"##]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn after_unsafe_token() {
|
||||
check(
|
||||
r#"
|
||||
enum Enum { Variant }
|
||||
struct MyStruct {}
|
||||
#[macro_export]
|
||||
macro_rules! foo {}
|
||||
mod bar {}
|
||||
const CONST: () = ();
|
||||
|
||||
unsafe $0"#,
|
||||
expect![[r##"
|
||||
kw fn
|
||||
kw trait
|
||||
kw impl
|
||||
sn tmod (Test module)
|
||||
sn tfn (Test function)
|
||||
sn macro_rules
|
||||
md bar
|
||||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn after_visibility() {
|
||||
check(
|
||||
r#"
|
||||
enum Enum { Variant }
|
||||
struct MyStruct {}
|
||||
#[macro_export]
|
||||
macro_rules! foo {}
|
||||
mod bar {}
|
||||
const CONST: () = ();
|
||||
|
||||
pub $0"#,
|
||||
expect![[r##"
|
||||
kw pub(crate)
|
||||
kw pub
|
||||
kw unsafe
|
||||
kw fn
|
||||
kw const
|
||||
kw type
|
||||
kw use
|
||||
kw impl
|
||||
kw trait
|
||||
kw static
|
||||
kw extern
|
||||
kw mod
|
||||
kw enum
|
||||
kw struct
|
||||
kw union
|
||||
sn tmod (Test module)
|
||||
sn tfn (Test function)
|
||||
sn macro_rules
|
||||
md bar
|
||||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
"##]],
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue