提交 d7159bdb 编写于 作者: G Guillaume Gomez

Add tests for implementors associated types display

上级 eb913664
......@@ -3,14 +3,14 @@
goto: file://|DOC_PATH|/implementors/trait.Whatever.html
assert: "#implementors-list"
// There are supposed to be two implementors listed.
assert-count: ("#implementors-list > .impl", 2)
assert-count: ("#implementors-list .impl", 2)
// Now we check that both implementors have an anchor, an ID and a similar DOM.
assert: ("#implementors-list > .impl:nth-child(1) > a.anchor")
assert-attribute: ("#implementors-list > .impl:nth-child(1)", {"id": "impl-Whatever"})
assert-attribute: ("#implementors-list > .impl:nth-child(1) > a.anchor", {"href": "#impl-Whatever"})
assert: "#implementors-list > .impl:nth-child(1) > .code-header.in-band"
assert: ("#implementors-list .impl:nth-child(1) > a.anchor")
assert-attribute: ("#implementors-list .impl:nth-child(1)", {"id": "impl-Whatever"})
assert-attribute: ("#implementors-list .impl:nth-child(1) > a.anchor", {"href": "#impl-Whatever"})
assert: "#implementors-list .impl:nth-child(1) > .code-header.in-band"
assert: ("#implementors-list > .impl:nth-child(2) > a.anchor")
assert-attribute: ("#implementors-list > .impl:nth-child(2)", {"id": "impl-Whatever-1"})
assert-attribute: ("#implementors-list > .impl:nth-child(2) > a.anchor", {"href": "#impl-Whatever-1"})
assert: "#implementors-list > .impl:nth-child(2) > .code-header.in-band"
assert: ("#implementors-list .impl:nth-child(2) > a.anchor")
assert-attribute: ("#implementors-list .impl:nth-child(2)", {"id": "impl-Whatever-1"})
assert-attribute: ("#implementors-list .impl:nth-child(2) > a.anchor", {"href": "#impl-Whatever-1"})
assert: "#implementors-list .impl:nth-child(2) > .code-header.in-band"
pub trait Whatever {
type Foo;
fn method() {}
}
pub struct Struct;
impl Whatever for Struct {}
impl Whatever for Struct {
type Foo = u8;
}
......@@ -38,7 +38,9 @@ impl Trait for Foo {
}
impl implementors::Whatever for Foo {}
impl implementors::Whatever for Foo {
type Foo = u32;
}
pub mod sub_mod {
/// ```txt
......
// This test ensures two things:
//
// 1. The implementors toggle are not open by default.
// 2. The "auto-collapse-implementors" setting is working as expected.
goto: file://|DOC_PATH|/implementors/trait.Whatever.html
// First, checking that they are not open by default.
assert-attribute-false: ("#implementors-list > details", {"open": ""}, ALL)
// Second, checking "auto-collapse-implementors" setting.
local-storage: {"rustdoc-auto-collapse-implementors": false}
reload:
assert-attribute: ("#implementors-list > details", {"open": ""}, ALL)
pub trait MyTrait {
type Assoc;
const VALUE: u32;
const VALUE: u32 = 12;
fn trait_function(&self);
fn defaulted(&self) {}
fn defaulted_override(&self) {}
......@@ -38,9 +38,11 @@ fn defaulted_override(&self) {}
}
impl MyTrait for MyStruct {
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedtype.Assoc-3"]//a[@class="anchor"]/@href' #associatedtype.Assoc-3
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="type"]/@href' trait.MyTrait.html#associatedtype.Assoc
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedtype.Assoc"]//a[@class="anchor"]/@href' #associatedtype.Assoc
type Assoc = bool;
// @has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-3"]//a[@class="anchor"]/@href' #associatedconstant.VALUE-3
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedconstant.VALUE"]//a[@class="constant"]/@href' trait.MyTrait.html#associatedconstant.VALUE
// @has trait_impl_items_links_and_anchors/struct.MyStruct.html '//div[@id="associatedconstant.VALUE"]//a[@class="anchor"]/@href' #associatedconstant.VALUE
const VALUE: u32 = 20;
......@@ -55,3 +57,10 @@ fn defaulted_override(&self) {}
}
pub struct MyStruct;
// We check that associated items with default values aren't generated in the implementors list.
impl MyTrait for (u8, u8) {
// @!has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]'
type Assoc = bool;
fn trait_function(&self) {}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册