]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/num-wrapping.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / run-pass / num-wrapping.rs
1 // Copyright 2015 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 // compile-flags: -C debug-assertions
12 //
13 // Test std::num::Wrapping<T> for {uN, iN, usize, isize}
14
15 #![feature(test)]
16
17 extern crate test;
18
19 use std::num::Wrapping;
20 use std::ops::{
21 Add, Sub, Mul, Div, Rem, BitXor, BitOr, BitAnd,
22 AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, BitXorAssign, BitOrAssign, BitAndAssign,
23 Shl, Shr, ShlAssign, ShrAssign
24 };
25 use test::black_box;
26
27 macro_rules! int_modules {
28 ($(($name:ident, $size:expr),)*) => ($(
29 mod $name {
30 pub const BITS: usize = $size;
31 pub use std::$name::*;
32 }
33 )*)
34 }
35
36 int_modules! {
37 (i8, 8),
38 (i16, 16),
39 (i32, 32),
40 (i64, 64),
41 (u8, 8),
42 (u16, 16),
43 (u32, 32),
44 (u64, 64),
45 }
46
47 #[cfg(target_pointer_width = "32")]
48 int_modules! {
49 (isize, 32),
50 (usize, 32),
51 }
52
53 #[cfg(target_pointer_width = "64")]
54 int_modules! {
55 (isize, 64),
56 (usize, 64),
57 }
58
59 fn main() {
60 test_ops();
61 test_op_assigns();
62 test_sh_ops();
63 test_sh_op_assigns();
64 }
65
66 fn test_ops() {
67 macro_rules! op_test {
68 ($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => {
69 assert_eq!(black_box(Wrapping($lhs).$op(Wrapping($rhs))), Wrapping($ans));
70 // FIXME(30524): uncomment this test when it's implemented
71 // assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans));
72 }
73 }
74
75 op_test!(add(i8::MAX, 1) == i8::MIN);
76 op_test!(add(i16::MAX, 1) == i16::MIN);
77 op_test!(add(i32::MAX, 1) == i32::MIN);
78 op_test!(add(i64::MAX, 1) == i64::MIN);
79 op_test!(add(isize::MAX, 1) == isize::MIN);
80
81 op_test!(add(u8::MAX, 1) == 0);
82 op_test!(add(u16::MAX, 1) == 0);
83 op_test!(add(u32::MAX, 1) == 0);
84 op_test!(add(u64::MAX, 1) == 0);
85 op_test!(add(usize::MAX, 1) == 0);
86
87
88 op_test!(sub(i8::MIN, 1) == i8::MAX);
89 op_test!(sub(i16::MIN, 1) == i16::MAX);
90 op_test!(sub(i32::MIN, 1) == i32::MAX);
91 op_test!(sub(i64::MIN, 1) == i64::MAX);
92 op_test!(sub(isize::MIN, 1) == isize::MAX);
93
94 op_test!(sub(0u8, 1) == u8::MAX);
95 op_test!(sub(0u16, 1) == u16::MAX);
96 op_test!(sub(0u32, 1) == u32::MAX);
97 op_test!(sub(0u64, 1) == u64::MAX);
98 op_test!(sub(0usize, 1) == usize::MAX);
99
100
101 op_test!(mul(i8::MAX, 2) == -2);
102 op_test!(mul(i16::MAX, 2) == -2);
103 op_test!(mul(i32::MAX, 2) == -2);
104 op_test!(mul(i64::MAX, 2) == -2);
105 op_test!(mul(isize::MAX, 2) == -2);
106
107 op_test!(mul(u8::MAX, 2) == u8::MAX - 1);
108 op_test!(mul(u16::MAX, 2) == u16::MAX - 1);
109 op_test!(mul(u32::MAX, 2) == u32::MAX - 1);
110 op_test!(mul(u64::MAX, 2) == u64::MAX - 1);
111 op_test!(mul(usize::MAX, 2) == usize::MAX - 1);
112
113
114 op_test!(div(i8::MIN, -1) == i8::MIN);
115 op_test!(div(i16::MIN, -1) == i16::MIN);
116 op_test!(div(i32::MIN, -1) == i32::MIN);
117 op_test!(div(i64::MIN, -1) == i64::MIN);
118 op_test!(div(isize::MIN, -1) == isize::MIN);
119
120
121 op_test!(rem(i8::MIN, -1) == 0);
122 op_test!(rem(i16::MIN, -1) == 0);
123 op_test!(rem(i32::MIN, -1) == 0);
124 op_test!(rem(i64::MIN, -1) == 0);
125 op_test!(rem(isize::MIN, -1) == 0);
126
127 // these are not that interesting, just testing to make sure they are implemented correctly
128 op_test!(bitxor(0b101010i8, 0b100110) == 0b001100);
129 op_test!(bitxor(0b101010i16, 0b100110) == 0b001100);
130 op_test!(bitxor(0b101010i32, 0b100110) == 0b001100);
131 op_test!(bitxor(0b101010i64, 0b100110) == 0b001100);
132 op_test!(bitxor(0b101010isize, 0b100110) == 0b001100);
133
134 op_test!(bitxor(0b101010u8, 0b100110) == 0b001100);
135 op_test!(bitxor(0b101010u16, 0b100110) == 0b001100);
136 op_test!(bitxor(0b101010u32, 0b100110) == 0b001100);
137 op_test!(bitxor(0b101010u64, 0b100110) == 0b001100);
138 op_test!(bitxor(0b101010usize, 0b100110) == 0b001100);
139
140
141 op_test!(bitor(0b101010i8, 0b100110) == 0b101110);
142 op_test!(bitor(0b101010i16, 0b100110) == 0b101110);
143 op_test!(bitor(0b101010i32, 0b100110) == 0b101110);
144 op_test!(bitor(0b101010i64, 0b100110) == 0b101110);
145 op_test!(bitor(0b101010isize, 0b100110) == 0b101110);
146
147 op_test!(bitor(0b101010u8, 0b100110) == 0b101110);
148 op_test!(bitor(0b101010u16, 0b100110) == 0b101110);
149 op_test!(bitor(0b101010u32, 0b100110) == 0b101110);
150 op_test!(bitor(0b101010u64, 0b100110) == 0b101110);
151 op_test!(bitor(0b101010usize, 0b100110) == 0b101110);
152
153
154 op_test!(bitand(0b101010i8, 0b100110) == 0b100010);
155 op_test!(bitand(0b101010i16, 0b100110) == 0b100010);
156 op_test!(bitand(0b101010i32, 0b100110) == 0b100010);
157 op_test!(bitand(0b101010i64, 0b100110) == 0b100010);
158 op_test!(bitand(0b101010isize, 0b100110) == 0b100010);
159
160 op_test!(bitand(0b101010u8, 0b100110) == 0b100010);
161 op_test!(bitand(0b101010u16, 0b100110) == 0b100010);
162 op_test!(bitand(0b101010u32, 0b100110) == 0b100010);
163 op_test!(bitand(0b101010u64, 0b100110) == 0b100010);
164 op_test!(bitand(0b101010usize, 0b100110) == 0b100010);
165 }
166
167 fn test_op_assigns() {
168 macro_rules! op_assign_test {
169 ($op:ident ($initial:expr, $rhs:expr) == $ans:expr) => {
170 {
171 let mut tmp = Wrapping($initial);
172 tmp = black_box(tmp);
173 tmp.$op(Wrapping($rhs));
174 assert_eq!(black_box(tmp), Wrapping($ans));
175 }
176 // FIXME(30524): Uncomment this test
177 /*
178 {
179 let mut tmp = Wrapping($initial);
180 tmp = black_box(tmp);
181 tmp.$op($rhs);
182 assert_eq!(black_box(tmp), Wrapping($ans));
183 }
184 */
185 }
186 }
187 op_assign_test!(add_assign(i8::MAX, 1) == i8::MIN);
188 op_assign_test!(add_assign(i16::MAX, 1) == i16::MIN);
189 op_assign_test!(add_assign(i32::MAX, 1) == i32::MIN);
190 op_assign_test!(add_assign(i64::MAX, 1) == i64::MIN);
191 op_assign_test!(add_assign(isize::MAX, 1) == isize::MIN);
192
193 op_assign_test!(add_assign(u8::MAX, 1) == u8::MIN);
194 op_assign_test!(add_assign(u16::MAX, 1) == u16::MIN);
195 op_assign_test!(add_assign(u32::MAX, 1) == u32::MIN);
196 op_assign_test!(add_assign(u64::MAX, 1) == u64::MIN);
197 op_assign_test!(add_assign(usize::MAX, 1) == usize::MIN);
198
199
200 op_assign_test!(sub_assign(i8::MIN, 1) == i8::MAX);
201 op_assign_test!(sub_assign(i16::MIN, 1) == i16::MAX);
202 op_assign_test!(sub_assign(i32::MIN, 1) == i32::MAX);
203 op_assign_test!(sub_assign(i64::MIN, 1) == i64::MAX);
204 op_assign_test!(sub_assign(isize::MIN, 1) == isize::MAX);
205
206 op_assign_test!(sub_assign(u8::MIN, 1) == u8::MAX);
207 op_assign_test!(sub_assign(u16::MIN, 1) == u16::MAX);
208 op_assign_test!(sub_assign(u32::MIN, 1) == u32::MAX);
209 op_assign_test!(sub_assign(u64::MIN, 1) == u64::MAX);
210 op_assign_test!(sub_assign(usize::MIN, 1) == usize::MAX);
211
212
213 op_assign_test!(mul_assign(i8::MAX, 2) == -2);
214 op_assign_test!(mul_assign(i16::MAX, 2) == -2);
215 op_assign_test!(mul_assign(i32::MAX, 2) == -2);
216 op_assign_test!(mul_assign(i64::MAX, 2) == -2);
217 op_assign_test!(mul_assign(isize::MAX, 2) == -2);
218
219 op_assign_test!(mul_assign(u8::MAX, 2) == u8::MAX - 1);
220 op_assign_test!(mul_assign(u16::MAX, 2) == u16::MAX - 1);
221 op_assign_test!(mul_assign(u32::MAX, 2) == u32::MAX - 1);
222 op_assign_test!(mul_assign(u64::MAX, 2) == u64::MAX - 1);
223 op_assign_test!(mul_assign(usize::MAX, 2) == usize::MAX - 1);
224
225
226 op_assign_test!(div_assign(i8::MIN, -1) == i8::MIN);
227 op_assign_test!(div_assign(i16::MIN, -1) == i16::MIN);
228 op_assign_test!(div_assign(i32::MIN, -1) == i32::MIN);
229 op_assign_test!(div_assign(i64::MIN, -1) == i64::MIN);
230 op_assign_test!(div_assign(isize::MIN, -1) == isize::MIN);
231
232
233 op_assign_test!(rem_assign(i8::MIN, -1) == 0);
234 op_assign_test!(rem_assign(i16::MIN, -1) == 0);
235 op_assign_test!(rem_assign(i32::MIN, -1) == 0);
236 op_assign_test!(rem_assign(i64::MIN, -1) == 0);
237 op_assign_test!(rem_assign(isize::MIN, -1) == 0);
238
239
240 // these are not that interesting, just testing to make sure they are implemented correctly
241 op_assign_test!(bitxor_assign(0b101010i8, 0b100110) == 0b001100);
242 op_assign_test!(bitxor_assign(0b101010i16, 0b100110) == 0b001100);
243 op_assign_test!(bitxor_assign(0b101010i32, 0b100110) == 0b001100);
244 op_assign_test!(bitxor_assign(0b101010i64, 0b100110) == 0b001100);
245 op_assign_test!(bitxor_assign(0b101010isize, 0b100110) == 0b001100);
246
247 op_assign_test!(bitxor_assign(0b101010u8, 0b100110) == 0b001100);
248 op_assign_test!(bitxor_assign(0b101010u16, 0b100110) == 0b001100);
249 op_assign_test!(bitxor_assign(0b101010u32, 0b100110) == 0b001100);
250 op_assign_test!(bitxor_assign(0b101010u64, 0b100110) == 0b001100);
251 op_assign_test!(bitxor_assign(0b101010usize, 0b100110) == 0b001100);
252
253
254 op_assign_test!(bitor_assign(0b101010i8, 0b100110) == 0b101110);
255 op_assign_test!(bitor_assign(0b101010i16, 0b100110) == 0b101110);
256 op_assign_test!(bitor_assign(0b101010i32, 0b100110) == 0b101110);
257 op_assign_test!(bitor_assign(0b101010i64, 0b100110) == 0b101110);
258 op_assign_test!(bitor_assign(0b101010isize, 0b100110) == 0b101110);
259
260 op_assign_test!(bitor_assign(0b101010u8, 0b100110) == 0b101110);
261 op_assign_test!(bitor_assign(0b101010u16, 0b100110) == 0b101110);
262 op_assign_test!(bitor_assign(0b101010u32, 0b100110) == 0b101110);
263 op_assign_test!(bitor_assign(0b101010u64, 0b100110) == 0b101110);
264 op_assign_test!(bitor_assign(0b101010usize, 0b100110) == 0b101110);
265
266
267 op_assign_test!(bitand_assign(0b101010i8, 0b100110) == 0b100010);
268 op_assign_test!(bitand_assign(0b101010i16, 0b100110) == 0b100010);
269 op_assign_test!(bitand_assign(0b101010i32, 0b100110) == 0b100010);
270 op_assign_test!(bitand_assign(0b101010i64, 0b100110) == 0b100010);
271 op_assign_test!(bitand_assign(0b101010isize, 0b100110) == 0b100010);
272
273 op_assign_test!(bitand_assign(0b101010u8, 0b100110) == 0b100010);
274 op_assign_test!(bitand_assign(0b101010u16, 0b100110) == 0b100010);
275 op_assign_test!(bitand_assign(0b101010u32, 0b100110) == 0b100010);
276 op_assign_test!(bitand_assign(0b101010u64, 0b100110) == 0b100010);
277 op_assign_test!(bitand_assign(0b101010usize, 0b100110) == 0b100010);
278 }
279
280 fn test_sh_ops() {
281 macro_rules! sh_test {
282 ($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => {
283 assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans));
284 }
285 }
286 // NOTE: This will break for i8 if we ever get i/u128
287 macro_rules! sh_test_all {
288 ($t:ty) => {
289 sh_test!(shl(i8::MAX, (i8::BITS + 1) as $t) == -2);
290 sh_test!(shl(i16::MAX, (i16::BITS + 1) as $t) == -2);
291 sh_test!(shl(i32::MAX, (i32::BITS + 1) as $t) == -2);
292 sh_test!(shl(i64::MAX, (i64::BITS + 1) as $t) == -2);
293 sh_test!(shl(isize::MAX, (isize::BITS + 1) as $t) == -2);
294
295 sh_test!(shl(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX - 1);
296 sh_test!(shl(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX - 1);
297 sh_test!(shl(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX - 1);
298 sh_test!(shl(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX - 1);
299 sh_test!(shl(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX - 1);
300
301
302 sh_test!(shr(i8::MAX, (i8::BITS + 1) as $t) == i8::MAX / 2);
303 sh_test!(shr(i16::MAX, (i16::BITS + 1) as $t) == i16::MAX / 2);
304 sh_test!(shr(i32::MAX, (i32::BITS + 1) as $t) == i32::MAX / 2);
305 sh_test!(shr(i64::MAX, (i64::BITS + 1) as $t) == i64::MAX / 2);
306 sh_test!(shr(isize::MAX, (isize::BITS + 1) as $t) == isize::MAX / 2);
307
308 sh_test!(shr(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX / 2);
309 sh_test!(shr(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX / 2);
310 sh_test!(shr(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX / 2);
311 sh_test!(shr(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX / 2);
312 sh_test!(shr(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX / 2);
313 }
314 }
315 macro_rules! sh_test_negative_all {
316 ($t:ty) => {
317 sh_test!(shr(i8::MAX, -((i8::BITS + 1) as $t)) == -2);
318 sh_test!(shr(i16::MAX, -((i16::BITS + 1) as $t)) == -2);
319 sh_test!(shr(i32::MAX, -((i32::BITS + 1) as $t)) == -2);
320 sh_test!(shr(i64::MAX, -((i64::BITS + 1) as $t)) == -2);
321 sh_test!(shr(isize::MAX, -((isize::BITS + 1) as $t)) == -2);
322
323 sh_test!(shr(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX - 1);
324 sh_test!(shr(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX - 1);
325 sh_test!(shr(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX - 1);
326 sh_test!(shr(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX - 1);
327 sh_test!(shr(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX - 1);
328
329
330 sh_test!(shl(i8::MAX, -((i8::BITS + 1) as $t)) == i8::MAX / 2);
331 sh_test!(shl(i16::MAX, -((i16::BITS + 1) as $t)) == i16::MAX / 2);
332 sh_test!(shl(i32::MAX, -((i32::BITS + 1) as $t)) == i32::MAX / 2);
333 sh_test!(shl(i64::MAX, -((i64::BITS + 1) as $t)) == i64::MAX / 2);
334 sh_test!(shl(isize::MAX, -((isize::BITS + 1) as $t)) == isize::MAX / 2);
335
336 sh_test!(shl(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX / 2);
337 sh_test!(shl(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX / 2);
338 sh_test!(shl(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX / 2);
339 sh_test!(shl(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX / 2);
340 sh_test!(shl(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX / 2);
341 }
342 }
343 // FIXME(#23545): Uncomment the remaining tests
344 //sh_test_all!(i8);
345 //sh_test_all!(u8);
346 //sh_test_all!(i16);
347 //sh_test_all!(u16);
348 //sh_test_all!(i32);
349 //sh_test_all!(u32);
350 //sh_test_all!(i64);
351 //sh_test_all!(u64);
352 //sh_test_all!(isize);
353 sh_test_all!(usize);
354
355 //sh_test_negative_all!(i8);
356 //sh_test_negative_all!(i16);
357 //sh_test_negative_all!(i32);
358 //sh_test_negative_all!(i64);
359 //sh_test_negative_all!(isize);
360 }
361
362 fn test_sh_op_assigns() {
363 macro_rules! sh_assign_test {
364 ($op:ident ($initial:expr, $rhs:expr) == $ans:expr) => {{
365 let mut tmp = Wrapping($initial);
366 tmp = black_box(tmp);
367 tmp.$op($rhs);
368 assert_eq!(black_box(tmp), Wrapping($ans));
369 }}
370 }
371 macro_rules! sh_assign_test_all {
372 ($t:ty) => {
373 sh_assign_test!(shl_assign(i8::MAX, (i8::BITS + 1) as $t) == -2);
374 sh_assign_test!(shl_assign(i16::MAX, (i16::BITS + 1) as $t) == -2);
375 sh_assign_test!(shl_assign(i32::MAX, (i32::BITS + 1) as $t) == -2);
376 sh_assign_test!(shl_assign(i64::MAX, (i64::BITS + 1) as $t) == -2);
377 sh_assign_test!(shl_assign(isize::MAX, (isize::BITS + 1) as $t) == -2);
378
379 sh_assign_test!(shl_assign(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX - 1);
380 sh_assign_test!(shl_assign(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX - 1);
381 sh_assign_test!(shl_assign(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX - 1);
382 sh_assign_test!(shl_assign(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX - 1);
383 sh_assign_test!(shl_assign(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX - 1);
384
385
386 sh_assign_test!(shr_assign(i8::MAX, (i8::BITS + 1) as $t) == i8::MAX / 2);
387 sh_assign_test!(shr_assign(i16::MAX, (i16::BITS + 1) as $t) == i16::MAX / 2);
388 sh_assign_test!(shr_assign(i32::MAX, (i32::BITS + 1) as $t) == i32::MAX / 2);
389 sh_assign_test!(shr_assign(i64::MAX, (i64::BITS + 1) as $t) == i64::MAX / 2);
390 sh_assign_test!(shr_assign(isize::MAX, (isize::BITS + 1) as $t) == isize::MAX / 2);
391
392 sh_assign_test!(shr_assign(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX / 2);
393 sh_assign_test!(shr_assign(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX / 2);
394 sh_assign_test!(shr_assign(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX / 2);
395 sh_assign_test!(shr_assign(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX / 2);
396 sh_assign_test!(shr_assign(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX / 2);
397 }
398 }
399 macro_rules! sh_assign_test_negative_all {
400 ($t:ty) => {
401 sh_assign_test!(shr_assign(i8::MAX, -((i8::BITS + 1) as $t)) == -2);
402 sh_assign_test!(shr_assign(i16::MAX, -((i16::BITS + 1) as $t)) == -2);
403 sh_assign_test!(shr_assign(i32::MAX, -((i32::BITS + 1) as $t)) == -2);
404 sh_assign_test!(shr_assign(i64::MAX, -((i64::BITS + 1) as $t)) == -2);
405 sh_assign_test!(shr_assign(isize::MAX, -((isize::BITS + 1) as $t)) == -2);
406
407 sh_assign_test!(shr_assign(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX - 1);
408 sh_assign_test!(shr_assign(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX - 1);
409 sh_assign_test!(shr_assign(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX - 1);
410 sh_assign_test!(shr_assign(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX - 1);
411 sh_assign_test!(shr_assign(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX - 1);
412
413
414 sh_assign_test!(shl_assign(i8::MAX, -((i8::BITS + 1) as $t)) == i8::MAX / 2);
415 sh_assign_test!(shl_assign(i16::MAX, -((i16::BITS + 1) as $t)) == i16::MAX / 2);
416 sh_assign_test!(shl_assign(i32::MAX, -((i32::BITS + 1) as $t)) == i32::MAX / 2);
417 sh_assign_test!(shl_assign(i64::MAX, -((i64::BITS + 1) as $t)) == i64::MAX / 2);
418 sh_assign_test!(shl_assign(isize::MAX, -((isize::BITS + 1) as $t)) == isize::MAX / 2);
419
420 sh_assign_test!(shl_assign(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX / 2);
421 sh_assign_test!(shl_assign(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX / 2);
422 sh_assign_test!(shl_assign(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX / 2);
423 sh_assign_test!(shl_assign(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX / 2);
424 sh_assign_test!(shl_assign(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX / 2);
425 }
426 }
427
428 // FIXME(#23545): Uncomment the remaining tests
429 //sh_assign_test_all!(i8);
430 //sh_assign_test_all!(u8);
431 //sh_assign_test_all!(i16);
432 //sh_assign_test_all!(u16);
433 //sh_assign_test_all!(i32);
434 //sh_assign_test_all!(u32);
435 //sh_assign_test_all!(i64);
436 //sh_assign_test_all!(u64);
437 //sh_assign_test_all!(isize);
438 sh_assign_test_all!(usize);
439
440 //sh_assign_test_negative_all!(i8);
441 //sh_assign_test_negative_all!(i16);
442 //sh_assign_test_negative_all!(i32);
443 //sh_assign_test_negative_all!(i64);
444 //sh_assign_test_negative_all!(isize);
445 }