]> git.proxmox.com Git - rustc.git/blame - tests/run-coverage/issue-84561.coverage
New upstream version 1.74.1+dfsg1
[rustc.git] / tests / run-coverage / issue-84561.coverage
CommitLineData
add651ee
FG
1 LL| |// This demonstrated Issue #84561: function-like macros produce unintuitive coverage results.
2 LL| |
3 LL| |// failure-status: 101
4 LL| 21|#[derive(PartialEq, Eq)]
5 LL| |struct Foo(u32);
6 LL| 1|fn test3() {
7 LL| 1| let is_true = std::env::args().len() == 1;
8 LL| 1| let bar = Foo(1);
9 LL| 1| assert_eq!(bar, Foo(1));
10 LL| 1| let baz = Foo(0);
11 LL| 1| assert_ne!(baz, Foo(1));
12 LL| 1| println!("{:?}", Foo(1));
13 LL| 1| println!("{:?}", bar);
14 LL| 1| println!("{:?}", baz);
15 LL| 1|
16 LL| 1| assert_eq!(Foo(1), Foo(1));
17 LL| 1| assert_ne!(Foo(0), Foo(1));
18 LL| 1| assert_eq!(Foo(2), Foo(2));
19 LL| 1| let bar = Foo(0);
20 LL| 1| assert_ne!(bar, Foo(3));
21 LL| 1| assert_ne!(Foo(0), Foo(4));
22 LL| 1| assert_eq!(Foo(3), Foo(3), "with a message");
17df50a5 23 ^0
add651ee
FG
24 LL| 1| println!("{:?}", bar);
25 LL| 1| println!("{:?}", Foo(1));
26 LL| 1|
27 LL| 1| assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" });
c295e0f8 28 ^0 ^0 ^0
add651ee
FG
29 LL| 1| assert_ne!(
30 LL| | Foo(0)
31 LL| | ,
32 LL| | Foo(5)
33 LL| | ,
34 LL| 0| "{}"
35 LL| 0| ,
36 LL| 0| if
37 LL| 0| is_true
38 LL| | {
39 LL| 0| "true message"
40 LL| | } else {
41 LL| 0| "false message"
42 LL| | }
43 LL| | );
44 LL| |
45 LL| 1| let is_true = std::env::args().len() == 1;
46 LL| 1|
47 LL| 1| assert_eq!(
48 LL| 1| Foo(1),
49 LL| 1| Foo(1)
50 LL| 1| );
51 LL| 1| assert_ne!(
52 LL| 1| Foo(0),
53 LL| 1| Foo(1)
54 LL| 1| );
55 LL| 1| assert_eq!(
56 LL| 1| Foo(2),
57 LL| 1| Foo(2)
58 LL| 1| );
59 LL| 1| let bar = Foo(1);
60 LL| 1| assert_ne!(
61 LL| 1| bar,
62 LL| 1| Foo(3)
63 LL| 1| );
64 LL| 1| if is_true {
65 LL| 1| assert_ne!(
66 LL| 1| Foo(0),
67 LL| 1| Foo(4)
68 LL| 1| );
69 LL| | } else {
70 LL| 0| assert_eq!(
71 LL| 0| Foo(3),
72 LL| 0| Foo(3)
73 LL| 0| );
74 LL| | }
75 LL| 1| if is_true {
76 LL| 1| assert_ne!(
77 LL| | Foo(0),
78 LL| | Foo(4),
79 LL| 0| "with a message"
80 LL| | );
81 LL| | } else {
82 LL| 0| assert_eq!(
83 LL| | Foo(3),
84 LL| | Foo(3),
85 LL| 0| "with a message"
86 LL| | );
87 LL| | }
88 LL| 1| assert_ne!(
89 LL| 1| if is_true {
90 LL| 1| Foo(0)
91 LL| | } else {
92 LL| 0| Foo(1)
93 LL| | },
94 LL| | Foo(5)
95 LL| | );
96 LL| 1| assert_ne!(
97 LL| 1| Foo(5),
98 LL| 1| if is_true {
99 LL| 1| Foo(0)
100 LL| | } else {
101 LL| 0| Foo(1)
102 LL| | }
103 LL| | );
104 LL| 1| assert_ne!(
105 LL| 1| if is_true {
106 LL| 1| assert_eq!(
107 LL| 1| Foo(3),
108 LL| 1| Foo(3)
109 LL| 1| );
110 LL| 1| Foo(0)
111 LL| | } else {
112 LL| 0| assert_ne!(
113 LL| 0| if is_true {
114 LL| 0| Foo(0)
115 LL| | } else {
116 LL| 0| Foo(1)
117 LL| | },
118 LL| | Foo(5)
119 LL| | );
120 LL| 0| Foo(1)
121 LL| | },
122 LL| | Foo(5),
123 LL| 0| "with a message"
124 LL| | );
125 LL| 1| assert_eq!(
126 LL| | Foo(1),
127 LL| | Foo(3),
128 LL| 1| "this assert should fail"
129 LL| | );
130 LL| 0| assert_eq!(
131 LL| | Foo(3),
132 LL| | Foo(3),
133 LL| 0| "this assert should not be reached"
134 LL| | );
135 LL| 0|}
136 LL| |
137 LL| |impl std::fmt::Debug for Foo {
138 LL| | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
139 LL| 7| write!(f, "try and succeed")?;
17df50a5 140 ^0
add651ee
FG
141 LL| 7| Ok(())
142 LL| 7| }
143 LL| |}
144 LL| |
145 LL| |static mut DEBUG_LEVEL_ENABLED: bool = false;
146 LL| |
147 LL| |macro_rules! debug {
148 LL| | ($($arg:tt)+) => (
149 LL| | if unsafe { DEBUG_LEVEL_ENABLED } {
150 LL| | println!($($arg)+);
151 LL| | }
152 LL| | );
153 LL| |}
154 LL| |
155 LL| 1|fn test1() {
156 LL| 1| debug!("debug is enabled");
17df50a5 157 ^0
add651ee 158 LL| 1| debug!("debug is enabled");
17df50a5 159 ^0
add651ee
FG
160 LL| 1| let _ = 0;
161 LL| 1| debug!("debug is enabled");
17df50a5 162 ^0
add651ee
FG
163 LL| 1| unsafe {
164 LL| 1| DEBUG_LEVEL_ENABLED = true;
165 LL| 1| }
166 LL| 1| debug!("debug is enabled");
167 LL| 1|}
168 LL| |
169 LL| |macro_rules! call_debug {
170 LL| | ($($arg:tt)+) => (
171 LL| 1| fn call_print(s: &str) {
172 LL| 1| print!("{}", s);
173 LL| 1| }
174 LL| |
175 LL| | call_print("called from call_debug: ");
176 LL| | debug!($($arg)+);
177 LL| | );
178 LL| |}
179 LL| |
180 LL| 1|fn test2() {
181 LL| 1| call_debug!("debug is enabled");
182 LL| 1|}
183 LL| |
184 LL| 1|fn main() {
185 LL| 1| test1();
186 LL| 1| test2();
187 LL| 1| test3();
188 LL| 1|}
17df50a5 189