+bucaran array.delete

This commit is contained in:
Bruno Pinto 2015-01-10 12:18:04 -02:00
parent 7c9d660f2c
commit 75ba7639a9
3 changed files with 15 additions and 21 deletions

View File

@ -0,0 +1,8 @@
# Remove item from list. List must be the name of a global variable.
# @params <item> <list>
function array.delete
set -l item $argv[1]
if set -l index (contains -i -- $item $$argv[2])
set -e $argv[2][$index]
end
end

View File

@ -1,7 +0,0 @@
set -l fish_tank /usr/local/share/fish-tank/tank.fish
if not test -e $fish_tank
echo 'error: fish-tank is required to run these tests (https://github.com/terlar/fish-tank)'
exit 1
end
source $fish_tank

View File

@ -32,13 +32,16 @@ function describe_oh_my_fish
end end
function it_loads_all_oh_my_fish_functions function it_loads_all_oh_my_fish_functions
remove_from_array "$fish_path/functions/" fish_function_path array.delete "$fish_path/functions/" fish_function_path
load_oh_my_fish load_oh_my_fish
expect $fish_function_path to_include $fish_path/functions/ expect $fish_function_path to_include $fish_path/functions/
end end
function it_loads_all_selected_plugins function it_loads_all_selected_plugins
remove_from_array "$fish_path/plugins/z" fish_function_path array.delete "$fish_path/plugins/bak" fish_function_path
array.delete "$fish_path/plugins/z" fish_function_path
set fish_plugins bak z set fish_plugins bak z
load_oh_my_fish load_oh_my_fish
expect $fish_function_path to_include $fish_path/plugins/bak and expect $fish_function_path to_include $fish_path/plugins/bak and
@ -46,7 +49,8 @@ function describe_oh_my_fish
end end
function it_loads_the_selected_theme function it_loads_the_selected_theme
remove_from_array "$fish_path/themes/l" fish_function_path array.delete "$fish_path/themes/l" fish_function_path
set fish_theme l set fish_theme l
load_oh_my_fish load_oh_my_fish
expect $fish_function_path to_include $fish_path/themes/l expect $fish_function_path to_include $fish_path/themes/l
@ -57,15 +61,4 @@ function load_oh_my_fish
. $fish_path/oh-my-fish.fish . $fish_path/oh-my-fish.fish
end end
function remove_from_array
set -l element $argv[1]
for i in (seq (count $$argv[2]))
if test $$argv[2][$i] = $element
set -e $argv[2][$i]
break
end
end
end
import plugins/fish-spec import plugins/fish-spec