From 4fccad9b2cea8b17066308129c9add49861f8e07 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Wed, 31 Jul 2019 10:46:15 -0400 Subject: Add explicit newline preserving tests --- crates/ra_lsp_server/src/markdown.rs | 6 ++++++ crates/ra_syntax/src/ast.rs | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/crates/ra_lsp_server/src/markdown.rs b/crates/ra_lsp_server/src/markdown.rs index 53cf24482..947ef77cd 100644 --- a/crates/ra_lsp_server/src/markdown.rs +++ b/crates/ra_lsp_server/src/markdown.rs @@ -48,4 +48,10 @@ mod tests { let comment = " # stay1\n# stay2\n#stay3\nstay4\n#\n #\n # \n #\tstay5\n\t#\t"; assert_eq!(format_docs(comment), comment); } + + #[test] + fn test_format_docs_preserves_newlines() { + let comment = "this\nis\nultiline"; + assert_eq!(format_docs(comment), comment); + } } diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 4a38197f6..c5746d98d 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -121,6 +121,23 @@ fn test_doc_comment_preserves_indents() { assert_eq!("doc1\n```\nfn foo() {\n // ...\n}\n```", module.doc_comment_text().unwrap()); } +#[test] +fn test_doc_comment_preserves_newlines() { + let file = SourceFile::parse( + r#" + /// this + /// is + /// mod + /// foo + mod foo {} + "#, + ) + .ok() + .unwrap(); + let module = file.syntax().descendants().find_map(Module::cast).unwrap(); + assert_eq!("this\nis\nmod\nfoo", module.doc_comment_text().unwrap()); +} + #[test] fn test_where_predicates() { fn assert_bound(text: &str, bound: Option) { -- cgit v1.2.3