2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2021-12-03 09:32:51 -06:00
|
|
|
// needs-unwind
|
2016-09-09 22:39:49 -05:00
|
|
|
// compile-flags: -C debug_assertions=yes
|
|
|
|
|
|
|
|
use std::panic;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let r = panic::catch_unwind(|| {
|
2020-06-02 02:59:11 -05:00
|
|
|
[1, i32::MAX].iter().sum::<i32>();
|
2016-09-09 22:39:49 -05:00
|
|
|
});
|
|
|
|
assert!(r.is_err());
|
|
|
|
|
|
|
|
let r = panic::catch_unwind(|| {
|
2020-06-02 02:59:11 -05:00
|
|
|
[2, i32::MAX].iter().product::<i32>();
|
2016-09-09 22:39:49 -05:00
|
|
|
});
|
|
|
|
assert!(r.is_err());
|
|
|
|
|
|
|
|
let r = panic::catch_unwind(|| {
|
2020-06-02 02:59:11 -05:00
|
|
|
[1, i32::MAX].iter().cloned().sum::<i32>();
|
2016-09-09 22:39:49 -05:00
|
|
|
});
|
|
|
|
assert!(r.is_err());
|
|
|
|
|
|
|
|
let r = panic::catch_unwind(|| {
|
2020-06-02 02:59:11 -05:00
|
|
|
[2, i32::MAX].iter().cloned().product::<i32>();
|
2016-09-09 22:39:49 -05:00
|
|
|
});
|
|
|
|
assert!(r.is_err());
|
|
|
|
}
|