Skip to content

Commit 52a1bf8

Browse files
committed
test: fix issue where test eval fails due to incomplete eval
1 parent 60bbf7b commit 52a1bf8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test/test_buffered_evaluation.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ end
131131

132132
for turbo in (false, true), i in 1:100
133133
# Generate a random tree with varying size (1-10 nodes)
134-
n_nodes = rand(1:10)
135-
tree = gen_random_tree_fixed_size(n_nodes, operators, size(X, 1), Float64, Node)
134+
rng = Random.MersenneTwister(i)
135+
n_nodes = rand(rng, 1:10)
136+
tree = gen_random_tree_fixed_size(
137+
n_nodes, operators, size(X, 1), Float64, Node, rng
138+
)
136139

137140
# Regular evaluation
138141
eval_options_no_buffer = EvalOptions(; turbo)
@@ -142,12 +145,12 @@ end
142145

143146
# Buffer evaluation
144147
buffer = Array{Float64}(undef, 2n_nodes, size(X, 2))
145-
buffer_ref = Ref(rand(1:10)) # Random starting index (will be reset)
148+
buffer_ref = Ref(rand(rng, 1:10)) # Random starting index (will be reset)
146149
eval_options = EvalOptions(; turbo, buffer=ArrayBuffer(buffer, buffer_ref))
147150
result2, ok2 = eval_tree_array(tree, X, operators; eval_options)
148151

149152
# Results should be identical
150-
@test isapprox(result1, result2; atol=1e-10)
153+
@test isapprox(result1, result2; atol=1e-10) || (!ok1 && !ok2)
151154
@test ok1 == ok2
152155
end
153156
end

0 commit comments

Comments
 (0)