summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const-int-sign-rpass.rs
blob: 63c191d422716e9a903a2e3a37bdbc3eebaf5c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// run-pass

const NEGATIVE_A: bool = (-10i32).is_negative();
const NEGATIVE_B: bool = 10i32.is_negative();
const POSITIVE_A: bool = (-10i32).is_positive();
const POSITIVE_B: bool = 10i32.is_positive();

const SIGNUM_POS: i32 = 10i32.signum();
const SIGNUM_NIL: i32 = 0i32.signum();
const SIGNUM_NEG: i32 = (-42i32).signum();

const ABS_A: i32 = 10i32.abs();
const ABS_B: i32 = (-10i32).abs();

fn main() {
    assert!(NEGATIVE_A);
    assert!(!NEGATIVE_B);
    assert!(!POSITIVE_A);
    assert!(POSITIVE_B);

    assert_eq!(SIGNUM_POS, 1);
    assert_eq!(SIGNUM_NIL, 0);
    assert_eq!(SIGNUM_NEG, -1);

    assert_eq!(ABS_A, 10);
    assert_eq!(ABS_B, 10);
}