Added tests to test associated types and consts.

This commit is contained in:
Kevin DeLorey 2020-02-10 21:02:51 -06:00
parent 52c4324e31
commit 785723e0d9

View File

@ -283,4 +283,82 @@ impl Test for T1 {
]
"###);
}
#[test]
fn associated_type() {
let completions = complete(
r"
trait Test {
type SomeType;
}
impl Test for () {
<|>
}
",
);
assert_debug_snapshot!(completions, @r###"
[
CompletionItem {
label: "type SomeType = ",
source_range: [119; 119),
delete: [119; 119),
insert: "type SomeType = ",
kind: TypeAlias,
},
]
"###);
}
#[test]
fn associated_const() {
let completions = complete(
r"
trait Test {
const SOME_CONST: u16;
}
impl Test for () {
<|>
}
",
);
assert_debug_snapshot!(completions, @r###"
[
CompletionItem {
label: "const SOME_CONST: u16 = ",
source_range: [127; 127),
delete: [127; 127),
insert: "const SOME_CONST: u16 = ",
kind: Const,
},
]
"###);
}
#[test]
fn associated_const_with_default() {
let completions = complete(
r"
trait Test {
const SOME_CONST: u16 = 42;
}
impl Test for () {
<|>
}
",
);
assert_debug_snapshot!(completions, @r###"
[
CompletionItem {
label: "const SOME_CONST: u16 = ",
source_range: [132; 132),
delete: [132; 132),
insert: "const SOME_CONST: u16 = ",
kind: Const,
},
]
"###);
}
}