From aa502dde556a040581adde292f5755024c1a7403 Mon Sep 17 00:00:00 2001 From: kshyatt Date: Sun, 4 Nov 2018 14:44:37 -0500 Subject: [PATCH] Tests for WeakRef --- test/missing.jl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/missing.jl b/test/missing.jl index 9f3084e46b1b7..29a5ae3fcb562 100644 --- a/test/missing.jl +++ b/test/missing.jl @@ -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} @@ -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