diff --git a/src/compat.jl b/src/compat.jl index 6515a0c..2eec725 100644 --- a/src/compat.jl +++ b/src/compat.jl @@ -39,7 +39,7 @@ julia> myjoin("/Users/rory/repos", "FilePaths.jl") ``` """ macro compat(ex) - mod = @__MODULE__ + mod::Module = QuoteNode(__module__).value new_ex = compat_exp(mod, deepcopy(ex)) return quote diff --git a/test/compat.jl b/test/compat.jl index 51f58c4..d2ca3f0 100644 --- a/test/compat.jl +++ b/test/compat.jl @@ -37,8 +37,19 @@ end # Test for inline definitions FilePaths.@compat inline(x::AbstractPath, y::AbstractPath) = relative(x, y) + +# Test for custom path type +struct MyPath <: AbstractPath + x::String end +__init__() = FilePathsBase.register(MyPath) +FilePathsBase.ispathtype(::Type{MyPath}, str::AbstractString) = startswith(str, "mypath://") + +FilePaths.@compat mypath_testem(path::MyPath) = "**"*path.x + +end # TestPkg module + @testset "@compat" begin cd(abs(parent(Path(@__FILE__)))) do reg = Sys.iswindows() ? "..\\src\\FilePaths.jl" : "../src/FilePaths.jl" @@ -117,5 +128,10 @@ end # Mixing strings and paths should also work here @test TestPkg.inline(string(p), home()) == relative(p, home()) end + + @testset "Custom path type" begin + @test TestPkg.mypath_testem(TestPkg.MyPath("mypath://foo")) == "**mypath://foo" + @test TestPkg.mypath_testem("mypath://foo") == "**mypath://foo" + end end end