From 4f64ff171bdd00873d6cdf8301f5cdddf999832f Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 23 Nov 2023 14:56:03 -0700 Subject: rustdoc: move doctest tests to folder --- tests/rustdoc/doctest-cfg-feature-30252.rs | 9 -- tests/rustdoc/doctest-crate-attributes-38129.rs | 99 ---------------------- tests/rustdoc/doctest-hide-empty-line-23106.rs | 10 --- tests/rustdoc/doctest-ignore-32556.rs | 8 -- tests/rustdoc/doctest-include-43153.rs | 12 --- tests/rustdoc/doctest-macro-38219.rs | 10 --- tests/rustdoc/doctest-manual-crate-name.rs | 7 -- .../rustdoc/doctest-markdown-inline-parse-23744.rs | 15 ---- .../doctest-markdown-trailing-docblock-48377.rs | 15 ---- .../doctest-multi-line-string-literal-25944.rs | 14 --- tests/rustdoc/doctest/auxiliary/empty.rs | 1 + tests/rustdoc/doctest/doctest-cfg-feature-30252.rs | 9 ++ .../doctest/doctest-crate-attributes-38129.rs | 99 ++++++++++++++++++++++ .../doctest/doctest-hide-empty-line-23106.rs | 10 +++ tests/rustdoc/doctest/doctest-ignore-32556.rs | 8 ++ tests/rustdoc/doctest/doctest-include-43153.rs | 12 +++ tests/rustdoc/doctest/doctest-macro-38219.rs | 10 +++ tests/rustdoc/doctest/doctest-manual-crate-name.rs | 7 ++ .../doctest/doctest-markdown-inline-parse-23744.rs | 15 ++++ .../doctest-markdown-trailing-docblock-48377.rs | 15 ++++ .../doctest-multi-line-string-literal-25944.rs | 14 +++ 21 files changed, 200 insertions(+), 199 deletions(-) delete mode 100644 tests/rustdoc/doctest-cfg-feature-30252.rs delete mode 100644 tests/rustdoc/doctest-crate-attributes-38129.rs delete mode 100644 tests/rustdoc/doctest-hide-empty-line-23106.rs delete mode 100644 tests/rustdoc/doctest-ignore-32556.rs delete mode 100644 tests/rustdoc/doctest-include-43153.rs delete mode 100644 tests/rustdoc/doctest-macro-38219.rs delete mode 100644 tests/rustdoc/doctest-manual-crate-name.rs delete mode 100644 tests/rustdoc/doctest-markdown-inline-parse-23744.rs delete mode 100644 tests/rustdoc/doctest-markdown-trailing-docblock-48377.rs delete mode 100644 tests/rustdoc/doctest-multi-line-string-literal-25944.rs create mode 100644 tests/rustdoc/doctest/auxiliary/empty.rs create mode 100644 tests/rustdoc/doctest/doctest-cfg-feature-30252.rs create mode 100644 tests/rustdoc/doctest/doctest-crate-attributes-38129.rs create mode 100644 tests/rustdoc/doctest/doctest-hide-empty-line-23106.rs create mode 100644 tests/rustdoc/doctest/doctest-ignore-32556.rs create mode 100644 tests/rustdoc/doctest/doctest-include-43153.rs create mode 100644 tests/rustdoc/doctest/doctest-macro-38219.rs create mode 100644 tests/rustdoc/doctest/doctest-manual-crate-name.rs create mode 100644 tests/rustdoc/doctest/doctest-markdown-inline-parse-23744.rs create mode 100644 tests/rustdoc/doctest/doctest-markdown-trailing-docblock-48377.rs create mode 100644 tests/rustdoc/doctest/doctest-multi-line-string-literal-25944.rs diff --git a/tests/rustdoc/doctest-cfg-feature-30252.rs b/tests/rustdoc/doctest-cfg-feature-30252.rs deleted file mode 100644 index ceb8076fe35..00000000000 --- a/tests/rustdoc/doctest-cfg-feature-30252.rs +++ /dev/null @@ -1,9 +0,0 @@ -// compile-flags:--test --cfg feature="bar" - -// https://github.com/rust-lang/rust/issues/30252 -#![crate_name="issue_30252"] - -/// ```rust -/// assert_eq!(cfg!(feature = "bar"), true); -/// ``` -pub fn foo() {} diff --git a/tests/rustdoc/doctest-crate-attributes-38129.rs b/tests/rustdoc/doctest-crate-attributes-38129.rs deleted file mode 100644 index 156d50fa52a..00000000000 --- a/tests/rustdoc/doctest-crate-attributes-38129.rs +++ /dev/null @@ -1,99 +0,0 @@ -// compile-flags:--test - -// This file tests the source-partitioning behavior of rustdoc. -// Each test contains some code that should be put into the generated -// `fn main` and some attributes should be left outside (except the first -// one, which has no attributes). -// If the #![recursion_limit] attribute is incorrectly left inside, -// then the tests will fail because the macro recurses 128 times. - -/// ``` -/// assert_eq!(1 + 1, 2); -/// ``` -pub fn simple() {} - -/// ``` -/// #![recursion_limit = "1024"] -/// macro_rules! recurse { -/// (()) => {}; -/// (() $($rest:tt)*) => { recurse!($($rest)*); } -/// } -/// recurse!(() () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () ()); -/// assert_eq!(1 + 1, 2); -/// ``` -pub fn non_feature_attr() {} - -/// ``` -/// #![feature(core_intrinsics)] -/// assert_eq!(1 + 1, 2); -/// ``` -pub fn feature_attr() {} - -/// ``` -/// #![feature(core_intrinsics)] -/// #![recursion_limit = "1024"] -/// macro_rules! recurse { -/// (()) => {}; -/// (() $($rest:tt)*) => { recurse!($($rest)*); } -/// } -/// recurse!(() () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () ()); -/// assert_eq!(1 + 1, 2); -/// ``` -pub fn both_attrs() {} - -/// ``` -/// #![recursion_limit = "1024"] -/// #![feature(core_intrinsics)] -/// macro_rules! recurse { -/// (()) => {}; -/// (() $($rest:tt)*) => { recurse!($($rest)*); } -/// } -/// recurse!(() () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () () -/// () () () () () () () ()); -/// assert_eq!(1 + 1, 2); -/// ``` -pub fn both_attrs_reverse() {} diff --git a/tests/rustdoc/doctest-hide-empty-line-23106.rs b/tests/rustdoc/doctest-hide-empty-line-23106.rs deleted file mode 100644 index 8e1e2cf098c..00000000000 --- a/tests/rustdoc/doctest-hide-empty-line-23106.rs +++ /dev/null @@ -1,10 +0,0 @@ -// compile-flags:--test - -// https://github.com/rust-lang/rust/issues/23106 -#![crate_name="issue_23106"] - -/// ``` -/// # -/// ``` -pub fn main() { -} diff --git a/tests/rustdoc/doctest-ignore-32556.rs b/tests/rustdoc/doctest-ignore-32556.rs deleted file mode 100644 index 99da9358bd6..00000000000 --- a/tests/rustdoc/doctest-ignore-32556.rs +++ /dev/null @@ -1,8 +0,0 @@ -// https://github.com/rust-lang/rust/issues/32556 -#![crate_name="issue_32556"] - -/// Blah blah blah -/// ```ignore (testing rustdoc's handling of ignore) -/// bad_assert!(); -/// ``` -pub fn foo() {} diff --git a/tests/rustdoc/doctest-include-43153.rs b/tests/rustdoc/doctest-include-43153.rs deleted file mode 100644 index ec21a68c4ee..00000000000 --- a/tests/rustdoc/doctest-include-43153.rs +++ /dev/null @@ -1,12 +0,0 @@ -// https://github.com/rust-lang/rust/issues/43153 - -// Test that `include!` in a doc test searches relative to the directory in -// which the test is declared. - -// compile-flags:--test - -/// ```rust -/// include!("auxiliary/empty.rs"); -/// fn main() {} -/// ``` -pub struct Foo; diff --git a/tests/rustdoc/doctest-macro-38219.rs b/tests/rustdoc/doctest-macro-38219.rs deleted file mode 100644 index 6c81df11085..00000000000 --- a/tests/rustdoc/doctest-macro-38219.rs +++ /dev/null @@ -1,10 +0,0 @@ -// https://github.com/rust-lang/rust/issues/38219 - -// compile-flags:--test -// should-fail - -/// ``` -/// fail -/// ``` -#[macro_export] -macro_rules! foo { () => {} } diff --git a/tests/rustdoc/doctest-manual-crate-name.rs b/tests/rustdoc/doctest-manual-crate-name.rs deleted file mode 100644 index 3a5e3734e14..00000000000 --- a/tests/rustdoc/doctest-manual-crate-name.rs +++ /dev/null @@ -1,7 +0,0 @@ -// compile-flags:--test - -//! ``` -//! #![crate_name="asdf"] -//! -//! println!("yo"); -//! ``` diff --git a/tests/rustdoc/doctest-markdown-inline-parse-23744.rs b/tests/rustdoc/doctest-markdown-inline-parse-23744.rs deleted file mode 100644 index 128e2daba07..00000000000 --- a/tests/rustdoc/doctest-markdown-inline-parse-23744.rs +++ /dev/null @@ -1,15 +0,0 @@ -// compile-flags:--test - -// https://github.com/rust-lang/rust/issues/23744 -#![crate_name="issue_23744"] - -/// Example of rustdoc incorrectly parsing ```rust,should_panic. -/// -/// ```should_panic -/// fn main() { panic!("fee"); } -/// ``` -/// -/// ```rust,should_panic -/// fn main() { panic!("fum"); } -/// ``` -pub fn foo() {} diff --git a/tests/rustdoc/doctest-markdown-trailing-docblock-48377.rs b/tests/rustdoc/doctest-markdown-trailing-docblock-48377.rs deleted file mode 100644 index d481dc0dd70..00000000000 --- a/tests/rustdoc/doctest-markdown-trailing-docblock-48377.rs +++ /dev/null @@ -1,15 +0,0 @@ -// compile-flags:--test - -// https://github.com/rust-lang/rust/issues/48377 - -//! This is a doc comment -//! -//! ```rust -//! fn main() {} -//! ``` -//! -//! With a trailing code fence -//! ``` - -/// Some foo function -pub fn foo() {} diff --git a/tests/rustdoc/doctest-multi-line-string-literal-25944.rs b/tests/rustdoc/doctest-multi-line-string-literal-25944.rs deleted file mode 100644 index eec796e4fbf..00000000000 --- a/tests/rustdoc/doctest-multi-line-string-literal-25944.rs +++ /dev/null @@ -1,14 +0,0 @@ -// compile-flags:--test - -// https://github.com/rust-lang/rust/issues/25944 -#![crate_name="issue_25944"] - -/// ``` -/// let a = r#" -/// foo -/// bar"#; -/// let b = "\nfoo\nbar"; -/// assert_eq!(a, b); -/// ``` -pub fn main() { -} diff --git a/tests/rustdoc/doctest/auxiliary/empty.rs b/tests/rustdoc/doctest/auxiliary/empty.rs new file mode 100644 index 00000000000..d11c69f812a --- /dev/null +++ b/tests/rustdoc/doctest/auxiliary/empty.rs @@ -0,0 +1 @@ +// intentionally empty diff --git a/tests/rustdoc/doctest/doctest-cfg-feature-30252.rs b/tests/rustdoc/doctest/doctest-cfg-feature-30252.rs new file mode 100644 index 00000000000..ceb8076fe35 --- /dev/null +++ b/tests/rustdoc/doctest/doctest-cfg-feature-30252.rs @@ -0,0 +1,9 @@ +// compile-flags:--test --cfg feature="bar" + +// https://github.com/rust-lang/rust/issues/30252 +#![crate_name="issue_30252"] + +/// ```rust +/// assert_eq!(cfg!(feature = "bar"), true); +/// ``` +pub fn foo() {} diff --git a/tests/rustdoc/doctest/doctest-crate-attributes-38129.rs b/tests/rustdoc/doctest/doctest-crate-attributes-38129.rs new file mode 100644 index 00000000000..156d50fa52a --- /dev/null +++ b/tests/rustdoc/doctest/doctest-crate-attributes-38129.rs @@ -0,0 +1,99 @@ +// compile-flags:--test + +// This file tests the source-partitioning behavior of rustdoc. +// Each test contains some code that should be put into the generated +// `fn main` and some attributes should be left outside (except the first +// one, which has no attributes). +// If the #![recursion_limit] attribute is incorrectly left inside, +// then the tests will fail because the macro recurses 128 times. + +/// ``` +/// assert_eq!(1 + 1, 2); +/// ``` +pub fn simple() {} + +/// ``` +/// #![recursion_limit = "1024"] +/// macro_rules! recurse { +/// (()) => {}; +/// (() $($rest:tt)*) => { recurse!($($rest)*); } +/// } +/// recurse!(() () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () ()); +/// assert_eq!(1 + 1, 2); +/// ``` +pub fn non_feature_attr() {} + +/// ``` +/// #![feature(core_intrinsics)] +/// assert_eq!(1 + 1, 2); +/// ``` +pub fn feature_attr() {} + +/// ``` +/// #![feature(core_intrinsics)] +/// #![recursion_limit = "1024"] +/// macro_rules! recurse { +/// (()) => {}; +/// (() $($rest:tt)*) => { recurse!($($rest)*); } +/// } +/// recurse!(() () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () ()); +/// assert_eq!(1 + 1, 2); +/// ``` +pub fn both_attrs() {} + +/// ``` +/// #![recursion_limit = "1024"] +/// #![feature(core_intrinsics)] +/// macro_rules! recurse { +/// (()) => {}; +/// (() $($rest:tt)*) => { recurse!($($rest)*); } +/// } +/// recurse!(() () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () () +/// () () () () () () () ()); +/// assert_eq!(1 + 1, 2); +/// ``` +pub fn both_attrs_reverse() {} diff --git a/tests/rustdoc/doctest/doctest-hide-empty-line-23106.rs b/tests/rustdoc/doctest/doctest-hide-empty-line-23106.rs new file mode 100644 index 00000000000..8e1e2cf098c --- /dev/null +++ b/tests/rustdoc/doctest/doctest-hide-empty-line-23106.rs @@ -0,0 +1,10 @@ +// compile-flags:--test + +// https://github.com/rust-lang/rust/issues/23106 +#![crate_name="issue_23106"] + +/// ``` +/// # +/// ``` +pub fn main() { +} diff --git a/tests/rustdoc/doctest/doctest-ignore-32556.rs b/tests/rustdoc/doctest/doctest-ignore-32556.rs new file mode 100644 index 00000000000..99da9358bd6 --- /dev/null +++ b/tests/rustdoc/doctest/doctest-ignore-32556.rs @@ -0,0 +1,8 @@ +// https://github.com/rust-lang/rust/issues/32556 +#![crate_name="issue_32556"] + +/// Blah blah blah +/// ```ignore (testing rustdoc's handling of ignore) +/// bad_assert!(); +/// ``` +pub fn foo() {} diff --git a/tests/rustdoc/doctest/doctest-include-43153.rs b/tests/rustdoc/doctest/doctest-include-43153.rs new file mode 100644 index 00000000000..ec21a68c4ee --- /dev/null +++ b/tests/rustdoc/doctest/doctest-include-43153.rs @@ -0,0 +1,12 @@ +// https://github.com/rust-lang/rust/issues/43153 + +// Test that `include!` in a doc test searches relative to the directory in +// which the test is declared. + +// compile-flags:--test + +/// ```rust +/// include!("auxiliary/empty.rs"); +/// fn main() {} +/// ``` +pub struct Foo; diff --git a/tests/rustdoc/doctest/doctest-macro-38219.rs b/tests/rustdoc/doctest/doctest-macro-38219.rs new file mode 100644 index 00000000000..6c81df11085 --- /dev/null +++ b/tests/rustdoc/doctest/doctest-macro-38219.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/38219 + +// compile-flags:--test +// should-fail + +/// ``` +/// fail +/// ``` +#[macro_export] +macro_rules! foo { () => {} } diff --git a/tests/rustdoc/doctest/doctest-manual-crate-name.rs b/tests/rustdoc/doctest/doctest-manual-crate-name.rs new file mode 100644 index 00000000000..3a5e3734e14 --- /dev/null +++ b/tests/rustdoc/doctest/doctest-manual-crate-name.rs @@ -0,0 +1,7 @@ +// compile-flags:--test + +//! ``` +//! #![crate_name="asdf"] +//! +//! println!("yo"); +//! ``` diff --git a/tests/rustdoc/doctest/doctest-markdown-inline-parse-23744.rs b/tests/rustdoc/doctest/doctest-markdown-inline-parse-23744.rs new file mode 100644 index 00000000000..128e2daba07 --- /dev/null +++ b/tests/rustdoc/doctest/doctest-markdown-inline-parse-23744.rs @@ -0,0 +1,15 @@ +// compile-flags:--test + +// https://github.com/rust-lang/rust/issues/23744 +#![crate_name="issue_23744"] + +/// Example of rustdoc incorrectly parsing ```rust,should_panic. +/// +/// ```should_panic +/// fn main() { panic!("fee"); } +/// ``` +/// +/// ```rust,should_panic +/// fn main() { panic!("fum"); } +/// ``` +pub fn foo() {} diff --git a/tests/rustdoc/doctest/doctest-markdown-trailing-docblock-48377.rs b/tests/rustdoc/doctest/doctest-markdown-trailing-docblock-48377.rs new file mode 100644 index 00000000000..d481dc0dd70 --- /dev/null +++ b/tests/rustdoc/doctest/doctest-markdown-trailing-docblock-48377.rs @@ -0,0 +1,15 @@ +// compile-flags:--test + +// https://github.com/rust-lang/rust/issues/48377 + +//! This is a doc comment +//! +//! ```rust +//! fn main() {} +//! ``` +//! +//! With a trailing code fence +//! ``` + +/// Some foo function +pub fn foo() {} diff --git a/tests/rustdoc/doctest/doctest-multi-line-string-literal-25944.rs b/tests/rustdoc/doctest/doctest-multi-line-string-literal-25944.rs new file mode 100644 index 00000000000..eec796e4fbf --- /dev/null +++ b/tests/rustdoc/doctest/doctest-multi-line-string-literal-25944.rs @@ -0,0 +1,14 @@ +// compile-flags:--test + +// https://github.com/rust-lang/rust/issues/25944 +#![crate_name="issue_25944"] + +/// ``` +/// let a = r#" +/// foo +/// bar"#; +/// let b = "\nfoo\nbar"; +/// assert_eq!(a, b); +/// ``` +pub fn main() { +} -- cgit 1.4.1-3-g733a5