From 08e3f76213f6404a3c8f6ab52dd64bf16d0ab712 Mon Sep 17 00:00:00 2001 From: kimikage Date: Wed, 14 Oct 2026 19:27:05 +0900 Subject: [PATCH] Mark tests for `sign` that do not behave as expected as `_broken` --- test/common.jl | 12 ++++++++++++ test/fixed.jl | 10 ++++------ test/normed.jl | 10 ++++------ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/test/common.jl b/test/common.jl index 3a04608..2f52ec0 100644 --- a/test/common.jl +++ b/test/common.jl @@ -375,6 +375,18 @@ function test_clamp_nan(TX::Type) end end +function test_sign_related(TX::Type) + for X in target(TX, :i8; ex = :thin) + # `FixedPoint` is not a signed or unsigned integer type + @test_throws Exception signed(X) + @test_throws Exception signed(X(0.5)) + @test_throws Exception unsigned(X) + @test_throws Exception unsigned(X(0.5)) + + @test signbit(X(0.5)) === signbit(X(0.0)) === false + end +end + function test_isinteger(TX::Type) @testset "isinteger(::$X)" for X in target(TX, :i8, :i16) xs = typemin(X):eps(X):typemax(X) diff --git a/test/fixed.jl b/test/fixed.jl index bcfce6d..baa4c3a 100644 --- a/test/fixed.jl +++ b/test/fixed.jl @@ -614,19 +614,17 @@ end end @testset "sign-related functions" begin - @test_throws Exception signed(Q0f7) - @test_throws Exception signed(0.5Q0f7) - @test_throws Exception unsigned(Q0f7) - @test_throws Exception unsigned(0.5Q0f7) + test_sign_related(Fixed) + @test copysign(0.5Q0f7, 0x1) === 0.5Q0f7 @test copysign(0.5Q0f7, -1) === -0.5Q0f7 @test flipsign(0.5Q0f7, 0x1) === 0.5Q0f7 @test flipsign(0.5Q0f7, -1) === -0.5Q0f7 - @test_throws ArgumentError sign(0Q0f7) + @test_broken sign(0Q0f7) === zero(Q0f7) + @test_throws ArgumentError sign(0.5Q0f7) @test sign(0Q1f6) === 0Q1f6 @test sign(0.5Q1f6) === 1Q1f6 @test sign(-0.5Q1f6) === -1Q1f6 - @test signbit(0.5Q0f7) === false @test signbit(-0.5Q0f7) === true end diff --git a/test/normed.jl b/test/normed.jl index 03f73fa..8c1010a 100644 --- a/test/normed.jl +++ b/test/normed.jl @@ -596,16 +596,14 @@ end end @testset "sign-related functions" begin - @test_throws Exception signed(N0f8) - @test_throws Exception signed(1N0f8) - @test_throws Exception unsigned(N0f8) - @test_throws Exception unsigned(1N0f8) + test_sign_related(Normed) + @test_throws ArgumentError copysign(1N0f8, 0x1) @test_throws ArgumentError copysign(1N0f8, -1) @test_throws ArgumentError flipsign(1N0f8, 0x1) @test_throws ArgumentError flipsign(1N0f8, -1) - @test_throws ArgumentError sign(0N0f8) - @test signbit(1N0f8) === false + @test_broken sign(0N0f8) === zero(N0f8) + @test_broken sign(0.5N0f8) === oneunit(N0f8) end @testset "bitwise" begin