Skip to content

Commit

Permalink
Merge pull request #29928 from JuliaLang/ksh/wrmissing
Browse files Browse the repository at this point in the history
Tests for WeakRef and missing
  • Loading branch information
kshyatt committed Nov 6, 2018
2 parents 58fea96 + aa502dd commit 0fde275
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/missing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ end
@test promote_type(Union{Int, Missing}, Int) == Union{Int, Missing}
@test promote_type(Int, Union{Int, Missing}) == Union{Int, Missing}
@test promote_type(Any, Union{Int, Missing}) == Any
@test promote_type(Union{Nothing, Missing}, Any) == Any
@test promote_type(Union{Int, Missing}, Union{Int, Missing}) == Union{Int, Missing}
@test promote_type(Union{Float64, Missing}, Union{String, Missing}) == Any
@test promote_type(Union{Float64, Missing}, Union{Int, Missing}) == Union{Float64, Missing}
Expand Down Expand Up @@ -433,3 +434,18 @@ end
@test coalesce(nothing, missing) === nothing
@test coalesce(missing, nothing) === nothing
end

mutable struct Obj; x; end
@testset "weak references" begin
@noinline function mk_wr(r, wr)
x = Obj(1)
push!(r, x)
push!(wr, WeakRef(x))
nothing
end
ref = []
wref = []
mk_wr(ref, wref)
@test ismissing(wref[1] == missing)
@test ismissing(missing == wref[1])
end

0 comments on commit 0fde275

Please sign in to comment.