2020-04-19 18:40:53 -05:00
|
|
|
// check-pass
|
2019-07-02 13:30:54 -05:00
|
|
|
// compile-flags:--test --test-args --test-threads=1
|
2023-04-29 04:08:33 -05:00
|
|
|
// normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
|
2020-11-26 14:15:15 -06:00
|
|
|
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
|
2019-04-24 15:26:42 -05:00
|
|
|
|
2019-05-25 18:11:30 -05:00
|
|
|
// Crates like core have doctests gated on `cfg(not(test))` so we need to make
|
|
|
|
// sure `cfg(test)` is not active when running `rustdoc --test`.
|
|
|
|
|
2019-04-24 15:26:42 -05:00
|
|
|
/// this doctest will be ignored:
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// assert!(false);
|
|
|
|
/// ```
|
2019-05-25 18:11:30 -05:00
|
|
|
#[cfg(test)]
|
2019-04-24 15:26:42 -05:00
|
|
|
pub struct Foo;
|
|
|
|
|
|
|
|
/// this doctest will be tested:
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// assert!(true);
|
|
|
|
/// ```
|
2019-05-25 18:11:30 -05:00
|
|
|
#[cfg(not(test))]
|
2019-04-24 15:26:42 -05:00
|
|
|
pub struct Foo;
|
2019-06-28 10:31:27 -05:00
|
|
|
|
|
|
|
/// this doctest will be tested, but will not appear in documentation:
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// assert!(true)
|
|
|
|
/// ```
|
|
|
|
#[cfg(doctest)]
|
|
|
|
pub struct Bar;
|