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.
11 macro_rules! assert_approx_eq {
12 ($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: int = -4 + 3;
21 static A2: uint = 3 + 3;
22 static B: f64 = 3.0 + 2.7;
24 static C: int = 3 - 4;
25 static D: uint = 3 - 3;
26 static E: f64 = 3.0 - 2.7;
28 static E2: int = -3 * 3;
29 static F: uint = 3 * 3;
30 static G: f64 = 3.3 * 3.3;
32 static H: int = 3 / -1;
33 static I: uint = 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: int = 3 & 1;
41 static Q: uint = 1 & 3;
43 static R: int = 3 | 1;
44 static S: uint = 1 | 3;
46 static T: int = 3 ^ 1;
47 static U: uint = 1 ^ 3;
49 static V: int = 1 << 3;
51 // NOTE: better shr coverage
52 static W: int = 1024 >> 4;
53 static X: uint = 1024 >> 4;
55 static Y: bool = 1i == 1;
56 static Z: bool = 1.0f64 == 1.0;
58 static AA: bool = 1i <= 2;
59 static AB: bool = -1i <= 2;
60 static AC: bool = 1.0f64 <= 2.0;
62 static AD: bool = 1i < 2;
63 static AE: bool = -1i < 2;
64 static AF: bool = 1.0f64 < 2.0;
66 static AG: bool = 1i != 2;
67 static AH: bool = -1i != 2;
68 static AI: bool = 1.0f64 != 2.0;
70 static AJ: bool = 2i >= 1;
71 static AK: bool = 2i >= -2;
72 static AL: bool = 1.0f64 >= -2.0;
74 static AM: bool = 2i > 1;
75 static AN: bool = 2i > -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);