Skip to content

Commit 9d022f2

Browse files
committed
rewrite span-length to include strings
It is way easier to copy-and-paste strings from the output than to figure out how to reproduce them from first principles.
1 parent 4714394 commit 9d022f2

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

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

Lines changed: 17 additions & 15 deletions
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,17 +91,19 @@ fn main() {
9191

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

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));
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));
107109
}

0 commit comments

Comments
 (0)