]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/const-binops.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.
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.
12 macro_rules
! assert_approx_eq
{
13 ($a
:expr
, $b
:expr
) => ({
14 let (a
, b
) = (&$a
, &$b
);
15 assert
!((*a
- *b
).abs() < 1.0e-6,
16 "{} is not approximately equal to {}", *a
, *b
);
20 static A
: isize = -4 + 3;
21 static A2
: usize = 3 + 3;
22 static B
: f64 = 3.0 + 2.7;
24 static C
: isize = 3 - 4;
25 static D
: usize = 3 - 3;
26 static E
: f64 = 3.0 - 2.7;
28 static E2
: isize = -3 * 3;
29 static F
: usize = 3 * 3;
30 static G
: f64 = 3.3 * 3.3;
32 static H
: isize = 3 / -1;
33 static I
: usize = 3 / 3;
34 static J
: f64 = 3.3 / 3.3;
36 static N
: bool
= true && false;
38 static O
: bool
= true || false;
40 static P
: isize = 3 & 1;
41 static Q
: usize = 1 & 3;
43 static R
: isize = 3 | 1;
44 static S
: usize = 1 | 3;
46 static T
: isize = 3 ^
1;
47 static U
: usize = 1 ^
3;
49 static V
: isize = 1 << 3;
51 // NOTE: better shr coverage
52 static W
: isize = 1024 >> 4;
53 static X
: usize = 1024 >> 4;
55 static Y
: bool
= 1 == 1;
56 static Z
: bool
= 1.0f64 == 1.0;
58 static AA
: bool
= 1 <= 2;
59 static AB
: bool
= -1 <= 2;
60 static AC
: bool
= 1.0f64 <= 2.0;
62 static AD
: bool
= 1 < 2;
63 static AE
: bool
= -1 < 2;
64 static AF
: bool
= 1.0f64 < 2.0;
66 static AG
: bool
= 1 != 2;
67 static AH
: bool
= -1 != 2;
68 static AI
: bool
= 1.0f64 != 2.0;
70 static AJ
: bool
= 2 >= 1;
71 static AK
: bool
= 2 >= -2;
72 static AL
: bool
= 1.0f64 >= -2.0;
74 static AM
: bool
= 2 > 1;
75 static AN
: bool
= 2 > -2;
76 static AO
: bool
= 1.0f64 > -2.0;
81 assert_approx_eq
!(B
, 5.7);
85 assert_approx_eq
!(E
, 0.3);
89 assert_approx_eq
!(G
, 10.89);
93 assert_approx_eq
!(J
, 1.0);
116 assert_eq
!(AA
, true);
117 assert_eq
!(AB
, true);
118 assert_eq
!(AC
, true);
120 assert_eq
!(AD
, true);
121 assert_eq
!(AE
, true);
122 assert_eq
!(AF
, true);
124 assert_eq
!(AG
, true);
125 assert_eq
!(AH
, true);
126 assert_eq
!(AI
, true);
128 assert_eq
!(AJ
, true);
129 assert_eq
!(AK
, true);
130 assert_eq
!(AL
, true);
132 assert_eq
!(AM
, true);
133 assert_eq
!(AN
, true);
134 assert_eq
!(AO
, true);