1 #![feature(rustc_attrs)]
2 #![deny(warnings)]
3 
4 use std::env;
5 use std::thread;
6 
main()7 fn main() {
8     let should_fail = env::args().nth(1) == Some("bad".to_string());
9 
10     assert_eq!(thread::spawn(debug_assert_eq).join().is_err(), should_fail);
11     assert_eq!(thread::spawn(debug_assert).join().is_err(), should_fail);
12     assert_eq!(thread::spawn(overflow).join().is_err(), should_fail);
13 }
14 
debug_assert_eq()15 fn debug_assert_eq() {
16     let mut hit1 = false;
17     let mut hit2 = false;
18     debug_assert_eq!({ hit1 = true; 1 }, { hit2 = true; 2 });
19     assert!(!hit1);
20     assert!(!hit2);
21 }
22 
debug_assert()23 fn debug_assert() {
24     let mut hit = false;
25     debug_assert!({ hit = true; false });
26     assert!(!hit);
27 }
28 
overflow()29 fn overflow() {
30     fn add(a: u8, b: u8) -> u8 { a + b }
31 
32     add(200u8, 200u8);
33 }
34