Skip to content

Commit 8c3a2d8

Browse files
test: make cache tests more deterministic
1 parent ed369b7 commit 8c3a2d8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/cache_macro.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ using SymbolicUtils
22
using SymbolicUtils: BasicSymbolic, @cache, associated_cache, set_limit!, get_limit,
33
clear_cache!, SymbolicKey, metadata, maketerm
44
using OhMyThreads: tmap
5+
using Random
56

67
@cache function f1(x::BasicSymbolic)::BasicSymbolic
78
return 2x + 1
@@ -140,17 +141,17 @@ end
140141
@testset "Threading" begin
141142
@syms x y z
142143
@test isequal(f4(2x + 1), 2(2x + 1) + 1)
143-
144+
rng = Xoshiro(3)
144145
function build_rand_expr(vars, depth, maxdepth)
145146
if depth < maxdepth
146147
v = build_rand_expr(vars, depth + 1, maxdepth)
147148
else
148-
v = rand(vars)
149+
v = rand(rng, vars)
149150
end
150151
if isodd(depth)
151-
return v + rand([1:3; vars])
152+
return v + rand(rng, [1:3; vars])
152153
else
153-
return v * rand([1:3; vars])
154+
return v * rand(rng, [1:3; vars])
154155
end
155156
end
156157

0 commit comments

Comments
 (0)