about summary refs log tree commit diff
path: root/tests/coverage/unicode.rs
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2023-12-15 22:41:01 +1100
committerZalathar <Zalathar@users.noreply.github.com>2024-01-08 21:43:22 +1100
commit585a28561996be51739e9a0523371e6e0339cb56 (patch)
treef85a2c9433da1f6b3d8cf8778127823c4da52911 /tests/coverage/unicode.rs
parent0ee9cfd54db7b5f4be35f026588904500c866196 (diff)
downloadrust-585a28561996be51739e9a0523371e6e0339cb56.tar.gz
rust-585a28561996be51739e9a0523371e6e0339cb56.zip
coverage: Test for column numbers involving non-ASCII characters
Diffstat (limited to 'tests/coverage/unicode.rs')
-rw-r--r--tests/coverage/unicode.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/coverage/unicode.rs b/tests/coverage/unicode.rs
new file mode 100644
index 00000000000..3335d3af458
--- /dev/null
+++ b/tests/coverage/unicode.rs
@@ -0,0 +1,36 @@
+// edition: 2021
+// ignore-mode-coverage-run - `llvm-cov` fails due to incorrectly-split UTF-8
+// llvm-cov-flags: --use-color
+
+// Check that column numbers are denoted in bytes, so that they don't cause
+// `llvm-cov` to fail or emit malformed output.
+//
+// Note that when `llvm-cov` prints ^ arrows on a subsequent line, it simply
+// inserts one space character for each "column", with no understanding of
+// Unicode or character widths. So those arrows will tend to be misaligned
+// for non-ASCII source code, regardless of whether column numbers are code
+// points or bytes.
+
+fn main() {
+    for _İ in 'А'..='Я' { /* Я */ }
+
+    if 申し訳ございません() && 申し訳ございません() {
+        println!("true");
+    }
+
+    サビ();
+}
+
+fn 申し訳ございません() -> bool {
+    std::hint::black_box(false)
+}
+
+macro_rules! macro_that_defines_a_function {
+    (fn $名:ident () $体:tt) => {
+        fn $名 () $体 fn 他 () {}
+    }
+}
+
+macro_that_defines_a_function! {
+    fn サビ() {}
+}