replace another custom show with the util func

Replace the `show_ary` function with the `show` test utility function.
This commit is contained in:
Kurtis Rader 2017-07-19 22:42:52 -07:00
parent dc33c1afe1
commit bb344bbd8f
3 changed files with 22 additions and 32 deletions

View file

@ -1,5 +1,8 @@
# Test expansion of variables
# We don't use the test utility function of the same name because we want
# different behavior. Specifically, that the expansion of any variables or
# other strings before we are invoked produce the expected expansion.
function show --description 'Prints argument count followed by arguments'
echo (count $argv) $argv
end

View file

@ -2,26 +2,13 @@
#
# Test the `function` builtin
# utility function
function show_ary -a name --no-scope-shadowing
set -l count (count $$name)
echo "\$$name: ($count)"
if test $count -gt 0
for i in (seq $count)
echo "$i: '$$name[1][$i]'"
end
end
end
# Test the -V flag
set -g foo 'global foo'
set -l foo 'local foo'
set bar one 'two 2' \t '' 3
set baz
function frob -V foo -V bar -V baz
show_ary foo
show_ary bar
show_ary baz
show foo bar baz
end
echo "Testing -V"
frob

View file

@ -1,23 +1,23 @@
Testing -V
$foo: (1)
1: 'local foo'
$bar: (5)
1: 'one'
2: 'two 2'
3: ' '
4: ''
5: '3'
$baz: (0)
$foo count=1
$foo[1]=|local foo|
$bar count=5
$bar[1]=|one|
$bar[2]=|two 2|
$bar[3]=| |
$bar[4]=||
$bar[5]=|3|
$baz count=0
Testing -V with changed variables
$foo: (1)
1: 'local foo'
$bar: (5)
1: 'one'
2: 'two 2'
3: ' '
4: ''
5: '3'
$baz: (0)
$foo count=1
$foo[1]=|local foo|
$bar count=5
$bar[1]=|one|
$bar[2]=|two 2|
$bar[3]=| |
$bar[4]=||
$bar[5]=|3|
$baz count=0
Function name1 found
Function name2 not found as expected
Function name3 found