diff options
author | Igor Aleksanov <[email protected]> | 2020-11-01 10:36:30 +0000 |
---|---|---|
committer | Igor Aleksanov <[email protected]> | 2020-11-03 07:16:35 +0000 |
commit | 97a504805d4b0cf8b48bc5052453b2b2f3298449 (patch) | |
tree | dd5da407ca9332898107fd51199ea49f396f7590 /crates/completion/src/render/enum_variant.rs | |
parent | 15b16917fcd55068d9aba3d4b5d87763ec5deb69 (diff) |
Move rendering tests to the render module
Diffstat (limited to 'crates/completion/src/render/enum_variant.rs')
-rw-r--r-- | crates/completion/src/render/enum_variant.rs | 74 |
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)] | ||
98 | mod 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#" | ||
109 | enum Option<T> { Some(T), None } | ||
110 | use Option::*; | ||
111 | fn main() -> Option<i32> { | ||
112 | Som<|> | ||
113 | } | ||
114 | "#, | ||
115 | r#" | ||
116 | enum Option<T> { Some(T), None } | ||
117 | use Option::*; | ||
118 | fn main() -> Option<i32> { | ||
119 | Some($0) | ||
120 | } | ||
121 | "#, | ||
122 | ); | ||
123 | check_edit( | ||
124 | "Some", | ||
125 | r#" | ||
126 | enum Option<T> { Some(T), None } | ||
127 | use Option::*; | ||
128 | fn main(value: Option<i32>) { | ||
129 | match value { | ||
130 | Som<|> | ||
131 | } | ||
132 | } | ||
133 | "#, | ||
134 | r#" | ||
135 | enum Option<T> { Some(T), None } | ||
136 | use Option::*; | ||
137 | fn 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#" | ||
152 | enum E { Var(i32) } | ||
153 | fn main() { | ||
154 | match E::Var(92) { | ||
155 | E::<|>(92) => (), | ||
156 | } | ||
157 | } | ||
158 | "#, | ||
159 | r#" | ||
160 | enum E { Var(i32) } | ||
161 | fn main() { | ||
162 | match E::Var(92) { | ||
163 | E::Var(92) => (), | ||
164 | } | ||
165 | } | ||
166 | "#, | ||
167 | ); | ||
168 | } | ||
169 | } | ||