aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast.rs')
-rw-r--r--crates/ra_syntax/src/ast.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 1b2ce921a..a12da5be2 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -173,7 +173,7 @@ fn test_doc_comment_single_line_block_strips_suffix_whitespace() {
173 .ok() 173 .ok()
174 .unwrap(); 174 .unwrap();
175 let module = file.syntax().descendants().find_map(Module::cast).unwrap(); 175 let module = file.syntax().descendants().find_map(Module::cast).unwrap();
176 assert_eq!("this is mod foo", module.doc_comment_text().unwrap()); 176 assert_eq!("this is mod foo ", module.doc_comment_text().unwrap());
177} 177}
178 178
179#[test] 179#[test]
@@ -191,7 +191,27 @@ fn test_doc_comment_multi_line_block_strips_suffix() {
191 .ok() 191 .ok()
192 .unwrap(); 192 .unwrap();
193 let module = file.syntax().descendants().find_map(Module::cast).unwrap(); 193 let module = file.syntax().descendants().find_map(Module::cast).unwrap();
194 assert_eq!(" this\n is\n mod foo", module.doc_comment_text().unwrap()); 194 assert_eq!(
195 " this\n is\n mod foo\n ",
196 module.doc_comment_text().unwrap()
197 );
198}
199
200#[test]
201fn test_comments_preserve_trailing_whitespace() {
202 let file = SourceFile::parse(
203 r#"
204/// Representation of a Realm.
205/// In the specification these are called Realm Records.
206struct Realm {}"#,
207 )
208 .ok()
209 .unwrap();
210 let def = file.syntax().descendants().find_map(StructDef::cast).unwrap();
211 assert_eq!(
212 "Representation of a Realm. \nIn the specification these are called Realm Records.",
213 def.doc_comment_text().unwrap()
214 );
195} 215}
196 216
197#[test] 217#[test]