summaryrefslogtreecommitdiffstats
path: root/tests/ui/numbers-arithmetic/num-wrapping.rs
blob: 43b1059f944eedb36abee54c754c52715460f999 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
// run-pass
#![allow(unused_macros)]

// compile-flags: -C debug-assertions
//
// Test std::num::Wrapping<T> for {uN, iN, usize, isize}

#![feature(test)]

extern crate test;

use std::num::Wrapping;
use std::ops::{
    Add, Sub, Mul, Div, Rem, BitXor, BitOr, BitAnd,
    AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, BitXorAssign, BitOrAssign, BitAndAssign,
    Shl, Shr, ShlAssign, ShrAssign
};
use test::black_box;

macro_rules! int_modules {
    ($(($name:ident, $size:expr),)*) => ($(
        mod $name {
            pub const BITS: usize = $size;
            pub const MAX: $name = $name::MAX;
            pub const MIN: $name = $name::MIN;
        }
    )*)
}

int_modules! {
    (i8, 8),
    (i16, 16),
    (i32, 32),
    (i64, 64),
    (u8, 8),
    (u16, 16),
    (u32, 32),
    (u64, 64),
}

#[cfg(target_pointer_width = "32")]
int_modules! {
    (isize, 32),
    (usize, 32),
}

#[cfg(target_pointer_width = "64")]
int_modules! {
    (isize, 64),
    (usize, 64),
}

fn main() {
    test_ops();
    test_op_assigns();
    test_sh_ops();
    test_sh_op_assigns();
}

fn test_ops() {
    macro_rules! op_test {
        ($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => {
            assert_eq!(black_box(Wrapping($lhs).$op(Wrapping($rhs))), Wrapping($ans));
            // FIXME(30524): uncomment this test when it's implemented
            // assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans));
        }
    }

    op_test!(add(i8::MAX, 1) == i8::MIN);
    op_test!(add(i16::MAX, 1) == i16::MIN);
    op_test!(add(i32::MAX, 1) == i32::MIN);
    op_test!(add(i64::MAX, 1) == i64::MIN);
    op_test!(add(isize::MAX, 1) == isize::MIN);

    op_test!(add(u8::MAX, 1) == 0);
    op_test!(add(u16::MAX, 1) == 0);
    op_test!(add(u32::MAX, 1) == 0);
    op_test!(add(u64::MAX, 1) == 0);
    op_test!(add(usize::MAX, 1) == 0);


    op_test!(sub(i8::MIN, 1) == i8::MAX);
    op_test!(sub(i16::MIN, 1) == i16::MAX);
    op_test!(sub(i32::MIN, 1) == i32::MAX);
    op_test!(sub(i64::MIN, 1) == i64::MAX);
    op_test!(sub(isize::MIN, 1) == isize::MAX);

    op_test!(sub(0u8, 1) == u8::MAX);
    op_test!(sub(0u16, 1) == u16::MAX);
    op_test!(sub(0u32, 1) == u32::MAX);
    op_test!(sub(0u64, 1) == u64::MAX);
    op_test!(sub(0usize, 1) == usize::MAX);


    op_test!(mul(i8::MAX, 2) == -2);
    op_test!(mul(i16::MAX, 2) == -2);
    op_test!(mul(i32::MAX, 2) == -2);
    op_test!(mul(i64::MAX, 2) == -2);
    op_test!(mul(isize::MAX, 2) == -2);

    op_test!(mul(u8::MAX, 2) == u8::MAX - 1);
    op_test!(mul(u16::MAX, 2) == u16::MAX - 1);
    op_test!(mul(u32::MAX, 2) == u32::MAX - 1);
    op_test!(mul(u64::MAX, 2) == u64::MAX - 1);
    op_test!(mul(usize::MAX, 2) == usize::MAX - 1);


    op_test!(div(i8::MIN, -1) == i8::MIN);
    op_test!(div(i16::MIN, -1) == i16::MIN);
    op_test!(div(i32::MIN, -1) == i32::MIN);
    op_test!(div(i64::MIN, -1) == i64::MIN);
    op_test!(div(isize::MIN, -1) == isize::MIN);


    op_test!(rem(i8::MIN, -1) == 0);
    op_test!(rem(i16::MIN, -1) == 0);
    op_test!(rem(i32::MIN, -1) == 0);
    op_test!(rem(i64::MIN, -1) == 0);
    op_test!(rem(isize::MIN, -1) == 0);

    // these are not that interesting, just testing to make sure they are implemented correctly
    op_test!(bitxor(0b101010i8, 0b100110) == 0b001100);
    op_test!(bitxor(0b101010i16, 0b100110) == 0b001100);
    op_test!(bitxor(0b101010i32, 0b100110) == 0b001100);
    op_test!(bitxor(0b101010i64, 0b100110) == 0b001100);
    op_test!(bitxor(0b101010isize, 0b100110) == 0b001100);

    op_test!(bitxor(0b101010u8, 0b100110) == 0b001100);
    op_test!(bitxor(0b101010u16, 0b100110) == 0b001100);
    op_test!(bitxor(0b101010u32, 0b100110) == 0b001100);
    op_test!(bitxor(0b101010u64, 0b100110) == 0b001100);
    op_test!(bitxor(0b101010usize, 0b100110) == 0b001100);


    op_test!(bitor(0b101010i8, 0b100110) == 0b101110);
    op_test!(bitor(0b101010i16, 0b100110) == 0b101110);
    op_test!(bitor(0b101010i32, 0b100110) == 0b101110);
    op_test!(bitor(0b101010i64, 0b100110) == 0b101110);
    op_test!(bitor(0b101010isize, 0b100110) == 0b101110);

    op_test!(bitor(0b101010u8, 0b100110) == 0b101110);
    op_test!(bitor(0b101010u16, 0b100110) == 0b101110);
    op_test!(bitor(0b101010u32, 0b100110) == 0b101110);
    op_test!(bitor(0b101010u64, 0b100110) == 0b101110);
    op_test!(bitor(0b101010usize, 0b100110) == 0b101110);


    op_test!(bitand(0b101010i8, 0b100110) == 0b100010);
    op_test!(bitand(0b101010i16, 0b100110) == 0b100010);
    op_test!(bitand(0b101010i32, 0b100110) == 0b100010);
    op_test!(bitand(0b101010i64, 0b100110) == 0b100010);
    op_test!(bitand(0b101010isize, 0b100110) == 0b100010);

    op_test!(bitand(0b101010u8, 0b100110) == 0b100010);
    op_test!(bitand(0b101010u16, 0b100110) == 0b100010);
    op_test!(bitand(0b101010u32, 0b100110) == 0b100010);
    op_test!(bitand(0b101010u64, 0b100110) == 0b100010);
    op_test!(bitand(0b101010usize, 0b100110) == 0b100010);
}

fn test_op_assigns() {
    macro_rules! op_assign_test {
        ($op:ident ($initial:expr, $rhs:expr) == $ans:expr) => {
            {
                let mut tmp = Wrapping($initial);
                tmp = black_box(tmp);
                tmp.$op(Wrapping($rhs));
                assert_eq!(black_box(tmp), Wrapping($ans));
            }

            // also test that a &Wrapping<T> right-hand side is possible
            {
                let mut tmp = Wrapping($initial);
                tmp = black_box(tmp);
                tmp.$op(&Wrapping($rhs));
                assert_eq!(black_box(tmp), Wrapping($ans));
            }

            // FIXME(30524): uncomment this test
            /*
            {
                let mut tmp = Wrapping($initial);
                tmp = black_box(tmp);
                tmp.$op($rhs);
                assert_eq!(black_box(tmp), Wrapping($ans));
            }
            */
        }
    }
    op_assign_test!(add_assign(i8::MAX, 1) == i8::MIN);
    op_assign_test!(add_assign(i16::MAX, 1) == i16::MIN);
    op_assign_test!(add_assign(i32::MAX, 1) == i32::MIN);
    op_assign_test!(add_assign(i64::MAX, 1) == i64::MIN);
    op_assign_test!(add_assign(isize::MAX, 1) == isize::MIN);

    op_assign_test!(add_assign(u8::MAX, 1) == u8::MIN);
    op_assign_test!(add_assign(u16::MAX, 1) == u16::MIN);
    op_assign_test!(add_assign(u32::MAX, 1) == u32::MIN);
    op_assign_test!(add_assign(u64::MAX, 1) == u64::MIN);
    op_assign_test!(add_assign(usize::MAX, 1) == usize::MIN);


    op_assign_test!(sub_assign(i8::MIN, 1) == i8::MAX);
    op_assign_test!(sub_assign(i16::MIN, 1) == i16::MAX);
    op_assign_test!(sub_assign(i32::MIN, 1) == i32::MAX);
    op_assign_test!(sub_assign(i64::MIN, 1) == i64::MAX);
    op_assign_test!(sub_assign(isize::MIN, 1) == isize::MAX);

    op_assign_test!(sub_assign(u8::MIN, 1) == u8::MAX);
    op_assign_test!(sub_assign(u16::MIN, 1) == u16::MAX);
    op_assign_test!(sub_assign(u32::MIN, 1) == u32::MAX);
    op_assign_test!(sub_assign(u64::MIN, 1) == u64::MAX);
    op_assign_test!(sub_assign(usize::MIN, 1) == usize::MAX);


    op_assign_test!(mul_assign(i8::MAX, 2) == -2);
    op_assign_test!(mul_assign(i16::MAX, 2) == -2);
    op_assign_test!(mul_assign(i32::MAX, 2) == -2);
    op_assign_test!(mul_assign(i64::MAX, 2) == -2);
    op_assign_test!(mul_assign(isize::MAX, 2) == -2);

    op_assign_test!(mul_assign(u8::MAX, 2) == u8::MAX - 1);
    op_assign_test!(mul_assign(u16::MAX, 2) == u16::MAX - 1);
    op_assign_test!(mul_assign(u32::MAX, 2) == u32::MAX - 1);
    op_assign_test!(mul_assign(u64::MAX, 2) == u64::MAX - 1);
    op_assign_test!(mul_assign(usize::MAX, 2) == usize::MAX - 1);


    op_assign_test!(div_assign(i8::MIN, -1) == i8::MIN);
    op_assign_test!(div_assign(i16::MIN, -1) == i16::MIN);
    op_assign_test!(div_assign(i32::MIN, -1) == i32::MIN);
    op_assign_test!(div_assign(i64::MIN, -1) == i64::MIN);
    op_assign_test!(div_assign(isize::MIN, -1) == isize::MIN);


    op_assign_test!(rem_assign(i8::MIN, -1) == 0);
    op_assign_test!(rem_assign(i16::MIN, -1) == 0);
    op_assign_test!(rem_assign(i32::MIN, -1) == 0);
    op_assign_test!(rem_assign(i64::MIN, -1) == 0);
    op_assign_test!(rem_assign(isize::MIN, -1) == 0);


    // these are not that interesting, just testing to make sure they are implemented correctly
    op_assign_test!(bitxor_assign(0b101010i8, 0b100110) == 0b001100);
    op_assign_test!(bitxor_assign(0b101010i16, 0b100110) == 0b001100);
    op_assign_test!(bitxor_assign(0b101010i32, 0b100110) == 0b001100);
    op_assign_test!(bitxor_assign(0b101010i64, 0b100110) == 0b001100);
    op_assign_test!(bitxor_assign(0b101010isize, 0b100110) == 0b001100);

    op_assign_test!(bitxor_assign(0b101010u8, 0b100110) == 0b001100);
    op_assign_test!(bitxor_assign(0b101010u16, 0b100110) == 0b001100);
    op_assign_test!(bitxor_assign(0b101010u32, 0b100110) == 0b001100);
    op_assign_test!(bitxor_assign(0b101010u64, 0b100110) == 0b001100);
    op_assign_test!(bitxor_assign(0b101010usize, 0b100110) == 0b001100);


    op_assign_test!(bitor_assign(0b101010i8, 0b100110) == 0b101110);
    op_assign_test!(bitor_assign(0b101010i16, 0b100110) == 0b101110);
    op_assign_test!(bitor_assign(0b101010i32, 0b100110) == 0b101110);
    op_assign_test!(bitor_assign(0b101010i64, 0b100110) == 0b101110);
    op_assign_test!(bitor_assign(0b101010isize, 0b100110) == 0b101110);

    op_assign_test!(bitor_assign(0b101010u8, 0b100110) == 0b101110);
    op_assign_test!(bitor_assign(0b101010u16, 0b100110) == 0b101110);
    op_assign_test!(bitor_assign(0b101010u32, 0b100110) == 0b101110);
    op_assign_test!(bitor_assign(0b101010u64, 0b100110) == 0b101110);
    op_assign_test!(bitor_assign(0b101010usize, 0b100110) == 0b101110);


    op_assign_test!(bitand_assign(0b101010i8, 0b100110) == 0b100010);
    op_assign_test!(bitand_assign(0b101010i16, 0b100110) == 0b100010);
    op_assign_test!(bitand_assign(0b101010i32, 0b100110) == 0b100010);
    op_assign_test!(bitand_assign(0b101010i64, 0b100110) == 0b100010);
    op_assign_test!(bitand_assign(0b101010isize, 0b100110) == 0b100010);

    op_assign_test!(bitand_assign(0b101010u8, 0b100110) == 0b100010);
    op_assign_test!(bitand_assign(0b101010u16, 0b100110) == 0b100010);
    op_assign_test!(bitand_assign(0b101010u32, 0b100110) == 0b100010);
    op_assign_test!(bitand_assign(0b101010u64, 0b100110) == 0b100010);
    op_assign_test!(bitand_assign(0b101010usize, 0b100110) == 0b100010);
}

fn test_sh_ops() {
    macro_rules! sh_test {
        ($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => {
            assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans));
        }
    }
    // NOTE: This will break for i8 if we ever get i/u128
    macro_rules! sh_test_all {
        ($t:ty) => {
            sh_test!(shl(i8::MAX, (i8::BITS + 1) as $t) == -2);
            sh_test!(shl(i16::MAX, (i16::BITS + 1) as $t) == -2);
            sh_test!(shl(i32::MAX, (i32::BITS + 1) as $t) == -2);
            sh_test!(shl(i64::MAX, (i64::BITS + 1) as $t) == -2);
            sh_test!(shl(isize::MAX, (isize::BITS + 1) as $t) == -2);

            sh_test!(shl(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX - 1);
            sh_test!(shl(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX - 1);
            sh_test!(shl(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX - 1);
            sh_test!(shl(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX - 1);
            sh_test!(shl(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX - 1);


            sh_test!(shr(i8::MAX, (i8::BITS + 1) as $t) == i8::MAX / 2);
            sh_test!(shr(i16::MAX, (i16::BITS + 1) as $t) == i16::MAX / 2);
            sh_test!(shr(i32::MAX, (i32::BITS + 1) as $t) == i32::MAX / 2);
            sh_test!(shr(i64::MAX, (i64::BITS + 1) as $t) == i64::MAX / 2);
            sh_test!(shr(isize::MAX, (isize::BITS + 1) as $t) == isize::MAX / 2);

            sh_test!(shr(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX / 2);
            sh_test!(shr(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX / 2);
            sh_test!(shr(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX / 2);
            sh_test!(shr(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX / 2);
            sh_test!(shr(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX / 2);
        }
    }
    macro_rules! sh_test_negative_all {
        ($t:ty) => {
            sh_test!(shr(i8::MAX, -((i8::BITS + 1) as $t)) == -2);
            sh_test!(shr(i16::MAX, -((i16::BITS + 1) as $t)) == -2);
            sh_test!(shr(i32::MAX, -((i32::BITS + 1) as $t)) == -2);
            sh_test!(shr(i64::MAX, -((i64::BITS + 1) as $t)) == -2);
            sh_test!(shr(isize::MAX, -((isize::BITS + 1) as $t)) == -2);

            sh_test!(shr(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX - 1);
            sh_test!(shr(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX - 1);
            sh_test!(shr(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX - 1);
            sh_test!(shr(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX - 1);
            sh_test!(shr(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX - 1);


            sh_test!(shl(i8::MAX, -((i8::BITS + 1) as $t)) == i8::MAX / 2);
            sh_test!(shl(i16::MAX, -((i16::BITS + 1) as $t)) == i16::MAX / 2);
            sh_test!(shl(i32::MAX, -((i32::BITS + 1) as $t)) == i32::MAX / 2);
            sh_test!(shl(i64::MAX, -((i64::BITS + 1) as $t)) == i64::MAX / 2);
            sh_test!(shl(isize::MAX, -((isize::BITS + 1) as $t)) == isize::MAX / 2);

            sh_test!(shl(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX / 2);
            sh_test!(shl(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX / 2);
            sh_test!(shl(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX / 2);
            sh_test!(shl(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX / 2);
            sh_test!(shl(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX / 2);
        }
    }
    // FIXME(#23545): Uncomment the remaining tests
    //sh_test_all!(i8);
    //sh_test_all!(u8);
    //sh_test_all!(i16);
    //sh_test_all!(u16);
    //sh_test_all!(i32);
    //sh_test_all!(u32);
    //sh_test_all!(i64);
    //sh_test_all!(u64);
    //sh_test_all!(isize);
    sh_test_all!(usize);

    //sh_test_negative_all!(i8);
    //sh_test_negative_all!(i16);
    //sh_test_negative_all!(i32);
    //sh_test_negative_all!(i64);
    //sh_test_negative_all!(isize);
}

fn test_sh_op_assigns() {
    macro_rules! sh_assign_test {
        ($op:ident ($initial:expr, $rhs:expr) == $ans:expr) => {{
            let mut tmp = Wrapping($initial);
            tmp = black_box(tmp);
            tmp.$op($rhs);
            assert_eq!(black_box(tmp), Wrapping($ans));
        }}
    }
    macro_rules! sh_assign_test_all {
        ($t:ty) => {
            sh_assign_test!(shl_assign(i8::MAX, (i8::BITS + 1) as $t) == -2);
            sh_assign_test!(shl_assign(i16::MAX, (i16::BITS + 1) as $t) == -2);
            sh_assign_test!(shl_assign(i32::MAX, (i32::BITS + 1) as $t) == -2);
            sh_assign_test!(shl_assign(i64::MAX, (i64::BITS + 1) as $t) == -2);
            sh_assign_test!(shl_assign(isize::MAX, (isize::BITS + 1) as $t) == -2);

            sh_assign_test!(shl_assign(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX - 1);
            sh_assign_test!(shl_assign(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX - 1);
            sh_assign_test!(shl_assign(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX - 1);
            sh_assign_test!(shl_assign(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX - 1);
            sh_assign_test!(shl_assign(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX - 1);


            sh_assign_test!(shr_assign(i8::MAX, (i8::BITS + 1) as $t) == i8::MAX / 2);
            sh_assign_test!(shr_assign(i16::MAX, (i16::BITS + 1) as $t) == i16::MAX / 2);
            sh_assign_test!(shr_assign(i32::MAX, (i32::BITS + 1) as $t) == i32::MAX / 2);
            sh_assign_test!(shr_assign(i64::MAX, (i64::BITS + 1) as $t) == i64::MAX / 2);
            sh_assign_test!(shr_assign(isize::MAX, (isize::BITS + 1) as $t) == isize::MAX / 2);

            sh_assign_test!(shr_assign(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX / 2);
            sh_assign_test!(shr_assign(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX / 2);
            sh_assign_test!(shr_assign(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX / 2);
            sh_assign_test!(shr_assign(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX / 2);
            sh_assign_test!(shr_assign(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX / 2);
        }
    }
    macro_rules! sh_assign_test_negative_all {
        ($t:ty) => {
            sh_assign_test!(shr_assign(i8::MAX, -((i8::BITS + 1) as $t)) == -2);
            sh_assign_test!(shr_assign(i16::MAX, -((i16::BITS + 1) as $t)) == -2);
            sh_assign_test!(shr_assign(i32::MAX, -((i32::BITS + 1) as $t)) == -2);
            sh_assign_test!(shr_assign(i64::MAX, -((i64::BITS + 1) as $t)) == -2);
            sh_assign_test!(shr_assign(isize::MAX, -((isize::BITS + 1) as $t)) == -2);

            sh_assign_test!(shr_assign(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX - 1);
            sh_assign_test!(shr_assign(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX - 1);
            sh_assign_test!(shr_assign(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX - 1);
            sh_assign_test!(shr_assign(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX - 1);
            sh_assign_test!(shr_assign(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX - 1);


            sh_assign_test!(shl_assign(i8::MAX, -((i8::BITS + 1) as $t)) == i8::MAX / 2);
            sh_assign_test!(shl_assign(i16::MAX, -((i16::BITS + 1) as $t)) == i16::MAX / 2);
            sh_assign_test!(shl_assign(i32::MAX, -((i32::BITS + 1) as $t)) == i32::MAX / 2);
            sh_assign_test!(shl_assign(i64::MAX, -((i64::BITS + 1) as $t)) == i64::MAX / 2);
            sh_assign_test!(shl_assign(isize::MAX, -((isize::BITS + 1) as $t)) == isize::MAX / 2);

            sh_assign_test!(shl_assign(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX / 2);
            sh_assign_test!(shl_assign(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX / 2);
            sh_assign_test!(shl_assign(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX / 2);
            sh_assign_test!(shl_assign(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX / 2);
            sh_assign_test!(shl_assign(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX / 2);
        }
    }

    // FIXME(#23545): Uncomment the remaining tests
    //sh_assign_test_all!(i8);
    //sh_assign_test_all!(u8);
    //sh_assign_test_all!(i16);
    //sh_assign_test_all!(u16);
    //sh_assign_test_all!(i32);
    //sh_assign_test_all!(u32);
    //sh_assign_test_all!(i64);
    //sh_assign_test_all!(u64);
    //sh_assign_test_all!(isize);
    sh_assign_test_all!(usize);

    //sh_assign_test_negative_all!(i8);
    //sh_assign_test_negative_all!(i16);
    //sh_assign_test_negative_all!(i32);
    //sh_assign_test_negative_all!(i64);
    //sh_assign_test_negative_all!(isize);
}