@@ -2813,3 +2813,45 @@ end
28132813 @test_throws MethodError fld (a, b)
28142814 @test_throws MethodError cld (a, b)
28152815end
2816+
2817+ @testset " Bool rounding (#25074)" begin
2818+ @testset " round Bool" begin
2819+ @test_throws InexactError round (Bool, - 4.1 )
2820+ @test_throws InexactError round (Bool, 1.5 )
2821+ @test true == round (Bool, 1.0 )
2822+ @test false == round (Bool, 0.0 )
2823+ @test true == round (Bool, 0.6 )
2824+ @test false == round (Bool, 0.4 )
2825+ @test false == round (Bool, 0.5 )
2826+ @test false == round (Bool, - 0.5 )
2827+ end
2828+
2829+ @testset " trunc Bool" begin
2830+ @test_throws InexactError trunc (Bool, - 4.1 )
2831+ @test_throws InexactError trunc (Bool, 2.5 )
2832+ @test true == trunc (Bool, 1.0 )
2833+ @test false == trunc (Bool, 0.0 )
2834+ @test false == trunc (Bool, 0.6 )
2835+ @test false == trunc (Bool, 0.4 )
2836+ @test true == trunc (Bool, 1.8 )
2837+ @test false == trunc (Bool, - 0.5 )
2838+ end
2839+
2840+ @testset " floor Bool" begin
2841+ @test_throws InexactError floor (Bool, - 0.1 )
2842+ @test_throws InexactError floor (Bool, 2.5 )
2843+ @test true == floor (Bool, 1.0 )
2844+ @test false == floor (Bool, 0.0 )
2845+ @test false == floor (Bool, 0.6 )
2846+ @test true == floor (Bool, 1.8 )
2847+ end
2848+
2849+ @testset " ceil Bool" begin
2850+ @test_throws InexactError ceil (Bool, - 1.4 )
2851+ @test_throws InexactError ceil (Bool, 1.5 )
2852+ @test true == ceil (Bool, 1.0 )
2853+ @test false == ceil (Bool, 0.0 )
2854+ @test true == ceil (Bool, 0.6 )
2855+ @test false == ceil (Bool, - 0.7 )
2856+ end
2857+ end
0 commit comments