|
1 | | -use rustc_span::{Symbol, sym}; |
| 1 | +use rustc_span::{Symbol, create_default_session_globals_then, sym}; |
2 | 2 |
|
3 | 3 | use crate::html::format::href_relative_parts; |
4 | 4 |
|
5 | | -fn assert_relative_path(expected: &[Symbol], relative_to_fqp: &[Symbol], fqp: &[Symbol]) { |
6 | | - // No `create_default_session_globals_then` call is needed here because all |
7 | | - // the symbols used are static, and no `Symbol::intern` calls occur. |
8 | | - assert_eq!(expected, href_relative_parts(&fqp, &relative_to_fqp).collect::<Vec<_>>()); |
| 5 | +fn assert_relative_path(expected: &str, relative_to_fqp: &[Symbol], fqp: &[Symbol]) { |
| 6 | + create_default_session_globals_then(|| { |
| 7 | + assert_eq!(expected, href_relative_parts(&fqp, &relative_to_fqp).finish()); |
| 8 | + }); |
9 | 9 | } |
10 | 10 |
|
11 | 11 | #[test] |
12 | 12 | fn href_relative_parts_basic() { |
13 | 13 | let relative_to_fqp = &[sym::std, sym::vec]; |
14 | 14 | let fqp = &[sym::std, sym::iter]; |
15 | | - assert_relative_path(&[sym::dotdot, sym::iter], relative_to_fqp, fqp); |
| 15 | + assert_relative_path("../iter", relative_to_fqp, fqp); |
16 | 16 | } |
17 | 17 |
|
18 | 18 | #[test] |
19 | 19 | fn href_relative_parts_parent_module() { |
20 | 20 | let relative_to_fqp = &[sym::std, sym::vec]; |
21 | 21 | let fqp = &[sym::std]; |
22 | | - assert_relative_path(&[sym::dotdot], relative_to_fqp, fqp); |
| 22 | + assert_relative_path("..", relative_to_fqp, fqp); |
23 | 23 | } |
24 | 24 |
|
25 | 25 | #[test] |
26 | 26 | fn href_relative_parts_different_crate() { |
27 | 27 | let relative_to_fqp = &[sym::std, sym::vec]; |
28 | 28 | let fqp = &[sym::core, sym::iter]; |
29 | | - assert_relative_path(&[sym::dotdot, sym::dotdot, sym::core, sym::iter], relative_to_fqp, fqp); |
| 29 | + assert_relative_path("../../core/iter", relative_to_fqp, fqp); |
30 | 30 | } |
31 | 31 |
|
32 | 32 | #[test] |
33 | 33 | fn href_relative_parts_same_module() { |
34 | 34 | let relative_to_fqp = &[sym::std, sym::vec]; |
35 | 35 | let fqp = &[sym::std, sym::vec]; |
36 | | - assert_relative_path(&[], relative_to_fqp, fqp); |
| 36 | + assert_relative_path("", relative_to_fqp, fqp); |
37 | 37 | } |
38 | 38 |
|
39 | 39 | #[test] |
40 | 40 | fn href_relative_parts_child_module() { |
41 | 41 | let relative_to_fqp = &[sym::std]; |
42 | 42 | let fqp = &[sym::std, sym::vec]; |
43 | | - assert_relative_path(&[sym::vec], relative_to_fqp, fqp); |
| 43 | + assert_relative_path("vec", relative_to_fqp, fqp); |
44 | 44 | } |
45 | 45 |
|
46 | 46 | #[test] |
47 | 47 | fn href_relative_parts_root() { |
48 | 48 | let relative_to_fqp = &[]; |
49 | 49 | let fqp = &[sym::std]; |
50 | | - assert_relative_path(&[sym::std], relative_to_fqp, fqp); |
| 50 | + assert_relative_path("std", relative_to_fqp, fqp); |
51 | 51 | } |
0 commit comments