Skip to content

Commit

Permalink
New version more cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokazama committed Feb 1, 2020
1 parent 5174089 commit fdd44c4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docs/build/

2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FieldProperties"
uuid = "127e4479-4c95-493a-afaa-609d38175b70"
authors = ["zchristensen "]
version = "0.3.5"
version = "0.4.0"

[deps]
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Expand Down
7 changes: 1 addition & 6 deletions src/abstractproperty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@ abstract type AbstractProperty{name,T} <: Function end
"NotProperty - Indicates the absence of a property."
struct NotProperty <: AbstractProperty{:not_property,nothing} end
const not_property = NotProperty()
(::NotProperty)(x, s) = error("type $(typeof(x).name) does not have property $s")


is_not_property(x) = x === not_property

Base.show(io::IO, p::AbstractProperty) = _show_property(io, p)
Base.show(io::IO, ::MIME"text/plain", p::AbstractProperty) = _show_property(io, p)

_fxnname(p::AbstractProperty{name,setproperty!}) where {name} = Symbol(name, :!)
_fxnname(p::AbstractProperty{name,getproperty}) where {name} = name
_fxnname(p::AbstractProperty{name,nothing}) where {name} = name
_fxnname(p::AbstractProperty{name,fxn}) where {name,fxn} = "$name($fxn)"

function _show_property(io, p::AbstractProperty)
Expand Down Expand Up @@ -56,7 +51,7 @@ This is functionlly equivalent to `convert(proptype(p, x), v)`.
"""
propconvert(p, x, v) = _propconvert(proptype(p, x), v)
_propconvert(::Type{T}, v::V) where {T,V<:T} = v
_propconvert(::Type{T}, v::V) where {T,V} = convert(T, v)
_propconvert(::Type{T}, v::V) where {T,V} = T(v)

"""
proptype(p, context) -> Type
Expand Down
3 changes: 3 additions & 0 deletions test/metadata_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ end

description!(m, "foo")
@test description(m) == "foo"

description!(m, rand(UInt8, 8))
@test isa(description(m), String)
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ t = TestStruct(1,2,3,4)
@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)
Expand Down

2 comments on commit fdd44c4

@Tokazama
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/8746

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" fdd44c497ef034dc7e7c7a94d763cb33428457ed
git push origin v0.4.0

Please sign in to comment.