Skip to content

Commit

Permalink
Use pushfirst! not reverse!; switch @test order
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly committed Jul 18, 2018
1 parent 8692f7f commit f910eaf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
6 changes: 3 additions & 3 deletions base/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ function splitpath(p::String)
dir, base = splitdir(p)
dir == p && (push!(out, dir); break) # Reached root node.
if !isempty(base) # Skip trailing '/' in basename
push!(out, base)
pushfirst!(out, base)
end
p = dir;
p = dir
end
return reverse!(out)
return out
end

joinpath(a::AbstractString) = a
Expand Down
1 change: 0 additions & 1 deletion base/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ precompile(Tuple{typeof(Base.Filesystem.isdir), String})
precompile(Tuple{typeof(Base.Filesystem.pwd)})
precompile(Tuple{typeof(Base.Filesystem.splitdir), String})
precompile(Tuple{typeof(Base.Filesystem.splitext), String})
precompile(Tuple{typeof(Base.Filesystem.splitpath), String})
precompile(Tuple{typeof(Base.Meta.isexpr), Symbol, Symbol, Int64})
precompile(Tuple{typeof(Base.Meta.parse), String})
precompile(Tuple{typeof(Base.Multimedia.display), Int64})
Expand Down
44 changes: 22 additions & 22 deletions test/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,34 +86,34 @@
@test relpath(S(joinpath("foo","bar")), S("foo")) == "bar"

@testset "splitpath" begin
@test ["a", "b", "c"] == splitpath(joinpath("a","b","c"))
@test [] == splitpath("")
@test splitpath(joinpath("a","b","c")) == ["a", "b", "c"]
@test splitpath("") == []

@test ["cats are", "gr8t"] == splitpath(joinpath("cats are", "gr8t"))
@test [" ", " "] == splitpath(joinpath(" ", " "))
@test splitpath(joinpath("cats are", "gr8t")) == ["cats are", "gr8t"]
@test splitpath(joinpath(" ", " ")) == [" ", " "]

# Unix-style paths are understood by all systems.
@test ["/", "a", "b"] == splitpath("/a/b")
@test ["/"] == splitpath("/")
@test ["a"] == splitpath("a/")
@test ["a", "b"] == splitpath("a/b/")
@test ["a.dir", "b.txt"] == splitpath("a.dir/b.txt")
@test ["/"] == splitpath("///")
@test ["/", "a", "b"] == splitpath("///a///b///")
@test splitpath("/a/b") == ["/", "a", "b"]
@test splitpath("/") == ["/"]
@test splitpath("a/") == ["a"]
@test splitpath("a/b/") == ["a", "b"]
@test splitpath("a.dir/b.txt") == ["a.dir", "b.txt"]
@test splitpath("///") == ["/"]
@test splitpath("///a///b///") == ["/", "a", "b"]

if Sys.iswindows()
@test ["C:\\", "a", "b", "c"] == splitpath("C:\\\\a\\b\\c")
@test ["C:\\"] == splitpath("C:\\\\")
@test ["J:\\"] == splitpath("J:\\")
@test ["C:"] == splitpath("C:")
@test ["a"] == splitpath("a\\")
@test ["a","b"] == splitpath("a\\\\b\\\\")
@test ["a.dir", "b.txt"] == splitpath("a.dir\\b.txt")
@test ["\\", "a","b"] == splitpath("\\a\\b\\")
@test splitpath("C:\\\\a\\b\\c") == ["C:\\", "a", "b", "c"]
@test splitpath("C:\\\\") == ["C:\\"]
@test splitpath("J:\\") == ["J:\\"]
@test splitpath("C:") == ["C:"]
@test splitpath("a\\") == ["a"]
@test splitpath("a\\\\b\\\\") == ["a","b"]
@test splitpath("a.dir\\b.txt") == ["a.dir", "b.txt"]
@test splitpath("\\a\\b\\") == ["\\", "a","b"]

@test ["/", "a", "b", "c", "d", "e"] == splitpath("/a/b\\c/d\\\\e")
@test ["/"] == splitpath("/\\/\\")
@test ["\\","a","b"] == splitpath("\\/\\a/\\//b")
@test splitpath("/a/b\\c/d\\\\e") == ["/", "a", "b", "c", "d", "e"]
@test splitpath("/\\/\\") == ["/"]
@test splitpath("\\/\\a/\\//b") == ["\\","a","b"]
end
end

Expand Down

0 comments on commit f910eaf

Please sign in to comment.