aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src/render/enum_variant.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/completion/src/render/enum_variant.rs')
-rw-r--r--crates/completion/src/render/enum_variant.rs74
1 files changed, 74 insertions, 0 deletions
diff --git a/crates/completion/src/render/enum_variant.rs b/crates/completion/src/render/enum_variant.rs
index 26cfdfeea..bc96cc303 100644
--- a/crates/completion/src/render/enum_variant.rs
+++ b/crates/completion/src/render/enum_variant.rs
@@ -93,3 +93,77 @@ impl<'a> EnumVariantRender<'a> {
93 } 93 }
94 } 94 }
95} 95}
96
97#[cfg(test)]
98mod tests {
99 use test_utils::mark;
100
101 use crate::test_utils::check_edit;
102
103 #[test]
104 fn inserts_parens_for_tuple_enums() {
105 mark::check!(inserts_parens_for_tuple_enums);
106 check_edit(
107 "Some",
108 r#"
109enum Option<T> { Some(T), None }
110use Option::*;
111fn main() -> Option<i32> {
112 Som<|>
113}
114"#,
115 r#"
116enum Option<T> { Some(T), None }
117use Option::*;
118fn main() -> Option<i32> {
119 Some($0)
120}
121"#,
122 );
123 check_edit(
124 "Some",
125 r#"
126enum Option<T> { Some(T), None }
127use Option::*;
128fn main(value: Option<i32>) {
129 match value {
130 Som<|>
131 }
132}
133"#,
134 r#"
135enum Option<T> { Some(T), None }
136use Option::*;
137fn main(value: Option<i32>) {
138 match value {
139 Some($0)
140 }
141}
142"#,
143 );
144 }
145
146 #[test]
147 fn dont_duplicate_pattern_parens() {
148 mark::check!(dont_duplicate_pattern_parens);
149 check_edit(
150 "Var",
151 r#"
152enum E { Var(i32) }
153fn main() {
154 match E::Var(92) {
155 E::<|>(92) => (),
156 }
157}
158"#,
159 r#"
160enum E { Var(i32) }
161fn main() {
162 match E::Var(92) {
163 E::Var(92) => (),
164 }
165}
166"#,
167 );
168 }
169}