diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-31 15:48:42 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-31 15:48:42 +0100 |
commit | 7c0a9718aab7a26d7570879e6bd5fcd7cca83ded (patch) | |
tree | 65b1055e81b9c789785e69e49ac21616b820fa1c /crates | |
parent | 4a6cfa1aa7ece5a32176548ce3a8e3605cdb8072 (diff) | |
parent | 4fccad9b2cea8b17066308129c9add49861f8e07 (diff) |
Merge #1629
1629: Add explicit newline preserving tests r=matklad a=kjeremy
I didn't see anything that explicitly called this out so added tests.
Co-authored-by: kjeremy <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_lsp_server/src/markdown.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 17 |
2 files changed, 23 insertions, 0 deletions
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 { | |||
48 | let comment = " # stay1\n# stay2\n#stay3\nstay4\n#\n #\n # \n #\tstay5\n\t#\t"; | 48 | let comment = " # stay1\n# stay2\n#stay3\nstay4\n#\n #\n # \n #\tstay5\n\t#\t"; |
49 | assert_eq!(format_docs(comment), comment); | 49 | assert_eq!(format_docs(comment), comment); |
50 | } | 50 | } |
51 | |||
52 | #[test] | ||
53 | fn test_format_docs_preserves_newlines() { | ||
54 | let comment = "this\nis\nultiline"; | ||
55 | assert_eq!(format_docs(comment), comment); | ||
56 | } | ||
51 | } | 57 | } |
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 | |||
@@ -122,6 +122,23 @@ fn test_doc_comment_preserves_indents() { | |||
122 | } | 122 | } |
123 | 123 | ||
124 | #[test] | 124 | #[test] |
125 | fn test_doc_comment_preserves_newlines() { | ||
126 | let file = SourceFile::parse( | ||
127 | r#" | ||
128 | /// this | ||
129 | /// is | ||
130 | /// mod | ||
131 | /// foo | ||
132 | mod foo {} | ||
133 | "#, | ||
134 | ) | ||
135 | .ok() | ||
136 | .unwrap(); | ||
137 | let module = file.syntax().descendants().find_map(Module::cast).unwrap(); | ||
138 | assert_eq!("this\nis\nmod\nfoo", module.doc_comment_text().unwrap()); | ||
139 | } | ||
140 | |||
141 | #[test] | ||
125 | fn test_where_predicates() { | 142 | fn test_where_predicates() { |
126 | fn assert_bound(text: &str, bound: Option<TypeBound>) { | 143 | fn assert_bound(text: &str, bound: Option<TypeBound>) { |
127 | assert_eq!(text, bound.unwrap().syntax().text().to_string()); | 144 | assert_eq!(text, bound.unwrap().syntax().text().to_string()); |