diff options
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index c5746d98d..6f0489617 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -139,6 +139,52 @@ fn test_doc_comment_preserves_newlines() { | |||
139 | } | 139 | } |
140 | 140 | ||
141 | #[test] | 141 | #[test] |
142 | fn test_doc_comment_single_line_block_strips_suffix() { | ||
143 | let file = SourceFile::parse( | ||
144 | r#" | ||
145 | /** this is mod foo*/ | ||
146 | mod foo {} | ||
147 | "#, | ||
148 | ) | ||
149 | .ok() | ||
150 | .unwrap(); | ||
151 | let module = file.syntax().descendants().find_map(Module::cast).unwrap(); | ||
152 | assert_eq!("this is mod foo", module.doc_comment_text().unwrap()); | ||
153 | } | ||
154 | |||
155 | #[test] | ||
156 | fn test_doc_comment_single_line_block_strips_suffix_whitespace() { | ||
157 | let file = SourceFile::parse( | ||
158 | r#" | ||
159 | /** this is mod foo */ | ||
160 | mod foo {} | ||
161 | "#, | ||
162 | ) | ||
163 | .ok() | ||
164 | .unwrap(); | ||
165 | let module = file.syntax().descendants().find_map(Module::cast).unwrap(); | ||
166 | assert_eq!("this is mod foo", module.doc_comment_text().unwrap()); | ||
167 | } | ||
168 | |||
169 | #[test] | ||
170 | fn test_doc_comment_multi_line_block_strips_suffix() { | ||
171 | let file = SourceFile::parse( | ||
172 | r#" | ||
173 | /** | ||
174 | this | ||
175 | is | ||
176 | mod foo | ||
177 | */ | ||
178 | mod foo {} | ||
179 | "#, | ||
180 | ) | ||
181 | .ok() | ||
182 | .unwrap(); | ||
183 | let module = file.syntax().descendants().find_map(Module::cast).unwrap(); | ||
184 | assert_eq!(" this\n is\n mod foo", module.doc_comment_text().unwrap()); | ||
185 | } | ||
186 | |||
187 | #[test] | ||
142 | fn test_where_predicates() { | 188 | fn test_where_predicates() { |
143 | fn assert_bound(text: &str, bound: Option<TypeBound>) { | 189 | fn assert_bound(text: &str, bound: Option<TypeBound>) { |
144 | assert_eq!(text, bound.unwrap().syntax().text().to_string()); | 190 | assert_eq!(text, bound.unwrap().syntax().text().to_string()); |