Skip to content

Commit ac4a5fe

Browse files
Merge branch 'master' into interface-check-20251230-062428
2 parents 1e6b572 + c440b8b commit ac4a5fe

3 files changed

Lines changed: 58 additions & 1 deletion

File tree

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
77
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
88

99
[compat]
10+
AllocCheck = "0.2"
1011
Aqua = "0.8"
1112
Distributions = "0.25"
1213
ExplicitImports = "1.14.0"
@@ -18,6 +19,7 @@ Test = "1"
1819
julia = "1.10"
1920

2021
[extras]
22+
AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a"
2123
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
2224
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
2325
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
@@ -26,4 +28,4 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
2628
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2729

2830
[targets]
29-
test = ["Aqua", "Statistics", "Test", "Distributions", "JET", "ExplicitImports"]
31+
test = ["AllocCheck", "Aqua", "Statistics", "Test", "Distributions", "JET", "ExplicitImports"]

test/alloc_tests.jl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using AllocCheck
2+
using PoissonRandom
3+
using Random
4+
5+
@testset "AllocCheck - Zero Allocations" begin
6+
@testset "count_rand" begin
7+
@check_allocs function test_count_rand(rng::TaskLocalRNG, λ::Float64)
8+
PoissonRandom.count_rand(rng, λ)
9+
end
10+
rng = Random.default_rng()
11+
@test test_count_rand(rng, 2.0) isa Int
12+
@test test_count_rand(rng, 5.0) isa Int
13+
end
14+
15+
@testset "ad_rand" begin
16+
@check_allocs function test_ad_rand(rng::TaskLocalRNG, λ::Float64)
17+
PoissonRandom.ad_rand(rng, λ)
18+
end
19+
rng = Random.default_rng()
20+
@test test_ad_rand(rng, 10.0) isa Int
21+
@test test_ad_rand(rng, 50.0) isa Int
22+
end
23+
24+
@testset "pois_rand" begin
25+
@check_allocs function test_pois_rand(rng::TaskLocalRNG, λ::Float64)
26+
pois_rand(rng, λ)
27+
end
28+
rng = Random.default_rng()
29+
@test test_pois_rand(rng, 2.0) isa Int
30+
@test test_pois_rand(rng, 10.0) isa Int
31+
end
32+
33+
@testset "pois_rand with PassthroughRNG" begin
34+
@check_allocs function test_pois_rand_passthrough(rng::PassthroughRNG, λ::Float64)
35+
pois_rand(rng, λ)
36+
end
37+
passthrough = PassthroughRNG()
38+
@test test_pois_rand_passthrough(passthrough, 2.0) isa Int
39+
@test test_pois_rand_passthrough(passthrough, 10.0) isa Int
40+
end
41+
42+
@testset "procf" begin
43+
@check_allocs function test_procf::Float64, K::Int, s::Float64)
44+
PoissonRandom.procf(λ, K, s)
45+
end
46+
@test test_procf(10.0, 5, 3.162) isa NTuple{4, Float64}
47+
@test test_procf(10.0, 15, 3.162) isa NTuple{4, Float64}
48+
end
49+
end

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,9 @@ end
113113
@test abs(sample_mean - Float64(λ)) < 3 * sqrt(Float64(λ))
114114
end
115115
end
116+
117+
if get(ENV, "GROUP", "all") == "all" || get(ENV, "GROUP", "all") == "nopre"
118+
@testset "Allocation Tests" begin
119+
include("alloc_tests.jl")
120+
end
121+
end

0 commit comments

Comments
 (0)