From 877460e8f184a457dccb61156ded031b195bdd8e Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Tue, 26 May 2026 16:54:08 -0400 Subject: [PATCH] Drop brittle == 7 in Point Mutation test for Julia 1.11+ compat The test in test/mutations.jl asserts `length(ex) == length(mex) == 7`, but the `== 7` was the tree length on Julia 1.10 only. Julia 1.11 reimplemented `rand(::AbstractRNG, ::Dict/Set/KeySet)` with a more efficient algorithm that consumes the RNG stream differently, so `rand(rng, tr, H)` in src/gp.jl produces a different-length tree on 1.11+ even with StableRNG (StableRNGs stabilizes the raw RNG number stream, not how Base's collection sampling consumes it). The behavioral invariant being tested is that point mutation preserves the node count of the input expression, which `length(ex) == length(mex)` already captures. Drop the hard-coded `== 7`. Verified locally: tests pass on both Julia 1.10.11 and 1.12.6. Co-Authored-By: Chris Rackauckas --- test/mutations.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/mutations.jl b/test/mutations.jl index da3eb43..76f1cb6 100644 --- a/test/mutations.jl +++ b/test/mutations.jl @@ -124,11 +124,15 @@ end # point + # The invariant is length(ex) == length(mex); the original `== 7` was the + # length on Julia 1.10 only. Julia 1.11 changed how `rand` samples from + # `Dict`/`KeySet`, so `rand(rng, tr, H)` yields a different tree on 1.11+ + # even under StableRNG. mut = point(tr) Random.seed!(rng, 1) @testset "Point Mutation" for i in 1:10 mex = mut(copy(ex), rng=rng) - @test length(ex) == length(mex) == 7 + @test length(ex) == length(mex) @test sum(x == y for (x,y) in zip(ex.args, mex.args)) >= 2 end