From 9edeb4a1b39e84dc9a5b9b5e5782b3404a049509 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Fri, 19 Sep 2025 17:07:23 +0200 Subject: [PATCH 1/2] test: add tests to increase code coverage --- test/runtests.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 57d1c9c..fc2f0ae 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -13,6 +13,16 @@ using Test end @testset "basic" begin @test sin(0.3) === @inferred Fix1(sin, 0.3)() + @test (7 - 3) === @inferred Fix1(-, 7)(3) + @test (7 - 3) === @inferred Fix2(-, 3)(7) + end + @testset "invalid `N`" begin + for N ∈ (-1, 0, true) + @test_throws ArgumentError Fix{N}(+, 7) + end + end + @testset "too few arguments in call" begin + @test_throws ArgumentError Fix{10}(Returns(nothing), 7)(1, 2, 3) end end From 07a8fd9d6232cb5bd6dd9272fefdad72d6562b18 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Fri, 19 Sep 2025 17:16:00 +0200 Subject: [PATCH 2/2] adjust exception type --- src/FixFunctionArgument.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/FixFunctionArgument.jl b/src/FixFunctionArgument.jl index 449f229..cc0d185 100644 --- a/src/FixFunctionArgument.jl +++ b/src/FixFunctionArgument.jl @@ -17,10 +17,17 @@ module FixFunctionArgument @noinline function throw_too_few_args() throw(ArgumentError("too few positional arguments given in call of a `Fix`")) end + @noinline function throw_not_int() + throw(ArgumentError("the type parameter `N` must be an `Int`")) + end @noinline function throw_not_positive() throw(ArgumentError("the type parameter `N` must be greater than zero")) end - @inline function check_positive(n::Int) + @inline function check_positive(n) + if !(n isa Int) + throw_not_int() + end + n = n::Int if n < 1 throw_not_positive() end