Skip to content

Commit 66920b9

Browse files
fix side effects in allocation tests
1 parent 9d31f64 commit 66920b9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/misc.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,10 +1392,12 @@ end
13921392
@testset "Base/timing.jl" begin
13931393
@test Base.jit_total_bytes() >= 0
13941394

1395-
# sanity check `@allocations` returns what we expect in some very simple cases
1396-
@test (@allocations "a") == 0
1397-
@test (@allocations "a" * "b") == 0 # constant propagation
1398-
@test (@allocations "a" * Base.inferencebarrier("b")) == 1
1395+
# sanity check `@allocations` returns what we expect in some very simple cases.
1396+
# These are inside functions because `@allocations` uses `Experimental.@force_compile`
1397+
# so can be affected by other code in the same scope.
1398+
@test (() -> @allocations "a")() == 0
1399+
@test (() -> @allocations "a" * "b")() == 0 # constant propagation
1400+
@test (() -> @allocations "a" * Base.inferencebarrier("b"))() == 1
13991401

14001402
lock_conflicts() = parse(Int, read(`$(Base.julia_cmd()) -tauto -E '
14011403
@lock_conflicts begin

0 commit comments

Comments
 (0)