Skip to content

Commit 9855a38

Browse files
Add tests for new toggle on deref blocks
1 parent a868b3f commit 9855a38

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/rustdoc-gui/deref-block.goml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// This test ensures that several clickable items actually have the pointer cursor.
2+
go-to: "file://" + |DOC_PATH| + "/lib2/struct.Derefer.html"
3+
4+
assert-text: (".big-toggle summary", "Methods from Deref<Target = str>§")
5+
// We ensure it doesn't go over `§`.
6+
assert-css: (".big-toggle summary::before", {
7+
"left": "-34px",
8+
"top": "9px",
9+
})
10+
// It should NOT have the same X or Y position as the other toggles.
11+
compare-elements-position-false: (
12+
".big-toggle summary::before",
13+
".method-toggle summary::before",
14+
["x", "y"],
15+
)
16+
17+
// We now check that if we're in mobile mode, it gets back to its original X position.
18+
set-window-size: (600, 600)
19+
assert-css: (".big-toggle summary::before", {
20+
"left": "-11px",
21+
"top": "9px",
22+
})
23+
// It should have the same X position as the other toggles.
24+
compare-elements-position: (".big-toggle summary::before", ".method-toggle summary::before", ["x"])
25+
// But still shouldn't have the same Y position.
26+
compare-elements-position-false: (
27+
".big-toggle summary::before",
28+
".method-toggle summary::before",
29+
["y"],
30+
)

tests/rustdoc-gui/src/lib2/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,13 @@ pub mod scroll_traits {
355355
fn this_is_a_method_with_a_long_name_returning_something() -> String;
356356
}
357357
}
358+
359+
pub struct Derefer(String);
360+
361+
impl std::ops::Deref for Derefer {
362+
type Target = str;
363+
364+
fn deref(&self) -> &Self::Target {
365+
&self.0
366+
}
367+
}

0 commit comments

Comments
 (0)