From fcee70f643d8a40fe82b784e50880d5f8af062c0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 29 Oct 2020 11:43:07 +0100 Subject: [PATCH] Update tests --- .../passes/unindent_comments/tests.rs | 7 +--- src/test/rustdoc/unindent.md | 1 + src/test/rustdoc/unindent.rs | 41 +++++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 src/test/rustdoc/unindent.md diff --git a/src/librustdoc/passes/unindent_comments/tests.rs b/src/librustdoc/passes/unindent_comments/tests.rs index 5c1307b6628..9dec71f7683 100644 --- a/src/librustdoc/passes/unindent_comments/tests.rs +++ b/src/librustdoc/passes/unindent_comments/tests.rs @@ -37,12 +37,7 @@ fn should_leave_multiple_indent_levels() { #[test] fn should_ignore_first_line_indent() { - // The first line of the first paragraph may not be indented as - // far due to the way the doc string was written: - // - // #[doc = "Start way over here - // and continue here"] - run_test("line1\n line2", "line1\nline2"); + run_test("line1\n line2", "line1\n line2"); } #[test] diff --git a/src/test/rustdoc/unindent.md b/src/test/rustdoc/unindent.md new file mode 100644 index 00000000000..8e4e7a25af8 --- /dev/null +++ b/src/test/rustdoc/unindent.md @@ -0,0 +1 @@ +Just some text. diff --git a/src/test/rustdoc/unindent.rs b/src/test/rustdoc/unindent.rs index 5e3d71ae7d0..d10e1ec89c5 100644 --- a/src/test/rustdoc/unindent.rs +++ b/src/test/rustdoc/unindent.rs @@ -1,3 +1,5 @@ +#![feature(external_doc)] + #![crate_name = "foo"] // @has foo/struct.Example.html @@ -21,3 +23,42 @@ pub struct Example; /// .build(); /// ``` pub struct F; + +// @has foo/struct.G.html +// @matches - '//pre[@class="rust rust-example-rendered"]' \ +// '(?m)let example = Example::new\(\)\n\.first\(\)\n \.another\(\)\n\.build\(\);\Z' +///```rust +///let example = Example::new() +///.first() +#[cfg_attr(not(feature = "one"), doc = " .another()")] +///.build(); +///``` +pub struct G; + +// @has foo/struct.H.html +// @has - '//div[@class="docblock"]/p' 'no whitespace lol' +///no whitespace +#[doc = " lol"] +pub struct H; + +// @has foo/struct.I.html +// @matches - '//pre[@class="rust rust-example-rendered"]' '(?m)4 whitespaces!\Z' +/// 4 whitespaces! +#[doc = "something"] +pub struct I; + +// @has foo/struct.J.html +// @matches - '//div[@class="docblock"]/p' '(?m)a\nno whitespace\nJust some text.\Z' +///a +///no whitespace +#[doc(include = "unindent.md")] +pub struct J; + +// @has foo/struct.K.html +// @matches - '//pre[@class="rust rust-example-rendered"]' '(?m)4 whitespaces!\Z' +///a +/// +/// 4 whitespaces! +/// +#[doc(include = "unindent.md")] +pub struct K;