File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed
Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -904,8 +904,8 @@ defmodule File do
904904 directories of the current directory. For this reason, returns `{ :ok, [files] }`
905905 in case of success, `{ :error, reason }` otherwise.
906906 """
907- def listdir ( ) do
908- listdir ( "." )
907+ def ls ( ) do
908+ ls ( "." )
909909 end
910910
911911@ doc """
@@ -914,7 +914,7 @@ defmodule File do
914914 directories of the current directory. For this reason, returns `{ :ok, [files] }`
915915 in case of success, `{ :error, reason }` otherwise.
916916 """
917- def listdir ( path ) do
917+ def ls ( path ) do
918918 case F . list_dir ( path ) do
919919 { :ok , file_list } -> { :ok , Enum . map file_list , :unicode . characters_to_binary ( & 1 ) }
920920 { :error , _ } = error -> error
@@ -927,7 +927,7 @@ defmodule File do
927927
928928 Raises File.Error in case of an error.
929929 """
930- def listdir !( dir ) do
930+ def ls !( dir ) do
931931 case F . list_dir ( dir ) do
932932 { :ok , file_list } -> Enum . map file_list , :unicode . characters_to_binary ( & 1 )
933933 { :error , reason } ->
Original file line number Diff line number Diff line change @@ -397,6 +397,31 @@ defmodule FileTest do
397397 end
398398 end
399399
400+ defmodule ListDir do
401+
402+ test :ls do
403+ { code , value } = File . ls ( fixture_path )
404+ assert code == :ok
405+ refute code == :error
406+ assert is_list value
407+ assert 0 < Enum . count ( value )
408+ assert List . member? ( value , "code_sample.exs" )
409+ assert List . member? ( value , "file.txt" )
410+ end
411+
412+ test :ls2 do
413+ { code , value } = File . ls! ( fixture_path )
414+ assert code == :ok
415+ refute code == :error
416+ assert is_list value
417+ assert 0 < Enum . count ( value )
418+ assert List . member? ( value , "code_sample.exs" )
419+ assert List . member? ( value , "file.txt" )
420+ end
421+ end
422+
423+
424+
400425 defmodule OpenReadWrite do
401426 use ExUnit.Case
402427
You can’t perform that action at this time.
0 commit comments