Skip to content

Commit b8b0800

Browse files
committed
coverage: Test for column numbers involving non-ASCII characters
1 parent 8e34642 commit b8b0800

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

tests/coverage/unicode.cov-map

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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, 0c, 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 + 12, 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, 1c, 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 + 28, 18) to (start + 0, 20)
37+
38+
Function name: unicode::申し訳ございません
39+
Raw bytes (9): 0x[01, 01, 00, 01, 01, 16, 01, 02, 02]
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(Counter(0)) at (prev + 22, 1) to (start + 2, 2)
45+

tests/coverage/unicode.coverage

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

tests/coverage/unicode.rs

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

0 commit comments

Comments
 (0)