diff options
| author | QuietMisdreavus <grey@quietmisdreavus.net> | 2019-02-21 16:02:56 -0600 |
|---|---|---|
| committer | QuietMisdreavus <grey@quietmisdreavus.net> | 2019-02-28 16:11:21 -0600 |
| commit | 63bdd29ef4e744d6cacc2373b3b317eeebdf2a07 (patch) | |
| tree | 30c74a89b6c0a815b0ebd9898276416671bfd59e | |
| parent | 3ce19b4a2c062a7a269bd2783a4a441d515b64c8 (diff) | |
| download | rust-63bdd29ef4e744d6cacc2373b3b317eeebdf2a07.tar.gz rust-63bdd29ef4e744d6cacc2373b3b317eeebdf2a07.zip | |
add tests for doc coverage
| -rw-r--r-- | src/test/rustdoc-ui/coverage/basic.rs | 50 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/basic.stdout | 15 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/empty.rs | 4 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/empty.stdout | 7 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/enums.rs | 22 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/enums.stdout | 10 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/exotic.rs | 15 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/exotic.stdout | 9 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/private.rs | 21 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/private.stdout | 10 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/statics-consts.rs | 23 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/statics-consts.stdout | 12 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/traits.rs | 37 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/coverage/traits.stdout | 16 |
14 files changed, 251 insertions, 0 deletions
diff --git a/src/test/rustdoc-ui/coverage/basic.rs b/src/test/rustdoc-ui/coverage/basic.rs new file mode 100644 index 00000000000..4247fdf9895 --- /dev/null +++ b/src/test/rustdoc-ui/coverage/basic.rs @@ -0,0 +1,50 @@ +// compile-flags:-Z unstable-options --show-coverage +// compile-pass + +#![feature(extern_types)] + +//! Make sure to have some docs on your crate root + +/// This struct is documented, but its fields are not. +/// +/// However, one field is private, so it shouldn't show in the total. +pub struct SomeStruct { + pub some_field: usize, + other_field: usize, +} + +impl SomeStruct { + /// Method with docs + pub fn this_fn(&self) {} + + // Method without docs + pub fn other_method(&self) {} +} + +// struct without docs +pub struct OtherStruct; + +// function with no docs +pub fn some_fn() {} + +/// Function with docs +pub fn other_fn() {} + +pub enum SomeEnum { + /// Some of these variants are documented... + VarOne, + /// ...but some of them are not. + VarTwo, + // (like this one) + VarThree, +} + +/// There's a macro here, too +#[macro_export] +macro_rules! some_macro { + () => {}; +} + +extern { + pub type ExternType; +} diff --git a/src/test/rustdoc-ui/coverage/basic.stdout b/src/test/rustdoc-ui/coverage/basic.stdout new file mode 100644 index 00000000000..089ab6017d1 --- /dev/null +++ b/src/test/rustdoc-ui/coverage/basic.stdout @@ -0,0 +1,15 @@ ++---------------------------+------------+------------+------------+ +| Item Type | Documented | Total | Percentage | ++---------------------------+------------+------------+------------+ +| Modules | 1 | 1 | 100.0% | +| Functions | 1 | 2 | 50.0% | +| Structs | 1 | 2 | 50.0% | +| Struct Fields | 0 | 1 | 0.0% | +| Enums | 0 | 1 | 0.0% | +| Enum Variants | 2 | 3 | 66.7% | +| Methods | 1 | 2 | 50.0% | +| Macros | 1 | 1 | 100.0% | +| Extern Types | 0 | 1 | 0.0% | ++---------------------------+------------+------------+------------+ +| Total | 7 | 14 | 50.0% | ++---------------------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/empty.rs b/src/test/rustdoc-ui/coverage/empty.rs new file mode 100644 index 00000000000..463617a1143 --- /dev/null +++ b/src/test/rustdoc-ui/coverage/empty.rs @@ -0,0 +1,4 @@ +// compile-flags:-Z unstable-options --show-coverage +// compile-pass + +// an empty crate still has one item to document: the crate root diff --git a/src/test/rustdoc-ui/coverage/empty.stdout b/src/test/rustdoc-ui/coverage/empty.stdout new file mode 100644 index 00000000000..df68205bbaa --- /dev/null +++ b/src/test/rustdoc-ui/coverage/empty.stdout @@ -0,0 +1,7 @@ ++---------------------------+------------+------------+------------+ +| Item Type | Documented | Total | Percentage | ++---------------------------+------------+------------+------------+ +| Modules | 0 | 1 | 0.0% | ++---------------------------+------------+------------+------------+ +| Total | 0 | 1 | 0.0% | ++---------------------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/enums.rs b/src/test/rustdoc-ui/coverage/enums.rs new file mode 100644 index 00000000000..5cd7f490d1a --- /dev/null +++ b/src/test/rustdoc-ui/coverage/enums.rs @@ -0,0 +1,22 @@ +// compile-flags:-Z unstable-options --show-coverage +// compile-pass + +//! (remember the crate root is still a module) + +/// so check out this enum here +pub enum ThisEnum { + /// this variant has some weird stuff going on + VarOne { + /// like, it has some named fields inside + field_one: usize, + // (these show up as struct fields) + field_two: usize, + }, + /// here's another variant for you + VarTwo(String), + // but not all of them need to be documented as thoroughly + VarThree, +} + +/// uninhabited enums? sure, let's throw one of those around +pub enum OtherEnum {} diff --git a/src/test/rustdoc-ui/coverage/enums.stdout b/src/test/rustdoc-ui/coverage/enums.stdout new file mode 100644 index 00000000000..651ea095310 --- /dev/null +++ b/src/test/rustdoc-ui/coverage/enums.stdout @@ -0,0 +1,10 @@ ++---------------------------+------------+------------+------------+ +| Item Type | Documented | Total | Percentage | ++---------------------------+------------+------------+------------+ +| Modules | 1 | 1 | 100.0% | +| Struct Fields | 1 | 2 | 50.0% | +| Enums | 2 | 2 | 100.0% | +| Enum Variants | 2 | 3 | 66.7% | ++---------------------------+------------+------------+------------+ +| Total | 6 | 8 | 75.0% | ++---------------------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/exotic.rs b/src/test/rustdoc-ui/coverage/exotic.rs new file mode 100644 index 00000000000..b4adf45b90b --- /dev/null +++ b/src/test/rustdoc-ui/coverage/exotic.rs @@ -0,0 +1,15 @@ +// compile-flags:-Z unstable-options --show-coverage +// compile-pass + +#![feature(doc_keyword)] + +//! the features only used in std also have entries in the table, so make sure those get pulled out +//! properly as well + +/// woo, check it out, we can write our own primitive docs lol +#[doc(primitive="unit")] +mod prim_unit {} + +/// keywords? sure, pile them on +#[doc(keyword="where")] +mod where_keyword {} diff --git a/src/test/rustdoc-ui/coverage/exotic.stdout b/src/test/rustdoc-ui/coverage/exotic.stdout new file mode 100644 index 00000000000..97eab50a55a --- /dev/null +++ b/src/test/rustdoc-ui/coverage/exotic.stdout @@ -0,0 +1,9 @@ ++---------------------------+------------+------------+------------+ +| Item Type | Documented | Total | Percentage | ++---------------------------+------------+------------+------------+ +| Modules | 1 | 1 | 100.0% | +| Primitives | 1 | 1 | 100.0% | +| Keywords | 1 | 1 | 100.0% | ++---------------------------+------------+------------+------------+ +| Total | 3 | 3 | 100.0% | ++---------------------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/private.rs b/src/test/rustdoc-ui/coverage/private.rs new file mode 100644 index 00000000000..9024185856d --- /dev/null +++ b/src/test/rustdoc-ui/coverage/private.rs @@ -0,0 +1,21 @@ +// compile-flags:-Z unstable-options --show-coverage --document-private-items +// compile-pass + +#![allow(unused)] + +//! when `--document-private-items` is passed, nothing is safe. everything must have docs or your +//! score will suffer the consequences + +mod this_mod { + fn private_fn() {} +} + +/// See, our public items have docs! +pub struct SomeStruct { + /// Look, all perfectly documented! + pub field: usize, + other: usize, +} + +/// Nothing shady going on here. Just a bunch of well-documented code. (cough) +pub fn public_fn() {} diff --git a/src/test/rustdoc-ui/coverage/private.stdout b/src/test/rustdoc-ui/coverage/private.stdout new file mode 100644 index 00000000000..f1a5461b836 --- /dev/null +++ b/src/test/rustdoc-ui/coverage/private.stdout @@ -0,0 +1,10 @@ ++---------------------------+------------+------------+------------+ +| Item Type | Documented | Total | Percentage | ++---------------------------+------------+------------+------------+ +| Modules | 1 | 2 | 50.0% | +| Functions | 1 | 2 | 50.0% | +| Structs | 1 | 1 | 100.0% | +| Struct Fields | 1 | 2 | 50.0% | ++---------------------------+------------+------------+------------+ +| Total | 4 | 7 | 57.1% | ++---------------------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/statics-consts.rs b/src/test/rustdoc-ui/coverage/statics-consts.rs new file mode 100644 index 00000000000..3c1dd35dfe1 --- /dev/null +++ b/src/test/rustdoc-ui/coverage/statics-consts.rs @@ -0,0 +1,23 @@ +// compile-flags:-Z unstable-options --show-coverage +// compile-pass + +//! gotta make sure we can count statics and consts correctly, too + +/// static like electricity, right? +pub static THIS_STATIC: usize = 0; + +/// (it's not electricity, is it) +pub const THIS_CONST: usize = 1; + +/// associated consts show up separately, but let's throw them in as well +pub trait SomeTrait { + /// just like that, yeah + const ASSOC_CONST: usize; +} + +pub struct SomeStruct; + +impl SomeStruct { + /// wait, structs can have them too, can't forget those + pub const ASSOC_CONST: usize = 100; +} diff --git a/src/test/rustdoc-ui/coverage/statics-consts.stdout b/src/test/rustdoc-ui/coverage/statics-consts.stdout new file mode 100644 index 00000000000..54516fe613f --- /dev/null +++ b/src/test/rustdoc-ui/coverage/statics-consts.stdout @@ -0,0 +1,12 @@ ++---------------------------+------------+------------+------------+ +| Item Type | Documented | Total | Percentage | ++---------------------------+------------+------------+------------+ +| Modules | 1 | 1 | 100.0% | +| Structs | 0 | 1 | 0.0% | +| Traits | 1 | 1 | 100.0% | +| Associated Constants | 2 | 2 | 100.0% | +| Statics | 1 | 1 | 100.0% | +| Constants | 1 | 1 | 100.0% | ++---------------------------+------------+------------+------------+ +| Total | 6 | 7 | 85.7% | ++---------------------------+------------+------------+------------+ diff --git a/src/test/rustdoc-ui/coverage/traits.rs b/src/test/rustdoc-ui/coverage/traits.rs new file mode 100644 index 00000000000..0a6defa17f8 --- /dev/null +++ b/src/test/rustdoc-ui/coverage/traits.rs @@ -0,0 +1,37 @@ +// compile-flags:-Z unstable-options --show-coverage +// compile-pass + +#![feature(trait_alias)] + +/// look at this trait right here +pub trait ThisTrait { + /// that's a trait all right + fn right_here(&self); + + /// even the provided functions show up as trait methods + fn aww_yeah(&self) {} + + /// gotta check those associated types, they're slippery + type SomeType; +} + +/// so what happens if we take some struct... +pub struct SomeStruct; + +/// ...and slap this trait on it? +impl ThisTrait for SomeStruct { + /// what we get is a perfect combo! + fn right_here(&self) {} + + type SomeType = String; +} + +/// but what about those aliases? i hear they're pretty exotic +pub trait MyAlias = ThisTrait + Send + Sync; + +// FIXME(58624): once rustdoc can process existential types, we need to make sure they're counted +// /// woah, getting all existential in here +// pub existential type ThisExists: ThisTrait; +// +// /// why don't we get a little more concrete +// pub fn defines() -> ThisExists { SomeStruct {} } diff --git a/src/test/rustdoc-ui/coverage/traits.stdout b/src/test/rustdoc-ui/coverage/traits.stdout new file mode 100644 index 00000000000..6f5db8729ef --- /dev/null +++ b/src/test/rustdoc-ui/coverage/traits.stdout @@ -0,0 +1,16 @@ ++---------------------------+------------+------------+------------+ +| Item Type | Documented | Total | Percentage | ++---------------------------+------------+------------+------------+ +| Modules | 0 | 1 | 0.0% | +| Structs | 1 | 1 | 100.0% | +| Traits | 1 | 1 | 100.0% | +| Trait Methods | 2 | 2 | 100.0% | +| Associated Types | 1 | 1 | 100.0% | +| Trait Aliases | 1 | 1 | 100.0% | ++---------------------------+------------+------------+------------+ +| Total (non trait impls) | 6 | 7 | 85.7% | ++---------------------------+------------+------------+------------+ +| Trait Impl Items | 2 | 3 | 66.7% | ++---------------------------+------------+------------+------------+ +| Total | 8 | 10 | 80.0% | ++---------------------------+------------+------------+------------+ |
