diff --git a/Project.toml b/Project.toml index e876afd..43a03d4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FieldProperties" uuid = "127e4479-4c95-493a-afaa-609d38175b70" authors = ["zchristensen "] -version = "0.4.0" +version = "0.4.1" [deps] Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" diff --git a/src/general.jl b/src/general.jl index c0017a6..3d695db 100644 --- a/src/general.jl +++ b/src/general.jl @@ -25,13 +25,13 @@ Property providing name for parent structure. Specifies maximum element for display purposes. If not specified returns the maximum value in the collection. """ @defprop CalibrationMaximum{:calmax}::(x::AbstractArray->eltype(x)) begin - @getproperty x -> maximum(x) + @getproperty x::AbstractArray -> maximum(x) end """ Specifies minimum element for display purposes. If not specified returns the minimum value in the collection. """ @defprop CalibrationMinimum{:calmin}::(x::AbstractArray->eltype(x)) begin - @getproperty x -> minimum(x) + @getproperty x::AbstractArray -> minimum(x) end diff --git a/test/metadata_tests.jl b/test/metadata_tests.jl index 017bb05..831221f 100644 --- a/test/metadata_tests.jl +++ b/test/metadata_tests.jl @@ -13,6 +13,9 @@ @test get!(m, :a, 3) == 1 @test m.a == 1 + m[:a] = 2 + @test m.a == 2 + @test m.b == 2 m.b = 3 @test m.b == 3 diff --git a/test/runtests.jl b/test/runtests.jl index 28a968d..fda19fd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -21,14 +21,25 @@ t = TestStruct(1,2,3,4,5) @test propertynames(t) == (:prop1,:prop2,:prop3,:prop4) - FieldProperties._fxnname(FieldProperties.Description{values}()) == "description(values)" - x = rand(4,4) @test @inferred(calmin(x)) == minimum(x) @test @inferred(calmax(x)) == maximum(x) +struct ArrayLike{T,N} + a::Array{T,N} + calmax::T + calmin::T +end + +xdiff = -(extrema(x)...) +xmax = maximum(x) - .25 * xdiff +xmin = minimum(x) + .25 * xdiff +a = ArrayLike(x, xmax, xmin) +@test calmax(a) == xmax +@test calmin(a) == xmin + include("metadata_tests.jl") @testset "FieldProperties docs" begin