@@ -779,17 +779,11 @@ end
779779 @testset " limits: with_overflow math" begin
780780 # Easy to reason about cases of overflow:
781781 @test Base. Checked. add_with_overflow (FD {Int8,2} (1 ), FD {Int8,2} (1 )) == (FD {Int8,2} (- 0.56 ), true )
782- @test Base. Checked. add_with_overflow (FD {Int8,2} (1 ), 1 ) == (FD {Int8,2} (- 0.56 ), true )
782+ @test Base. Checked. add_with_overflow (FD {Int8,2} (1 ), FD {Int8,2} ( 1 ) ) == (FD {Int8,2} (- 0.56 ), true )
783783 @test Base. Checked. add_with_overflow (FD {Int8,2} (1 ), FD {Int8,2} (0.4 )) == (FD {Int8,2} (- 1.16 ), true )
784-
785784 @test Base. Checked. sub_with_overflow (FD {Int8,2} (1 ), FD {Int8,2} (- 1 )) == (FD {Int8,2} (- 0.56 ), true )
786- @test Base. Checked. sub_with_overflow (1 , FD {Int8,2} (- 1 )) == (FD {Int8,2} (- 0.56 ), true )
787785 @test Base. Checked. sub_with_overflow (FD {Int8,2} (- 1 ), FD {Int8,2} (0.4 )) == (FD {Int8,2} (1.16 ), true )
788-
789786 @test Base. Checked. mul_with_overflow (FD {Int8,2} (1.2 ), FD {Int8,2} (1.2 )) == (FD {Int8,2} (- 1.12 ), true )
790- @test Base. Checked. mul_with_overflow (FD {Int8,1} (12 ), 2 ) == (FD {Int8,1} (- 1.6 ), true )
791- @test Base. Checked. mul_with_overflow (FD {Int8,0} (120 ), 2 ) == (FD {Int8,0} (- 16 ), true )
792- @test Base. Checked. mul_with_overflow (120 , FD {Int8,0} (2 )) == (FD {Int8,0} (- 16 ), true )
793787
794788 @test div_with_overflow (FD {Int8,2} (1 ), FD {Int8,2} (0.5 )) == (FD {Int8,2} (- 0.56 ), true )
795789 @test div_with_overflow (typemin (FD{Int32,0 }), FD {Int32,0} (- 1 )) == (typemin (FD{Int32,0 }), true )
@@ -802,23 +796,23 @@ end
802796
803797 @test Base. Checked. add_with_overflow (typemax (T), eps (T)) == (typemax (T) + eps (T), true )
804798 issigned (I) && @test Base. Checked. add_with_overflow (typemin (T), - eps (T)) == (typemin (T) + - eps (T), true )
805- @test Base. Checked. add_with_overflow (typemax (T), 1 ) == (typemax (T) + 1 , true )
806- @test Base. Checked. add_with_overflow (1 , typemax (T)) == (typemax (T) + 1 , true )
799+ @test Base. Checked. add_with_overflow (typemax (T), T ( 1 ) ) == (typemax (T) + 1 , true )
800+ @test Base. Checked. add_with_overflow (T ( 1 ) , typemax (T)) == (typemax (T) + 1 , true )
807801
808802 @test Base. Checked. sub_with_overflow (typemin (T), eps (T)) == (typemin (T) - eps (T), true )
809803 issigned (I) && @test Base. Checked. sub_with_overflow (typemax (T), - eps (T)) == (typemax (T) - - eps (T), true )
810- @test Base. Checked. sub_with_overflow (typemin (T), 1 ) == (typemin (T) - 1 , true )
804+ @test Base. Checked. sub_with_overflow (typemin (T), T ( 1 ) ) == (typemin (T) - 1 , true )
811805 if issigned (I) && 2.0 <= typemax (T)
812- @test Base. Checked. sub_with_overflow (- 2 , typemax (T)) == (- 2 - typemax (T), true )
806+ @test Base. Checked. sub_with_overflow (T ( - 2 ) , typemax (T)) == (- 2 - typemax (T), true )
813807 end
814808
815809 @test Base. Checked. mul_with_overflow (typemax (T), typemax (T)) == (typemax (T) * typemax (T), true )
816810 issigned (I) && @test Base. Checked. mul_with_overflow (typemin (T), typemax (T)) == (typemin (T) * typemax (T), true )
817811 if 2.0 <= typemax (T)
818- @test Base. Checked. mul_with_overflow (typemax (T), 2 ) == (typemax (T) * 2 , true )
819- @test Base. Checked. mul_with_overflow (2 , typemax (T)) == (2 * typemax (T), true )
820- issigned (I) && @test Base. Checked. mul_with_overflow (typemin (T), 2 ) == (typemin (T) * 2 , true )
821- issigned (I) && @test Base. Checked. mul_with_overflow (2 , typemin (T)) == (2 * typemin (T), true )
812+ @test Base. Checked. mul_with_overflow (typemax (T), T ( 2 ) ) == (typemax (T) * 2 , true )
813+ @test Base. Checked. mul_with_overflow (T ( 2 ) , typemax (T)) == (2 * typemax (T), true )
814+ issigned (I) && @test Base. Checked. mul_with_overflow (typemin (T), T ( 2 ) ) == (typemin (T) * 2 , true )
815+ issigned (I) && @test Base. Checked. mul_with_overflow (T ( 2 ) , typemin (T)) == (2 * typemin (T), true )
822816 end
823817
824818 if f > 0
@@ -833,36 +827,21 @@ end
833827 end
834828 end
835829
836- @testset " with_overflow math promotions" begin
837- x = FD {Int8,1} (1 )
838- y = FD {Int64,1} (2 )
839- @testset for op in (
840- Base. Checked. add_with_overflow, Base. Checked. sub_with_overflow,
841- Base. Checked. mul_with_overflow,
842- )
843- @test op (x, y) === op (FD {Int64,1} (1 ), y)
844- @test op (y, x) === op (y, FD {Int64,1} (1 ))
845-
846- @test op (x, 2 ) === op (x, FD {Int8,1} (2 ))
847- @test op (2 , x) === op (FD {Int8,1} (2 ), x)
848- end
849- end
850-
851830 @testset " non-overflowing with_overflow math" begin
852- @test Base. Checked. add_with_overflow (1 , FD {Int8,1} (1.1 )) == (FD {Int8,1} (2.1 ), false )
853- @test Base. Checked. add_with_overflow (FD {Int8,1} (1.1 ), 1 ) == (FD {Int8,1} (2.1 ), false )
831+ @test Base. Checked. add_with_overflow (FD {Int8,1} ( 1 ) , FD {Int8,1} (1.1 )) == (FD {Int8,1} (2.1 ), false )
832+ @test Base. Checked. add_with_overflow (FD {Int8,1} (1.1 ), FD {Int8,1} ( 1 ) ) == (FD {Int8,1} (2.1 ), false )
854833 @test Base. Checked. add_with_overflow (FD {Int64,8} (30.123 ), FD {Int64,8} (30 )) == (FD {Int64,8} (60.123 ), false )
855- @test Base. Checked. add_with_overflow (FD {Int64,8} (30.123 ), FD {Int64,5} ( 30 )) == (FD {Int64,8} (60.123 ), false )
834+ @test Base. Checked. add_with_overflow (FD {Int64,8} (30.123 ), FD {Int64,8} ( - 50 )) == (FD {Int64,8} (- 19.877 ), false )
856835
857- @test Base. Checked. sub_with_overflow (3 , FD {Int16,2} (2.5 )) == (FD {Int16,1} (0.5 ), false )
858- @test Base. Checked. sub_with_overflow (FD {Int16,2} (2.5 ), 3 ) == (FD {Int16,1} (- 0.5 ), false )
836+ @test Base. Checked. sub_with_overflow (FD {Int16,2} ( 3 ) , FD {Int16,2} (2.5 )) == (FD {Int16,1} (0.5 ), false )
837+ @test Base. Checked. sub_with_overflow (FD {Int16,2} (2.5 ), FD {Int16,2} ( 3 ) ) == (FD {Int16,1} (- 0.5 ), false )
859838 @test Base. Checked. sub_with_overflow (FD {Int32,4} (10.11 ), FD {Int32,4} (2 )) == (FD {Int32,4} (8.11 ), false )
860- @test Base. Checked. sub_with_overflow (FD {Int32,4} (10.11 ), FD {Int32,3} ( 2 )) == (FD {Int32,4} (8 .11 ), false )
839+ @test Base. Checked. sub_with_overflow (FD {Int32,4} (10.11 ), FD {Int32,4} ( - 2 )) == (FD {Int32,4} (12 .11 ), false )
861840
862- @test Base. Checked. mul_with_overflow (4 , FD {Int64,6} (2.22 )) == (FD {Int64,6} (8.88 ), false )
863- @test Base. Checked. mul_with_overflow (FD {Int64,6} (2.22 ), 4 ) == (FD {Int64,6} (8.88 ), false )
841+ @test Base. Checked. mul_with_overflow (FD {Int64,6} ( 4 ) , FD {Int64,6} (2.22 )) == (FD {Int64,6} (8.88 ), false )
842+ @test Base. Checked. mul_with_overflow (FD {Int64,6} (2.22 ), FD {Int64,6} ( 4 ) ) == (FD {Int64,6} (8.88 ), false )
864843 @test Base. Checked. mul_with_overflow (FD {Int128,14} (10 ), FD {Int128,14} (20.1 )) == (FD {Int128,14} (201 ), false )
865- @test Base. Checked. mul_with_overflow (FD {Int128,30} (10.11 ), FD {Int128,0 } (1 )) == (FD {Int128,30} (10.11 ), false )
844+ @test Base. Checked. mul_with_overflow (FD {Int128,30} (10.1 ), FD {Int128,30 } (1 )) == (FD {Int128,30} (10.1 ), false )
866845
867846 @test div_with_overflow (FD {Int64,6} (4 ), FD {Int64,6} (2 )) == (FD {Int64,6} (2 ), false )
868847 @test div_with_overflow (FD {Int32,6} (4 ), FD {Int32,6} (2.1 )) == (FD {Int32,6} (1 ), false )
0 commit comments