Update rustdoc tests

This commit is contained in:
Guillaume Gomez 2022-07-05 15:10:12 +02:00
parent 499e024ac9
commit 05e69d8fc6
10 changed files with 34 additions and 23 deletions

View File

@ -16,8 +16,16 @@ assert-attribute: ("#implementors-list .impl:nth-child(2) > a.anchor", {"href":
assert: "#implementors-list .impl:nth-child(2) > .code-header.in-band"
goto: file://|DOC_PATH|/test_docs/struct.HasEmptyTraits.html
compare-elements-position-near-false: ("#impl-EmptyTrait1", "#impl-EmptyTrait2", {"y": 30})
compare-elements-position-near: ("#impl-EmptyTrait3 h3", "#impl-EmptyTrait3 .item-info", {"y": 30})
compare-elements-position-near-false: (
"#impl-EmptyTrait1-for-HasEmptyTraits",
"#impl-EmptyTrait2-for-HasEmptyTraits",
{"y": 30},
)
compare-elements-position-near: (
"#impl-EmptyTrait3-for-HasEmptyTraits h3",
"#impl-EmptyTrait3-for-HasEmptyTraits .item-info",
{"y": 30},
)
// Now check that re-exports work correctly.
// There should be exactly one impl shown on both of these pages.

View File

@ -15,14 +15,17 @@ assert-text: (
// Checking the "item-info" on an impl block as well:
goto: file://|DOC_PATH|/lib2/struct.LongItemInfo2.html
compare-elements-property: (
"#impl-SimpleTrait .item-info",
"#impl-SimpleTrait + .docblock",
"#impl-SimpleTrait-for-LongItemInfo2 .item-info",
"#impl-SimpleTrait-for-LongItemInfo2 + .docblock",
["scrollWidth"],
)
assert-property: ("#impl-SimpleTrait .item-info", {"scrollWidth": "866"})
assert-property: (
"#impl-SimpleTrait-for-LongItemInfo2 .item-info",
{"scrollWidth": "866"},
)
// Just to be sure we're comparing the correct "item-info":
assert-text: (
"#impl-SimpleTrait .item-info",
"#impl-SimpleTrait-for-LongItemInfo2 .item-info",
"Available on Android or Linux or Emscripten or DragonFly BSD",
STARTS_WITH,
)

View File

@ -1,8 +1,8 @@
#![crate_name = "foo"]
// @has 'foo/struct.Foo.html'
// @has - '//*[@id="impl-Send"]' 'impl !Send for Foo'
// @has - '//*[@id="impl-Sync"]' 'impl !Sync for Foo'
// @has - '//*[@id="impl-Send-for-Foo"]' 'impl !Send for Foo'
// @has - '//*[@id="impl-Sync-for-Foo"]' 'impl !Sync for Foo'
pub struct Foo(*const i8);
pub trait Whatever: Send {}
impl<T: Send + ?Sized> Whatever for T {}

View File

@ -1,6 +1,5 @@
#![crate_name = "foo"]
pub trait Foo<T> {
fn foo() {}
}
@ -8,5 +7,5 @@ fn foo() {}
pub struct Bar;
// @has foo/struct.Bar.html
// @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo%3Cunsafe%20extern%20%22C%22%20fn()%3E"]' 'Foo<unsafe extern "C" fn()>'
// @has - '//*[@class="sidebar-elems"]//section//a[@href="#impl-Foo%3Cunsafe%20extern%20%22C%22%20fn()%3E-for-Bar"]' 'Foo<unsafe extern "C" fn()>'
impl Foo<unsafe extern "C" fn()> for Bar {}

View File

@ -2,12 +2,12 @@
use std::fmt;
// @!has foo/struct.Bar.html '//*[@id="impl-ToString-for-Bar"]//h3[@class="code-header in-band"]' 'impl<T> ToString for T'
// @!has foo/struct.Bar.html '//*[@id="impl-ToString-for-Bar"]' ''
pub struct Bar;
// @has foo/struct.Foo.html '//*[@id="impl-ToString-for-Foo"]//h3[@class="code-header in-band"]' 'impl<T> ToString for T'
pub struct Foo;
// @has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString"]' 'ToString'
// @has foo/struct.Foo.html '//*[@class="sidebar-elems"]//section//a[@href="#impl-ToString-for-Foo"]' 'ToString'
impl fmt::Display for Foo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@ -5,7 +5,7 @@
pub struct MyType;
// @has 'impl_box/struct.MyType.html'
// @has '-' '//*[@id="impl-Iterator"]' 'impl Iterator for Box<MyType>'
// @has '-' '//*[@id="impl-Iterator-for-Box%3CMyType%3E"]' 'impl Iterator for Box<MyType>'
impl Iterator for Box<MyType> {
type Item = ();

View File

@ -13,5 +13,5 @@
// @!has foo/trait.Deref.html '//*[@id="impl-Deref-for-EndianSlice"]//h3[@class="code-header in-band"]' 'impl Deref for EndianSlice'
pub use realcore::Deref;
// @has foo/trait.Join.html '//*[@id="impl-Join"]//h3[@class="code-header in-band"]' 'impl Join for Foo'
// @has foo/trait.Join.html '//*[@id="impl-Join-for-Foo"]//h3[@class="code-header in-band"]' 'impl Join for Foo'
pub use realcore::Join;

View File

@ -5,8 +5,8 @@
// the ID is correctly derived.
// @has 'foo/struct.AnotherStruct.html'
// @count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait"]' 1
// @count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-1"]' 1
// @count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-AnotherStruct%3C()%3E"]' 1
// @count - '//*[@class="sidebar"]//a[@href="#impl-AnAmazingTrait-for-AnotherStruct%3CT%3E"]' 1
pub trait Something {}

View File

@ -29,10 +29,11 @@ fn a<A: ~const Clone + ~const Destruct>()
}
}
// @!has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]' '~const'
// @has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/a[@class="trait"]' 'Clone'
// @!has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/span[@class="where"]' '~const'
// @has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/span[@class="where fmt-newline"]' ': Clone'
// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]' ''
// @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header in-band"]' '~const'
// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header in-band"]/a[@class="trait"]' 'Clone'
// @!has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header in-band"]/span[@class="where"]' '~const'
// @has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header in-band"]/span[@class="where fmt-newline"]' ': Clone'
impl<T: ~const Clone + ~const Destruct> const Tr<T> for T
where
Option<T>: ~const Clone + ~const Destruct,

View File

@ -1,10 +1,10 @@
#![crate_name = "foo"]
// @has foo/struct.Unsized.html
// @has - '//div[@id="impl-Sized-for-Unsized"]/h3[@class="code-header in-band"]' 'impl !Sized for Unsized'
// @!has - '//*[@id="impl-Sized"]//a[@class="srclink"]' 'source'
// @has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header in-band"]' 'impl !Sized for Unsized'
// @!has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="srclink"]' 'source'
// @has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header in-band"]' 'impl Sync for Unsized'
// @!has - '//*[@id="impl-Sync"]//a[@class="srclink"]' 'source'
// @!has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="srclink"]' 'source'
// @has - '//*[@id="impl-Any-for-Unsized"]/h3[@class="code-header in-band"]' 'impl<T> Any for T'
// @has - '//*[@id="impl-Any-for-Unsized"]//a[@class="srclink"]' 'source'
pub struct Unsized {