]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-8460.rs
Auto merge of #41433 - estebank:constructor, r=michaelwoerister
[rust.git] / src / test / run-pass / issue-8460.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-emscripten no threads support
12 #![feature(rustc_attrs)]
13
14 use std::thread;
15
16 trait Int {
17     fn zero() -> Self;
18     fn one() -> Self;
19 }
20 macro_rules! doit {
21     ($($t:ident)*) => ($(impl Int for $t {
22         fn zero() -> $t { 0 }
23         fn one() -> $t { 1 }
24     })*)
25 }
26 doit! { i8 i16 i32 i64 isize }
27
28 macro_rules! check {
29     ($($e:expr),*) => {
30         $(assert!(thread::spawn({
31             move|| { $e; }
32         }).join().is_err());)*
33     }
34 }
35
36 fn main() {
37     check![
38         isize::min_value() / -isize::one(),
39         i8::min_value() / -i8::one(),
40         i16::min_value() / -i16::one(),
41         i32::min_value() / -i32::one(),
42         i64::min_value() / -i64::one(),
43         1isize / isize::zero(),
44         1i8 / i8::zero(),
45         1i16 / i16::zero(),
46         1i32 / i32::zero(),
47         1i64 / i64::zero(),
48         isize::min_value() % -isize::one(),
49         i8::min_value() % -i8::one(),
50         i16::min_value() % -i16::one(),
51         i32::min_value() % -i32::one(),
52         i64::min_value() % -i64::one(),
53         1isize % isize::zero(),
54         1i8 % i8::zero(),
55         1i16 % i16::zero(),
56         1i32 % i32::zero(),
57         1i64 % i64::zero()
58     ];
59 }