Skip to content

Commit 4fa1c2b

Browse files
committed
test: Cleanup trim tests
1 parent fd61af9 commit 4fa1c2b

File tree

1 file changed

+28
-52
lines changed

1 file changed

+28
-52
lines changed

tests/formatter.rs

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,7 +2937,7 @@ error: title
29372937
assert_data_eq!(renderer.render(input), expected_ascii);
29382938

29392939
let expected_unicode = str![[r#"
2940-
error: title
2940+
error: titlecompiler/rustc_errors
29412941
╭▸
29422942
1 │ version = "0.1.0"
29432943
2 │ # Ensure that the spans from toml handle utf-8 correctly
@@ -2952,111 +2952,87 @@ error: title
29522952
}
29532953

29542954
#[test]
2955-
fn unicode_cut_handling2() {
2955+
fn trim_unicode_annotate_ascii_end_with_label() {
29562956
let source = "/*这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。*/?";
2957-
let input = &[Level::ERROR
2958-
.primary_title("expected item, found `?`").element(
2959-
Snippet::source(source)
2960-
.fold(false)
2961-
.annotation(AnnotationKind::Primary.span(499..500).label("expected item"))
2962-
).element(
2963-
Level::NOTE.message("for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>")
2964-
2965-
)];
2957+
let input = &[Group::with_level(Level::ERROR).element(
2958+
Snippet::source(source).annotation(
2959+
AnnotationKind::Primary
2960+
.span(499..500)
2961+
.label("expected item"),
2962+
),
2963+
)];
29662964

29672965
let expected_ascii = str![[r#"
2968-
error: expected item, found `?`
29692966
|
29702967
1 | ... 的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。*/?
29712968
| ^ expected item
2972-
|
2973-
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
29742969
"#]];
29752970

29762971
let renderer = Renderer::plain();
29772972
assert_data_eq!(renderer.render(input), expected_ascii);
29782973

29792974
let expected_unicode = str![[r#"
2980-
error: expected item, found `?`
29812975
╭▸
29822976
1 │ … 宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。*/?
2983-
│ ━ expected item
2984-
2985-
╰ note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
2977+
╰╴ ━ expected item
29862978
"#]];
29872979
let renderer = renderer.decor_style(DecorStyle::Unicode);
29882980
assert_data_eq!(renderer.render(input), expected_unicode);
29892981
}
29902982

29912983
#[test]
2992-
fn unicode_cut_handling3() {
2984+
fn trim_unicode_annotate_unicode_middle_with_label() {
29932985
let source = "/*这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。*/?";
2994-
let input = &[Level::ERROR
2995-
.primary_title("expected item, found `?`").element(
2996-
Snippet::source(source)
2997-
.fold(false)
2998-
.annotation(AnnotationKind::Primary.span(251..254).label("expected item"))
2999-
).element(
3000-
Level::NOTE.message("for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>")
3001-
3002-
)];
2986+
let input = &[Group::with_level(Level::ERROR).element(
2987+
Snippet::source(source).annotation(
2988+
AnnotationKind::Primary
2989+
.span(251..254)
2990+
.label("expected item"),
2991+
),
2992+
)];
30032993

30042994
let expected_ascii = str![[r#"
3005-
error: expected item, found `?`
30062995
|
30072996
1 | ... 。这是宽的。这是宽的。这是宽的...
30082997
| ^^ expected item
3009-
|
3010-
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
30112998
"#]];
30122999

30133000
let renderer = Renderer::plain().term_width(43);
30143001
assert_data_eq!(renderer.render(input), expected_ascii);
30153002

30163003
let expected_unicode = str![[r#"
3017-
error: expected item, found `?`
30183004
╭▸
30193005
1 │ … 的。这是宽的。这是宽的。这是宽的。…
3020-
│ ━━ expected item
3021-
3022-
╰ note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
3006+
╰╴ ━━ expected item
30233007
"#]];
30243008
let renderer = renderer.decor_style(DecorStyle::Unicode);
30253009
assert_data_eq!(renderer.render(input), expected_unicode);
30263010
}
30273011

30283012
#[test]
3029-
fn unicode_cut_handling4() {
3013+
fn trim_ascii_annotate_ascii_end_with_label() {
30303014
let source = "/*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/?";
3031-
let input = &[Level::ERROR
3032-
.primary_title("expected item, found `?`").element(
3033-
Snippet::source(source)
3034-
.fold(false)
3035-
.annotation(AnnotationKind::Primary.span(334..335).label("expected item"))
3036-
).element(
3037-
Level::NOTE.message("for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>")
3038-
3039-
)];
3015+
let input = &[Group::with_level(Level::ERROR).element(
3016+
Snippet::source(source).annotation(
3017+
AnnotationKind::Primary
3018+
.span(334..335)
3019+
.label("expected item"),
3020+
),
3021+
)];
30403022

30413023
let expected_ascii = str![[r#"
3042-
error: expected item, found `?`
30433024
|
30443025
1 | ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/?
30453026
| ^ expected item
3046-
|
3047-
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
30483027
"#]];
30493028

30503029
let renderer = Renderer::plain();
30513030
assert_data_eq!(renderer.render(input), expected_ascii);
30523031

30533032
let expected_unicode = str![[r#"
3054-
error: expected item, found `?`
30553033
╭▸
30563034
1 │ …aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/?
3057-
│ ━ expected item
3058-
3059-
╰ note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
3035+
╰╴ ━ expected item
30603036
"#]];
30613037
let renderer = renderer.decor_style(DecorStyle::Unicode);
30623038
assert_data_eq!(renderer.render(input), expected_unicode);

0 commit comments

Comments
 (0)