Skip to content

Commit f910eaf

Browse files
committed
Use pushfirst! not reverse!; switch @test order
1 parent 8692f7f commit f910eaf

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

base/path.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ function splitpath(p::String)
216216
dir, base = splitdir(p)
217217
dir == p && (push!(out, dir); break) # Reached root node.
218218
if !isempty(base) # Skip trailing '/' in basename
219-
push!(out, base)
219+
pushfirst!(out, base)
220220
end
221-
p = dir;
221+
p = dir
222222
end
223-
return reverse!(out)
223+
return out
224224
end
225225

226226
joinpath(a::AbstractString) = a

base/precompile.jl

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ precompile(Tuple{typeof(Base.Filesystem.isdir), String})
122122
precompile(Tuple{typeof(Base.Filesystem.pwd)})
123123
precompile(Tuple{typeof(Base.Filesystem.splitdir), String})
124124
precompile(Tuple{typeof(Base.Filesystem.splitext), String})
125-
precompile(Tuple{typeof(Base.Filesystem.splitpath), String})
126125
precompile(Tuple{typeof(Base.Meta.isexpr), Symbol, Symbol, Int64})
127126
precompile(Tuple{typeof(Base.Meta.parse), String})
128127
precompile(Tuple{typeof(Base.Multimedia.display), Int64})

test/path.jl

+22-22
Original file line numberDiff line numberDiff line change
@@ -86,34 +86,34 @@
8686
@test relpath(S(joinpath("foo","bar")), S("foo")) == "bar"
8787

8888
@testset "splitpath" begin
89-
@test ["a", "b", "c"] == splitpath(joinpath("a","b","c"))
90-
@test [] == splitpath("")
89+
@test splitpath(joinpath("a","b","c")) == ["a", "b", "c"]
90+
@test splitpath("") == []
9191

92-
@test ["cats are", "gr8t"] == splitpath(joinpath("cats are", "gr8t"))
93-
@test [" ", " "] == splitpath(joinpath(" ", " "))
92+
@test splitpath(joinpath("cats are", "gr8t")) == ["cats are", "gr8t"]
93+
@test splitpath(joinpath(" ", " ")) == [" ", " "]
9494

9595
# Unix-style paths are understood by all systems.
96-
@test ["/", "a", "b"] == splitpath("/a/b")
97-
@test ["/"] == splitpath("/")
98-
@test ["a"] == splitpath("a/")
99-
@test ["a", "b"] == splitpath("a/b/")
100-
@test ["a.dir", "b.txt"] == splitpath("a.dir/b.txt")
101-
@test ["/"] == splitpath("///")
102-
@test ["/", "a", "b"] == splitpath("///a///b///")
96+
@test splitpath("/a/b") == ["/", "a", "b"]
97+
@test splitpath("/") == ["/"]
98+
@test splitpath("a/") == ["a"]
99+
@test splitpath("a/b/") == ["a", "b"]
100+
@test splitpath("a.dir/b.txt") == ["a.dir", "b.txt"]
101+
@test splitpath("///") == ["/"]
102+
@test splitpath("///a///b///") == ["/", "a", "b"]
103103

104104
if Sys.iswindows()
105-
@test ["C:\\", "a", "b", "c"] == splitpath("C:\\\\a\\b\\c")
106-
@test ["C:\\"] == splitpath("C:\\\\")
107-
@test ["J:\\"] == splitpath("J:\\")
108-
@test ["C:"] == splitpath("C:")
109-
@test ["a"] == splitpath("a\\")
110-
@test ["a","b"] == splitpath("a\\\\b\\\\")
111-
@test ["a.dir", "b.txt"] == splitpath("a.dir\\b.txt")
112-
@test ["\\", "a","b"] == splitpath("\\a\\b\\")
105+
@test splitpath("C:\\\\a\\b\\c") == ["C:\\", "a", "b", "c"]
106+
@test splitpath("C:\\\\") == ["C:\\"]
107+
@test splitpath("J:\\") == ["J:\\"]
108+
@test splitpath("C:") == ["C:"]
109+
@test splitpath("a\\") == ["a"]
110+
@test splitpath("a\\\\b\\\\") == ["a","b"]
111+
@test splitpath("a.dir\\b.txt") == ["a.dir", "b.txt"]
112+
@test splitpath("\\a\\b\\") == ["\\", "a","b"]
113113

114-
@test ["/", "a", "b", "c", "d", "e"] == splitpath("/a/b\\c/d\\\\e")
115-
@test ["/"] == splitpath("/\\/\\")
116-
@test ["\\","a","b"] == splitpath("\\/\\a/\\//b")
114+
@test splitpath("/a/b\\c/d\\\\e") == ["/", "a", "b", "c", "d", "e"]
115+
@test splitpath("/\\/\\") == ["/"]
116+
@test splitpath("\\/\\a/\\//b") == ["\\","a","b"]
117117
end
118118
end
119119

0 commit comments

Comments
 (0)