diff --git a/src/container.jl b/src/container.jl index 80d7898..f73ce51 100644 --- a/src/container.jl +++ b/src/container.jl @@ -62,6 +62,9 @@ end setcontainerproperty!(obj::AnyContainer, name::Symbol, value::Any) = getfield(obj, 1)[name] = value setcontainerproperty!(obj::ShadowContainer, name::Symbol, value) = setfield!(obj, name, value) +Base.:(==)(x::AnyContainer{T}, y::AnyContainer{T}) where {T} = all(p -> getproperty(x, p) == getproperty(y, p), fieldnames(T)) +Base.:(!=)(x::AnyContainer{T}, y::AnyContainer{T}) where {T} = any(p -> getproperty(x, p) != getproperty(y, p), fieldnames(T)) + Base.summary(io::IO, ::Container{T}) where {T} = show(io, Container{T}) function Base.show(io::IO, obj::Container) @@ -115,3 +118,4 @@ function Container(obj::T) where {T} end res end +Container(c::Container) = c diff --git a/test/runtests.jl b/test/runtests.jl index a2f7bb8..6fddb6f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -85,6 +85,8 @@ end @test repr(UndefProperty()) == "#undef" @test_throws ArgumentError Container(1) @test Container(im).im + @test Container(Container(1//2)) == Container(1//2) + @test Container(Container(2//1)) != Container(1//2) @test Container{Complex{Bool}}().im == UndefProperty{Bool}() @test Container{Complex{Rational{Int}}}().im.num == UndefProperty{Int}() @test_throws ErrorException Container{Complex{Bool}}().i