diff --git a/src/path.jl b/src/path.jl index 3dcedd2..f21244f 100644 --- a/src/path.jl +++ b/src/path.jl @@ -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) diff --git a/test/runtests.jl b/test/runtests.jl index 2c8df2f..0eaff4e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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,