2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(unused_must_use)]
|
2016-02-11 05:34:41 -06:00
|
|
|
// ignore-emscripten no threads support
|
2017-04-20 17:12:42 -05:00
|
|
|
#![feature(rustc_attrs)]
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2015-02-17 17:24:34 -06:00
|
|
|
use std::thread;
|
2014-06-05 14:23:34 -05:00
|
|
|
|
2017-04-20 17:12:42 -05:00
|
|
|
trait Int {
|
|
|
|
fn zero() -> Self;
|
|
|
|
fn one() -> Self;
|
|
|
|
}
|
|
|
|
macro_rules! doit {
|
|
|
|
($($t:ident)*) => ($(impl Int for $t {
|
|
|
|
fn zero() -> $t { 0 }
|
|
|
|
fn one() -> $t { 1 }
|
|
|
|
})*)
|
|
|
|
}
|
|
|
|
doit! { i8 i16 i32 i64 isize }
|
|
|
|
|
2016-03-10 13:20:09 -06:00
|
|
|
macro_rules! check {
|
|
|
|
($($e:expr),*) => {
|
|
|
|
$(assert!(thread::spawn({
|
|
|
|
move|| { $e; }
|
|
|
|
}).join().is_err());)*
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-05 14:23:34 -05:00
|
|
|
fn main() {
|
2016-03-10 13:20:09 -06:00
|
|
|
check![
|
2017-04-20 17:12:42 -05:00
|
|
|
isize::min_value() / -isize::one(),
|
|
|
|
i8::min_value() / -i8::one(),
|
|
|
|
i16::min_value() / -i16::one(),
|
|
|
|
i32::min_value() / -i32::one(),
|
|
|
|
i64::min_value() / -i64::one(),
|
2016-03-10 13:20:09 -06:00
|
|
|
1isize / isize::zero(),
|
|
|
|
1i8 / i8::zero(),
|
|
|
|
1i16 / i16::zero(),
|
|
|
|
1i32 / i32::zero(),
|
|
|
|
1i64 / i64::zero(),
|
2017-04-20 17:12:42 -05:00
|
|
|
isize::min_value() % -isize::one(),
|
|
|
|
i8::min_value() % -i8::one(),
|
|
|
|
i16::min_value() % -i16::one(),
|
|
|
|
i32::min_value() % -i32::one(),
|
|
|
|
i64::min_value() % -i64::one(),
|
2016-03-10 13:20:09 -06:00
|
|
|
1isize % isize::zero(),
|
|
|
|
1i8 % i8::zero(),
|
|
|
|
1i16 % i16::zero(),
|
|
|
|
1i32 % i32::zero(),
|
|
|
|
1i64 % i64::zero()
|
|
|
|
];
|
2014-06-05 14:23:34 -05:00
|
|
|
}
|