Skip to content

Commit e7b1242

Browse files
author
José Valim
committed
Fix a bug on Path.split/1
1 parent d3d83b1 commit e7b1242

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

lib/elixir/lib/path.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,16 @@ defmodule Path do
423423
## Examples
424424
425425
iex> Path.split("")
426-
["/"]
426+
[]
427427
iex> Path.split("foo")
428428
["foo"]
429429
iex> Path.split("/foo/bar")
430430
["/", "foo", "bar"]
431431
432432
"""
433+
# Work around a bug in Erlang on UNIX
434+
def split(""), do: []
435+
433436
def split(path) do
434437
FN.split(path)
435438
end

lib/elixir/test/elixir/path_test.exs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ defmodule PathTest do
6464
assert Path.type("C:\\usr\\local\\bin") == :absolute
6565
assert Path.type("C:usr\\local\\bin") == :volumerelative
6666

67-
assert Path.type("/usr/local/bin") == :absolute
67+
assert Path.type("/usr/local/bin") == :volumerelative
6868
assert Path.type("usr/local/bin") == :relative
6969
assert Path.type("../usr/local/bin") == :relative
7070

71-
assert Path.type('/usr/local/bin') == :absolute
71+
assert Path.type('/usr/local/bin') == :volumerelative
7272
assert Path.type('usr/local/bin') == :relative
7373
assert Path.type('../usr/local/bin') == :relative
7474

75-
assert Path.type(['/usr/', 'local/bin']) == :absolute
75+
assert Path.type(['/usr/', 'local/bin']) == :volumerelative
7676
assert Path.type(['usr/', 'local/bin']) == :relative
7777
assert Path.type(['../usr', '/local/bin']) == :relative
7878
end
@@ -238,13 +238,13 @@ defmodule PathTest do
238238
end
239239

240240
test :split_with_binary do
241-
assert Path.split("") == ["/"]
241+
assert Path.split("") == []
242242
assert Path.split("foo") == ["foo"]
243243
assert Path.split("/foo/bar") == ["/", "foo", "bar"]
244244
end
245245

246246
test :split_with_list do
247-
assert Path.split('') == ''
247+
assert Path.split('') == []
248248
assert Path.split('foo') == ['foo']
249249
assert Path.split('/foo/bar') == ['/', 'foo', 'bar']
250250
end

lib/elixir/test/elixir/system_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ defmodule SystemTest do
5555
end
5656

5757
test :cmd do
58-
assert is_binary(System.cmd "binary")
59-
assert is_list(System.cmd 'binary')
58+
assert is_binary(System.cmd "cd .")
59+
assert is_list(System.cmd 'cd .')
6060
end
6161

6262
test :find_executable_with_binary do

0 commit comments

Comments
 (0)