Skip to content

Commit b052cd6

Browse files
committed
coverage: Test for column numbers involving non-ASCII characters
1 parent 595bc6f commit b052cd6

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

tests/coverage/unicode.cov-map

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Function name: unicode::main
2+
Raw bytes (67): 0x[01, 01, 09, 01, 05, 03, 05, 1e, 0d, 22, 09, 03, 05, 11, 1b, 1e, 0d, 22, 09, 03, 05, 09, 01, 0e, 01, 00, 0b, 05, 01, 09, 00, 0b, 03, 00, 0f, 00, 18, 05, 00, 19, 00, 24, 22, 02, 08, 00, 13, 09, 00, 17, 00, 22, 11, 00, 23, 02, 06, 1b, 02, 06, 00, 07, 17, 02, 05, 01, 02]
3+
Number of files: 1
4+
- file 0 => global file 1
5+
Number of expressions: 9
6+
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
7+
- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(1)
8+
- expression 2 operands: lhs = Expression(7, Sub), rhs = Counter(3)
9+
- expression 3 operands: lhs = Expression(8, Sub), rhs = Counter(2)
10+
- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(1)
11+
- expression 5 operands: lhs = Counter(4), rhs = Expression(6, Add)
12+
- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(3)
13+
- expression 7 operands: lhs = Expression(8, Sub), rhs = Counter(2)
14+
- expression 8 operands: lhs = Expression(0, Add), rhs = Counter(1)
15+
Number of file 0 mappings: 9
16+
- Code(Counter(0)) at (prev + 14, 1) to (start + 0, 11)
17+
- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 11)
18+
- Code(Expression(0, Add)) at (prev + 0, 15) to (start + 0, 24)
19+
= (c0 + c1)
20+
- Code(Counter(1)) at (prev + 0, 25) to (start + 0, 36)
21+
- Code(Expression(8, Sub)) at (prev + 2, 8) to (start + 0, 19)
22+
= ((c0 + c1) - c1)
23+
- Code(Counter(2)) at (prev + 0, 23) to (start + 0, 34)
24+
- Code(Counter(4)) at (prev + 0, 35) to (start + 2, 6)
25+
- Code(Expression(6, Add)) at (prev + 2, 6) to (start + 0, 7)
26+
= ((((c0 + c1) - c1) - c2) + c3)
27+
- Code(Expression(5, Add)) at (prev + 2, 5) to (start + 1, 2)
28+
= (c4 + ((((c0 + c1) - c1) - c2) + c3))
29+
30+
Function name: unicode::サビ
31+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 1e, 12, 00, 14]
32+
Number of files: 1
33+
- file 0 => global file 1
34+
Number of expressions: 0
35+
Number of file 0 mappings: 1
36+
- Code(Counter(0)) at (prev + 30, 18) to (start + 0, 20)
37+
38+
Function name: unicode::他 (unused)
39+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 1e, 15, 00, 1f]
40+
Number of files: 1
41+
- file 0 => global file 1
42+
Number of expressions: 0
43+
Number of file 0 mappings: 1
44+
- Code(Zero) at (prev + 30, 21) to (start + 0, 31)
45+
46+
Function name: unicode::申し訳ございません
47+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 18, 01, 02, 02]
48+
Number of files: 1
49+
- file 0 => global file 1
50+
Number of expressions: 0
51+
Number of file 0 mappings: 1
52+
- Code(Counter(0)) at (prev + 24, 1) to (start + 2, 2)
53+

tests/coverage/unicode.rs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// edition: 2021
2+
// ignore-mode-coverage-run - `llvm-cov` fails due to incorrectly-split UTF-8
3+
// llvm-cov-flags: --use-color
4+
5+
// Check that column numbers are denoted in bytes, so that they don't cause
6+
// `llvm-cov` to fail or emit malformed output.
7+
//
8+
// Note that when `llvm-cov` prints ^ arrows on a subsequent line, it simply
9+
// inserts one space character for each "column", with no understanding of
10+
// Unicode or character widths. So those arrows will tend to be misaligned
11+
// for non-ASCII source code, regardless of whether column numbers are code
12+
// points or bytes.
13+
14+
fn main() {
15+
forin 'А'..='Я' { /* Я */ }
16+
17+
if 申し訳ございません() && 申し訳ございません() {
18+
println!("true");
19+
}
20+
21+
サビ();
22+
}
23+
24+
fn 申し訳ございません() -> bool {
25+
std::hint::black_box(false)
26+
}
27+
28+
macro_rules! macro_that_defines_a_function {
29+
(fn $名:ident () $体:tt) => {
30+
fn $名 () $体 fn() {}
31+
}
32+
}
33+
34+
macro_that_defines_a_function! {
35+
fn サビ() {}
36+
}

0 commit comments

Comments
 (0)