@@ -55,37 +55,37 @@ using Random
55
55
end
56
56
end
57
57
@testset " signed and unsigned" begin
58
- @test signed (3 ) == 3
59
- @test signed (UInt (3 )) == 3
58
+ @test signed (3 ) === 3
59
+ @test signed (UInt (3 )) === 3
60
60
@test isa (signed (UInt (3 )), Int)
61
- @test signed (UInt (0 ) - 1 ) == - 1
61
+ @test signed (UInt (0 ) - 1 ) === - 1
62
62
@test_throws InexactError signed (UInt (- 3 ))
63
- @test signed (true ) == 1
63
+ @test signed (true ) === 1
64
64
@test unsigned (true ) isa Unsigned
65
- @test unsigned (true ) == unsigned (1 )
65
+ @test unsigned (true ) === unsigned (1 )
66
66
67
- @test signed (Bool) == Int
68
- @test signed (Bool) == typeof (signed (true ))
69
- @test unsigned (Bool) == UInt
70
- @test unsigned (Bool) == typeof (unsigned (true ))
67
+ @test signed (Bool) === Int
68
+ @test signed (Bool) === typeof (signed (true ))
69
+ @test unsigned (Bool) === UInt
70
+ @test unsigned (Bool) === typeof (unsigned (true ))
71
71
end
72
72
@testset " bswap" begin
73
73
@test bswap (Int8 (3 )) == 3
74
- @test bswap (UInt8 (3 )) == 3
74
+ @test bswap (UInt8 (3 )) === 0x3
75
75
@test bswap (Int16 (3 )) == 256 * 3
76
76
@test bswap (Int16 (256 )) == 1
77
77
@test bswap (Int16 (257 )) == 257
78
78
@test bswap (Int32 (1 )) == 2 ^ (3 * 8 )
79
79
@test bswap (Int32 (2 )^ (3 * 8 )) == 1
80
- @test bswap (Int64 (1 )) == Int64 (2 )^ (7 * 8 )
80
+ @test bswap (Int64 (1 )) === Int64 (2 )^ (7 * 8 )
81
81
@test bswap (Int64 (2 )^ (7 * 8 )) == 1
82
- @test bswap (Int128 (1 )) == Int128 (2 )^ (15 * 8 )
83
- @test bswap (Int128 (2 )^ (15 * 8 )) == Int128 (1 )
84
- @test bswap (UInt128 (2 )^ (15 * 8 )) == UInt128 (1 )
82
+ @test bswap (Int128 (1 )) === Int128 (2 )^ (15 * 8 )
83
+ @test bswap (Int128 (2 )^ (15 * 8 )) === Int128 (1 )
84
+ @test bswap (UInt128 (2 )^ (15 * 8 )) === UInt128 (1 )
85
85
end
86
86
@testset " count_zeros" begin
87
- @test count_zeros (10 ) == Sys. WORD_SIZE - 2
88
- @test count_zeros (UInt8 (10 )) == 6
87
+ @test count_zeros (10 ) === Sys. WORD_SIZE - 2
88
+ @test count_zeros (UInt8 (10 )) === 6
89
89
end
90
90
@testset " Conversions" begin
91
91
@test convert (Signed, UInt128 (3 )) === Int128 (3 )
@@ -104,11 +104,11 @@ end
104
104
end
105
105
106
106
@testset " trunc, floor, ceil" begin
107
- @test trunc (3 ) == 3
108
- @test trunc (Integer, 3 ) == 3
107
+ @test trunc (3 ) === 3
108
+ @test trunc (Integer, 3 ) === 3
109
109
110
- @test floor (3 ) == 3
111
- @test ceil (3 ) == 3
110
+ @test floor (3 ) === 3
111
+ @test ceil (3 ) === 3
112
112
end
113
113
114
114
@testset " big" begin
@@ -120,10 +120,11 @@ end
120
120
end
121
121
122
122
@test round (UInt8, 123 ) == 123
123
- @test mod (123 , UInt8) == 0x7b
123
+ @test mod (123 , UInt8) === 0x7b
124
124
125
- primitive type MyBitsType <: Integer 8 end
125
+ primitive type MyBitsType <: Signed 8 end
126
126
@test_throws MethodError ~ reinterpret (MyBitsType, 0x7b )
127
+ @test signed (MyBitsType) === MyBitsType
127
128
128
129
UItypes = Base. BitUnsigned_types
129
130
SItypes = Base. BitSigned_types
211
212
end
212
213
213
214
val2 = 0xabcd
214
- @test 0x5e6d == bitrotate (val2, 3 )
215
- @test 0xb579 == bitrotate (val2, - 3 )
215
+ @test 0x5e6d === bitrotate (val2, 3 )
216
+ @test 0xb579 === bitrotate (val2, - 3 )
216
217
end
217
218
218
219
@testset " widen/widemul" begin
@@ -240,12 +241,12 @@ end
240
241
@test typeof (widen (Int64 (- 3 ))) == Int128
241
242
@test typeof (widen (Int128 (- 3 ))) == BigInt
242
243
243
- @test widemul (false , false ) == false
244
- @test widemul (false , 3 ) == 0
245
- @test widemul (3 , true ) == widemul (true , 3 ) == 3
244
+ @test widemul (false , false ) === false
245
+ @test widemul (false , 3 ) === 0
246
+ @test widemul (3 , true ) === widemul (true , 3 ) = == 3
246
247
247
248
let i= Int64 (2 )^ 63 - 1 , k= widemul (i,i)
248
- @test widemul (i,i)== 85070591730234615847396907784232501249
249
+ @test widemul (i,i)=== 85070591730234615847396907784232501249
249
250
j= div (k,2 )
250
251
@test div (k,j)== 2
251
252
j= div (k,5 )
@@ -367,17 +368,17 @@ end
367
368
(5 , - 3 , - 2 , - 2 , - 2 ))
368
369
for sign in (+ 1 , - 1 )
369
370
(a, b) = (a* sign, b* sign)
370
- @test div (a, b, RoundNearest) == nearest
371
- @test div (a, b, RoundNearestTiesAway) == away
372
- @test div (a, b, RoundNearestTiesUp) == up
371
+ @test div (a, b, RoundNearest) === nearest
372
+ @test div (a, b, RoundNearestTiesAway) === away
373
+ @test div (a, b, RoundNearestTiesUp) === up
373
374
end
374
375
end
375
376
376
377
@test div (typemax (Int64), typemax (Int64)- 1 , RoundNearest) == 1
377
378
@test div (- typemax (Int64), typemax (Int64)- 1 , RoundNearest) == - 1
378
379
@test div (typemax (Int64), 2 , RoundNearest) == 4611686018427387904
379
380
@test div (- typemax (Int64), 2 , RoundNearestTiesUp) == - 4611686018427387903
380
- @test div (typemax (Int)- 2 , typemax (Int), RoundNearest) == 1
381
+ @test div (typemax (Int)- 2 , typemax (Int), RoundNearest) === 1
381
382
382
383
# Exhaustively test (U)Int8 to catch any overflow-style issues
383
384
for r in (RoundNearest, RoundNearestTiesAway, RoundNearestTiesUp)
@@ -407,25 +408,32 @@ end
407
408
end
408
409
409
410
@testset " min/max of datatype" begin
410
- @test typemin (Int8) == Int8 (- 128 )
411
- @test typemin (UInt8) == UInt8 (0 )
412
- @test typemin (Int16) == Int16 (- 32768 )
413
- @test typemin (UInt16) == UInt16 (0 )
414
- @test typemin (Int32) == Int32 (- 2147483648 )
415
- @test typemin (UInt32) == UInt32 (0 )
416
- @test typemin (Int64) == Int64 (- 9223372036854775808 )
417
- @test typemin (UInt64) == UInt64 (0 )
418
- @test typemin (Int128) == Int128 (- 170141183460469231731687303715884105728 )
419
- @test typemin (UInt128) == UInt128 (0 )
420
-
421
- @test typemax (Int8) == Int8 (127 )
422
- @test typemax (UInt8) == UInt8 (255 )
423
- @test typemax (Int16) == Int16 (32767 )
424
- @test typemax (UInt16) == UInt16 (65535 )
425
- @test typemax (Int32) == Int32 (2147483647 )
426
- @test typemax (UInt32) == UInt32 (4294967295 )
427
- @test typemax (Int64) == Int64 (9223372036854775807 )
428
- @test typemax (UInt64) == UInt64 (0xffffffffffffffff )
429
- @test typemax (Int128) == Int128 (170141183460469231731687303715884105727 )
430
- @test typemax (UInt128) == UInt128 (0xffffffffffffffffffffffffffffffff )
411
+ @test typemin (Int8) === Int8 (- 128 )
412
+ @test typemin (UInt8) === UInt8 (0 )
413
+ @test typemin (Int16) === Int16 (- 32768 )
414
+ @test typemin (UInt16) === UInt16 (0 )
415
+ @test typemin (Int32) === Int32 (- 2147483648 )
416
+ @test typemin (UInt32) === UInt32 (0 )
417
+ @test typemin (Int64) === Int64 (- 9223372036854775808 )
418
+ @test typemin (UInt64) === UInt64 (0 )
419
+ @test typemin (Int128) === Int128 (- 170141183460469231731687303715884105728 )
420
+ @test typemin (UInt128) === UInt128 (0 )
421
+
422
+ @test typemax (Int8) === Int8 (127 )
423
+ @test typemax (UInt8) === UInt8 (255 )
424
+ @test typemax (Int16) === Int16 (32767 )
425
+ @test typemax (UInt16) === UInt16 (65535 )
426
+ @test typemax (Int32) === Int32 (2147483647 )
427
+ @test typemax (UInt32) === UInt32 (4294967295 )
428
+ @test typemax (Int64) === Int64 (9223372036854775807 )
429
+ @test typemax (UInt64) === UInt64 (0xffffffffffffffff )
430
+ @test typemax (Int128) === Int128 (170141183460469231731687303715884105727 )
431
+ @test typemax (UInt128) === UInt128 (0xffffffffffffffffffffffffffffffff )
432
+ end
433
+
434
+ @testset " BitIntegerType" begin
435
+ @test Int isa Base. BitIntegerType
436
+ @test Base. BitIntegerType === Union{
437
+ Type{ Int8}, Type{ Int16}, Type{ Int32}, Type{ Int64}, Type{ Int128},
438
+ Type{UInt8}, Type{UInt16}, Type{UInt32}, Type{UInt64}, Type{UInt128}}
431
439
end
0 commit comments