Skip to content

Commit c3a1696

Browse files
committed
Fix unicode test to use original error format
1 parent 23b7184 commit c3a1696

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/test/run-make/unicode-input/span_length.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ fn main() {
6565

6666
let err = String::from_utf8_lossy(&result.stderr);
6767

68-
// the span should end the line (e.g no extra ^'s)
69-
let expected_span = format!("^{}\n", repeat("^").take(n - 1)
68+
// the span should end the line (e.g no extra ~'s)
69+
let expected_span = format!("^{}\n", repeat("~").take(n - 1)
7070
.collect::<String>());
7171
assert!(err.contains(&expected_span));
7272
}
@@ -91,19 +91,17 @@ fn main() {
9191

9292
// Test both the length of the snake and the leading spaces up to it
9393

94-
// First snake is 9 ^s long.
95-
let expected_1 = r#"
96-
1 |> extern "路濫狼á́́" fn foo() {} extern "路濫狼á́" fn bar() {}
97-
|> ^^^^^^^^^
98-
"#;
99-
assert!(err.contains(&expected_1));
100-
101-
// Second snake is only 8 ^s long, because rustc counts chars()
102-
// now rather than width(). This is because width() functions are
103-
// to be removed from librustc_unicode
104-
let expected_2 = r#"
105-
1 |> extern "路濫狼á́́" fn foo() {} extern "路濫狼á́" fn bar() {}
106-
|> ^^^^^^^^
107-
"#;
108-
assert!(err.contains(&expected_2));
94+
// First snake is 8 ~s long, with 7 preceding spaces (excluding file name/line offset)
95+
let expected_span = format!("\n{}^{}\n",
96+
repeat(" ").take(offset + 7).collect::<String>(),
97+
repeat("~").take(8).collect::<String>());
98+
assert!(err.contains(&expected_span));
99+
// Second snake is only 7 ~s long, with 36 preceding spaces,
100+
// because rustc counts chars() now rather than width(). This
101+
// is because width() functions are to be removed from
102+
// librustc_unicode
103+
let expected_span = format!("\n{}^{}\n",
104+
repeat(" ").take(offset + 36).collect::<String>(),
105+
repeat("~").take(7).collect::<String>());
106+
assert!(err.contains(&expected_span));
109107
}

0 commit comments

Comments
 (0)