diff options
| author | P1start <rewi-github@whanau.org> | 2015-01-22 19:49:40 +1300 |
|---|---|---|
| committer | P1start <rewi-github@whanau.org> | 2015-02-04 00:56:51 +1300 |
| commit | d244f099116ce7628ed00f74bc2466de72268cf6 (patch) | |
| tree | 296d236b2ed0206ac96ff509fbbb807ba36f8d63 /src/test/run-make/unicode-input | |
| parent | 7858cb432d3f2efc0374424cb2b51518f697c172 (diff) | |
| download | rust-d244f099116ce7628ed00f74bc2466de72268cf6.tar.gz rust-d244f099116ce7628ed00f74bc2466de72268cf6.zip | |
Compute widths properly when displaying spans in error messages
Closes #8706.
Diffstat (limited to 'src/test/run-make/unicode-input')
| -rw-r--r-- | src/test/run-make/unicode-input/span_length.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/run-make/unicode-input/span_length.rs b/src/test/run-make/unicode-input/span_length.rs index 01e2c1f2973..9ee7516c7ba 100644 --- a/src/test/run-make/unicode-input/span_length.rs +++ b/src/test/run-make/unicode-input/span_length.rs @@ -65,4 +65,36 @@ fn main() { .collect::<String>()); assert!(err.contains(expected_span.as_slice())); } + + // Test multi-column characters and tabs + { + let _ = write!(&mut File::create(&main_file).unwrap(), + r#"extern "路濫狼á́́" fn foo() {{}} extern "路濫狼á́" fn bar() {{}}"#); + } + + // Extra characters. Every line is preceded by `filename:lineno <actual code>` + let offset = main_file.as_str().unwrap().len() + 3; + + let result = Command::new("sh") + .arg("-c") + .arg(format!("{} {}", + rustc, + main_file.as_str() + .unwrap()).as_slice()) + .output().unwrap(); + + let err = String::from_utf8_lossy(result.error.as_slice()); + + // Test both the length of the snake and the leading spaces up to it + + // 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.as_slice())); + // Second snake is 8 ~s long, with 36 preceding spaces + let expected_span = format!("\n{}^{}\n", + repeat(" ").take(offset + 36).collect::<String>(), + repeat("~").take(8).collect::<String>()); + assert!(err.contains(expected_span.as_slice())); } |
