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_syntax/src/ast.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'crates/ra_syntax') 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