1 // This demonstrated Issue #84561: function-like macros produce unintuitive coverage results.
3 // expect-exit-status-101
4 #[derive(PartialEq, Eq)]
7 let is_true = std::env::args().len() == 1;
9 assert_eq!(bar, Foo(1));
11 assert_ne!(baz, Foo(1));
12 println!("{:?}", Foo(1));
13 println!("{:?}", bar);
14 println!("{:?}", baz);
16 assert_eq!(Foo(1), Foo(1));
17 assert_ne!(Foo(0), Foo(1));
18 assert_eq!(Foo(2), Foo(2));
20 assert_ne!(bar, Foo(3));
21 assert_ne!(Foo(0), Foo(4));
22 assert_eq!(Foo(3), Foo(3), "with a message");
23 println!("{:?}", bar);
24 println!("{:?}", Foo(1));
26 assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" });
43 let is_true = std::env::args().len() == 1;
126 "this assert should fail"
131 "this assert should not be reached"
135 impl std::fmt::Debug for Foo {
136 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
137 write!(f, "try and succeed")?;
142 static mut DEBUG_LEVEL_ENABLED: bool = false;
146 if unsafe { DEBUG_LEVEL_ENABLED } {
153 debug!("debug is enabled");
154 debug!("debug is enabled");
156 debug!("debug is enabled");
158 DEBUG_LEVEL_ENABLED = true;
160 debug!("debug is enabled");
163 macro_rules! call_debug {
165 fn call_print(s: &str) {
169 call_print("called from call_debug: ");
175 call_debug!("debug is enabled");