Skip to content

Commit 38909d9

Browse files
committed
make GP mutation tests more stable
1 parent 5b85177 commit 38909d9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/mutations.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,18 @@
8383
Random.seed!(rng, 1)
8484
off = [mut(copy(ex), rng=rng) for i in 1:10]
8585
@testset "Offspring Height" for i in 1:10
86-
@test all(o->Evolutionary.height(o) <= H, map(o->mut(o,rng=rng), off))
86+
map(o->mut(o,rng=rng), off) # mutate offspring
87+
@test all(o->Evolutionary.height(o) <= H, off)
8788
end
8889

8990
# subtree mutation does not produce offspring expression longer then the parent
9091
mut = subtree(tr; growth=0.5)
9192
Random.seed!(rng, 2)
9293
off = [mut(copy(ex), rng=rng) for i in 1:10]
9394
@testset "Offspring Height (Growth)" for i in 1:5
94-
@test all(o->Evolutionary.height(o) <= 3i, map(o->mut(o,rng=rng), off))
95+
map(o->mut(o,rng=rng), off) # mutate offspring
96+
h = map(Evolutionary.height, off)
97+
@test all(h .<= 3+i)
9598
end
9699

97100
# hoist
@@ -103,7 +106,7 @@
103106
@testset "Hoist Mutation" for i in 1:10
104107
n = length(off[i])
105108
m = length(mut(off[i], rng=rng))
106-
@test n > m
109+
@test n >= m
107110
end
108111

109112
# shrink

0 commit comments

Comments
 (0)