Skip to content

Commit

Permalink
Fix unicode test to use original error format
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiajt committed Apr 30, 2016
1 parent 23b7184 commit c3a1696
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/test/run-make/unicode-input/span_length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ fn main() {

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

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

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

// First snake is 9 ^s long.
let expected_1 = r#"
1 |> extern "路濫狼á́́" fn foo() {} extern "路濫狼á́" fn bar() {}
|> ^^^^^^^^^
"#;
assert!(err.contains(&expected_1));

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

0 comments on commit c3a1696

Please sign in to comment.