Skip to content

Commit

Permalink
Add test for multiple finalizers
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Apr 3, 2016
1 parent 952331a commit 3da6fe7
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,7 @@ type ObjMember
member::DateRange6387
end

obj = ObjMember(DateRange6387{Int64}())
obj6387 = ObjMember(DateRange6387{Int64}())

function v6387{T}(r::Range{T})
a = Array(T,1)
Expand All @@ -1831,7 +1831,7 @@ function day_in(obj::ObjMember)
@test isa(x, Vector{Date6387{Int64}})
@test isa(x[1], Date6387{Int64})
end
day_in(obj)
day_in(obj6387)

# issue #6784
@test ndims(Array(Array{Float64},3,5)) == 2
Expand Down Expand Up @@ -3746,3 +3746,23 @@ end
@noinline function f15425(x)
end
@test f15425(1) === nothing

# check if we can run multiple finalizers at the same time
let
# disable GC to make sure no collection/promotion happens
# when we are constructing the objects
gc_enabled13995 = gc_enable(false)
obj13995 = Ref(1)
finalized13995 = [false, false, false, false]
finalizer(obj13995, (x)->(finalized13995[1] = true))
finalizer(obj13995, (x)->(finalized13995[2] = true))
finalizer(obj13995, (x)->(finalized13995[3] = true))
finalizer(obj13995, (x)->(finalized13995[4] = true))
obj13995 = nothing
gc_enable(true)
# obj is unreachable and young, a single young gc should collect it
# and trigger all the finalizers.
gc(false)
println(finalized13995 == [true, true, true, true])
gc_enable(gc_enabled13995)
end

0 comments on commit 3da6fe7

Please sign in to comment.