Skip to content

Commit

Permalink
Merge pull request #139 from beacon-biosignals/eph/propertynames
Browse files Browse the repository at this point in the history
add `propertynames`
  • Loading branch information
rofinn authored Nov 16, 2021
2 parents c1cd009 + 5c737aa commit eb9895e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ function Base.getproperty(fp::T, attr::Symbol) where T <: AbstractPath
end
end

function Base.propertynames(::T, private::Bool=false) where T <: AbstractPath
public_names = (:drive, :root, :anchor, :separator)
return private ? Base.merge_names(public_names, fieldnames(T)) : public_names
end

#=
We only want to print the macro string syntax when compact is true and
we want print to just return the string (this allows `string` to work normally)
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ include("testpkg.jl")
# Test that our weird registered path works
ps = PathSet(TestPkg.posix2test(tmpdir()) / "pathset_root"; symlink=true)

@testset "`propertynames`" begin
@test propertynames(ps.root) == (:drive, :root, :anchor, :separator)
@test propertynames(ps.root, true) == (:drive, :root, :anchor, :separator, :segments)
end

@testset "$(typeof(ps.root))" begin
testsets = [
test_registration,
Expand Down

0 comments on commit eb9895e

Please sign in to comment.