Skip to content

Commit

Permalink
Update tests/rustdoc to new test syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jun 24, 2024
1 parent d3ec92e commit 1b67035
Show file tree
Hide file tree
Showing 627 changed files with 4,378 additions and 4,378 deletions.
12 changes: 6 additions & 6 deletions tests/rustdoc/alias-reexport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

extern crate alias_reexport2;

// @has 'foo/reexport/fn.foo.html'
// @has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported'
// @has 'foo/reexport/fn.foo2.html'
// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>'
// @has 'foo/reexport/type.Reexported.html'
// @has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;'
//@ has 'foo/reexport/fn.foo.html'
//@ has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported'
//@ has 'foo/reexport/fn.foo2.html'
//@ has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>'
//@ has 'foo/reexport/type.Reexported.html'
//@ has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;'
#[doc(inline)]
pub use alias_reexport2 as reexport;
8 changes: 4 additions & 4 deletions tests/rustdoc/alias-reexport2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ extern crate alias_reexport;

use alias_reexport::Reexported;

// @has 'foo/fn.foo.html'
// @has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported'
//@ has 'foo/fn.foo.html'
//@ has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported'
pub fn foo() -> Reexported { 0 }
// @has 'foo/fn.foo2.html'
// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>'
//@ has 'foo/fn.foo2.html'
//@ has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result<Reexported, ()>'
pub fn foo2() -> Result<Reexported, ()> { Ok(0) }
16 changes: 8 additions & 8 deletions tests/rustdoc/all.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#![crate_name = "foo"]

// @has foo/all.html '//a[@href="struct.Struct.html"]' 'Struct'
// @has foo/all.html '//a[@href="enum.Enum.html"]' 'Enum'
// @has foo/all.html '//a[@href="union.Union.html"]' 'Union'
// @has foo/all.html '//a[@href="constant.CONST.html"]' 'CONST'
// @has foo/all.html '//a[@href="static.STATIC.html"]' 'STATIC'
// @has foo/all.html '//a[@href="fn.function.html"]' 'function'
//@ has foo/all.html '//a[@href="struct.Struct.html"]' 'Struct'
//@ has foo/all.html '//a[@href="enum.Enum.html"]' 'Enum'
//@ has foo/all.html '//a[@href="union.Union.html"]' 'Union'
//@ has foo/all.html '//a[@href="constant.CONST.html"]' 'CONST'
//@ has foo/all.html '//a[@href="static.STATIC.html"]' 'STATIC'
//@ has foo/all.html '//a[@href="fn.function.html"]' 'function'

pub struct Struct;
pub enum Enum {
Expand All @@ -23,6 +23,6 @@ mod private_module {
pub struct ReexportedStruct;
}

// @has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct'
// @!hasraw foo/all.html 'private_module'
//@ has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct'
//@ !hasraw foo/all.html 'private_module'
pub use private_module::ReexportedStruct;
20 changes: 10 additions & 10 deletions tests/rustdoc/anchor-id-duplicate-method-name-25001.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// https://github.com/rust-lang/rust/issues/25001
#![crate_name="issue_25001"]

// @has issue_25001/struct.Foo.html
//@ has issue_25001/struct.Foo.html
pub struct Foo<T>(T);

pub trait Bar {
Expand All @@ -11,36 +11,36 @@ pub trait Bar {
}

impl Foo<u8> {
// @has - '//*[@id="method.pass"]//h4[@class="code-header"]' 'fn pass()'
//@ has - '//*[@id="method.pass"]//h4[@class="code-header"]' 'fn pass()'
pub fn pass() {}
}
impl Foo<u16> {
// @has - '//*[@id="method.pass-1"]//h4[@class="code-header"]' 'fn pass() -> usize'
//@ has - '//*[@id="method.pass-1"]//h4[@class="code-header"]' 'fn pass() -> usize'
pub fn pass() -> usize { 42 }
}
impl Foo<u32> {
// @has - '//*[@id="method.pass-2"]//h4[@class="code-header"]' 'fn pass() -> isize'
//@ has - '//*[@id="method.pass-2"]//h4[@class="code-header"]' 'fn pass() -> isize'
pub fn pass() -> isize { 42 }
}

impl<T> Bar for Foo<T> {
// @has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' 'type Item = T'
//@ has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' 'type Item = T'
type Item=T;

// @has - '//*[@id="method.quux"]//h4[@class="code-header"]' 'fn quux(self)'
//@ has - '//*[@id="method.quux"]//h4[@class="code-header"]' 'fn quux(self)'
fn quux(self) {}
}
impl<'a, T> Bar for &'a Foo<T> {
// @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item = &'a T"
//@ has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item = &'a T"
type Item=&'a T;

// @has - '//*[@id="method.quux-1"]//h4[@class="code-header"]' 'fn quux(self)'
//@ has - '//*[@id="method.quux-1"]//h4[@class="code-header"]' 'fn quux(self)'
fn quux(self) {}
}
impl<'a, T> Bar for &'a mut Foo<T> {
// @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item = &'a mut T"
//@ has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item = &'a mut T"
type Item=&'a mut T;

// @has - '//*[@id="method.quux-2"]//h4[@class="code-header"]' 'fn quux(self)'
//@ has - '//*[@id="method.quux-2"]//h4[@class="code-header"]' 'fn quux(self)'
fn quux(self) {}
}
2 changes: 1 addition & 1 deletion tests/rustdoc/anchor-id-trait-method-15169.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq'
//@ has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq'

// https://github.com/rust-lang/rust/issues/15169
#![crate_name="issue_15169"]
Expand Down
26 changes: 13 additions & 13 deletions tests/rustdoc/anchor-id-trait-tymethod-28478.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@

#![feature(associated_type_defaults)]

// @has issue_28478/trait.Bar.html
//@ has issue_28478/trait.Bar.html
pub trait Bar {
// @has - '//*[@id="associatedtype.Bar"]' 'type Bar = ()'
// @has - '//*[@href="#associatedtype.Bar"]' 'Bar'
//@ has - '//*[@id="associatedtype.Bar"]' 'type Bar = ()'
//@ has - '//*[@href="#associatedtype.Bar"]' 'Bar'
type Bar = ();
// @has - '//*[@id="associatedconstant.Baz"]' 'const Baz: usize'
// @has - '//*[@href="#associatedconstant.Baz"]' 'Baz'
//@ has - '//*[@id="associatedconstant.Baz"]' 'const Baz: usize'
//@ has - '//*[@href="#associatedconstant.Baz"]' 'Baz'
const Baz: usize = 7;
// @has - '//*[@id="tymethod.bar"]' 'fn bar'
//@ has - '//*[@id="tymethod.bar"]' 'fn bar'
fn bar();
// @has - '//*[@id="method.baz"]' 'fn baz'
//@ has - '//*[@id="method.baz"]' 'fn baz'
fn baz() { }
}

// @has issue_28478/struct.Foo.html
//@ has issue_28478/struct.Foo.html
pub struct Foo;

impl Foo {
// @has - '//*[@href="#method.foo"]' 'foo'
//@ has - '//*[@href="#method.foo"]' 'foo'
pub fn foo() {}
}

impl Bar for Foo {
// @has - '//*[@href="trait.Bar.html#associatedtype.Bar"]' 'Bar'
// @has - '//*[@href="trait.Bar.html#associatedconstant.Baz"]' 'Baz'
// @has - '//*[@href="trait.Bar.html#tymethod.bar"]' 'bar'
//@ has - '//*[@href="trait.Bar.html#associatedtype.Bar"]' 'Bar'
//@ has - '//*[@href="trait.Bar.html#associatedconstant.Baz"]' 'Baz'
//@ has - '//*[@href="trait.Bar.html#tymethod.bar"]' 'bar'
fn bar() {}
// @has - '//*[@href="trait.Bar.html#method.baz"]' 'baz'
//@ has - '//*[@href="trait.Bar.html#method.baz"]' 'baz'
}
26 changes: 13 additions & 13 deletions tests/rustdoc/anchors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,44 @@

pub struct Foo;

// @has 'foo/trait.Bar.html'
//@ has 'foo/trait.Bar.html'
pub trait Bar {
// There should be no anchors here.
// @snapshot no_type_anchor - '//*[@id="associatedtype.T"]'
//@ snapshot no_type_anchor - '//*[@id="associatedtype.T"]'
type T;
// There should be no anchors here.
// @snapshot no_const_anchor - '//*[@id="associatedconstant.YOLO"]'
//@ snapshot no_const_anchor - '//*[@id="associatedconstant.YOLO"]'
const YOLO: u32;

// There should be no anchors here.
// @snapshot no_tymethod_anchor - '//*[@id="tymethod.foo"]'
//@ snapshot no_tymethod_anchor - '//*[@id="tymethod.foo"]'
fn foo();
// There should be no anchors here.
// @snapshot no_trait_method_anchor - '//*[@id="method.bar"]'
//@ snapshot no_trait_method_anchor - '//*[@id="method.bar"]'
fn bar() {}
}

// @has 'foo/struct.Foo.html'
//@ has 'foo/struct.Foo.html'
impl Bar for Foo {
// @has - '//*[@id="associatedtype.T"]/a[@class="anchor"]' ''
//@ has - '//*[@id="associatedtype.T"]/a[@class="anchor"]' ''
type T = u32;
// @has - '//*[@id="associatedconstant.YOLO"]/a[@class="anchor"]' ''
//@ has - '//*[@id="associatedconstant.YOLO"]/a[@class="anchor"]' ''
const YOLO: u32 = 0;

// @has - '//*[@id="method.foo"]/a[@class="anchor"]' ''
//@ has - '//*[@id="method.foo"]/a[@class="anchor"]' ''
fn foo() {}
// Same check for provided "bar" method.
// @has - '//*[@id="method.bar"]/a[@class="anchor"]' ''
//@ has - '//*[@id="method.bar"]/a[@class="anchor"]' ''
}

impl Foo {
// @snapshot no_const_anchor2 - '//*[@id="associatedconstant.X"]'
//@ snapshot no_const_anchor2 - '//*[@id="associatedconstant.X"]'
// There should be no anchors here.
pub const X: i32 = 0;
// @snapshot no_type_anchor2 - '//*[@id="associatedtype.Y"]'
//@ snapshot no_type_anchor2 - '//*[@id="associatedtype.Y"]'
// There should be no anchors here.
pub type Y = u32;
// @snapshot no_method_anchor - '//*[@id="method.new"]'
//@ snapshot no_method_anchor - '//*[@id="method.new"]'
// There should be no anchors here.
pub fn new() -> Self { Self }
}
4 changes: 2 additions & 2 deletions tests/rustdoc/anonymous-lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub trait Stream {
fn size_hint(&self) -> (usize, Option<usize>);
}

// @has 'foo/trait.Stream.html'
// @has - '//*[@class="code-header"]' 'impl<S: ?Sized + Stream + Unpin> Stream for &mut S'
//@ has 'foo/trait.Stream.html'
//@ has - '//*[@class="code-header"]' 'impl<S: ?Sized + Stream + Unpin> Stream for &mut S'
impl<S: ?Sized + Stream + Unpin> Stream for &mut S {
type Item = S::Item;

Expand Down
14 changes: 7 additions & 7 deletions tests/rustdoc/anonymous-reexport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

// This test ensures we don't display anonymous (non-inline) re-exports of public items.

// @has 'foo/index.html'
// @has - '//*[@id="main-content"]' ''
//@ has 'foo/index.html'
//@ has - '//*[@id="main-content"]' ''
// We check that the only "h2" present are "Structs" (for "Bla") and "Re-exports".
// @count - '//*[@id="main-content"]/h2' 2
// @has - '//*[@id="main-content"]/h2' 'Structs'
// @has - '//*[@id="main-content"]/h2' 'Re-exports'
//@ count - '//*[@id="main-content"]/h2' 2
//@ has - '//*[@id="main-content"]/h2' 'Structs'
//@ has - '//*[@id="main-content"]/h2' 'Re-exports'
// The 3 re-exports.
// @count - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 3
//@ count - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 3
// The public struct.
// @count - '//*[@id="main-content"]//a[@class="struct"]' 1
//@ count - '//*[@id="main-content"]//a[@class="struct"]' 1

mod ext {
pub trait Foo {}
Expand Down
16 changes: 8 additions & 8 deletions tests/rustdoc/array-links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@

pub struct MyBox<T: ?Sized>(*const T);

// @has 'foo/fn.alpha.html'
// @snapshot link_slice_u32 - '//pre[@class="rust item-decl"]/code'
//@ has 'foo/fn.alpha.html'
//@ snapshot link_slice_u32 - '//pre[@class="rust item-decl"]/code'
pub fn alpha() -> &'static [u32; 1] {
loop {}
}

// @has 'foo/fn.beta.html'
// @snapshot link_slice_generic - '//pre[@class="rust item-decl"]/code'
//@ has 'foo/fn.beta.html'
//@ snapshot link_slice_generic - '//pre[@class="rust item-decl"]/code'
pub fn beta<T>() -> &'static [T; 1] {
loop {}
}

// @has 'foo/fn.gamma.html'
// @snapshot link_box_u32 - '//pre[@class="rust item-decl"]/code'
//@ has 'foo/fn.gamma.html'
//@ snapshot link_box_u32 - '//pre[@class="rust item-decl"]/code'
pub fn gamma() -> MyBox<[u32; 1]> {
loop {}
}

// @has 'foo/fn.delta.html'
// @snapshot link_box_generic - '//pre[@class="rust item-decl"]/code'
//@ has 'foo/fn.delta.html'
//@ snapshot link_box_generic - '//pre[@class="rust item-decl"]/code'
pub fn delta<T>() -> MyBox<[T; 1]> {
loop {}
}
4 changes: 2 additions & 2 deletions tests/rustdoc/asm-foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::arch::asm;

// @has asm_foreign/fn.aarch64.html
//@ has asm_foreign/fn.aarch64.html
pub unsafe fn aarch64(a: f64, b: f64) -> f64 {
let c;
asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
Expand All @@ -12,7 +12,7 @@ pub unsafe fn aarch64(a: f64, b: f64) -> f64 {
c
}

// @has asm_foreign/fn.x86.html
//@ has asm_foreign/fn.x86.html
pub unsafe fn x86(a: f64, b: f64) -> f64 {
let c;
asm!("addsd {}, {}, xmm0", out(xmm_reg) c, in(xmm_reg) a, in("xmm0") b);
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc/asm-foreign2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::arch::asm;

// @has asm_foreign2/fn.x86.html
//@ has asm_foreign2/fn.x86.html
pub unsafe fn x86(x: i64) -> i64 {
let y;
asm!("movq {}, {}", in(reg) x, out(reg) y, options(att_syntax));
Expand Down
4 changes: 2 additions & 2 deletions tests/rustdoc/asref-for-and-of-local-82465.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
use std::convert::AsRef;
pub struct Local;

// @has foo/struct.Local.html '//h3[@class="code-header"]' 'impl AsRef<str> for Local'
//@ has foo/struct.Local.html '//h3[@class="code-header"]' 'impl AsRef<str> for Local'
impl AsRef<str> for Local {
fn as_ref(&self) -> &str {
todo!()
}
}

// @has - '//h3[@class="code-header"]' 'impl AsRef<Local> for str'
//@ has - '//h3[@class="code-header"]' 'impl AsRef<Local> for str'
impl AsRef<Local> for str {
fn as_ref(&self) -> &Local {
todo!()
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc/assoc-consts-version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
pub struct SomeStruct;

impl SomeStruct {
// @has 'foo/struct.SomeStruct.html' \
//@ has 'foo/struct.SomeStruct.html' \
// '//*[@id="associatedconstant.SOME_CONST"]//span[@class="since"]' '1.1.2'
#[stable(since="1.1.2", feature="rust2")]
pub const SOME_CONST: usize = 0;
Expand Down
Loading

0 comments on commit 1b67035

Please sign in to comment.