]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/const-int-sign.rs
Rollup merge of #61705 - petrhosek:llvm-cflags, r=alexcrichton
[rust.git] / src / test / run-pass / const-int-sign.rs
1 #![feature(const_int_sign)]
2
3 const NEGATIVE_A: bool = (-10i32).is_negative();
4 const NEGATIVE_B: bool = 10i32.is_negative();
5 const POSITIVE_A: bool = (-10i32).is_positive();
6 const POSITIVE_B: bool = 10i32.is_positive();
7
8 const SIGNUM_POS: i32 = 10i32.signum();
9 const SIGNUM_NIL: i32 = 0i32.signum();
10 const SIGNUM_NEG: i32 = (-42i32).signum();
11
12 fn main() {
13     assert!(NEGATIVE_A);
14     assert!(!NEGATIVE_B);
15     assert!(!POSITIVE_A);
16     assert!(POSITIVE_B);
17
18     assert_eq!(SIGNUM_POS, 1);
19     assert_eq!(SIGNUM_NIL, 0);
20     assert_eq!(SIGNUM_NEG, -1);
21 }