From bb344bbd8f0ba026186306a350a6b85e702e7392 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Wed, 19 Jul 2017 22:42:52 -0700 Subject: [PATCH] replace another custom `show` with the util func Replace the `show_ary` function with the `show` test utility function. --- tests/expansion.in | 3 +++ tests/function.in | 15 +-------------- tests/function.out | 36 ++++++++++++++++++------------------ 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/tests/expansion.in b/tests/expansion.in index cfdcfa366..207b811c3 100644 --- a/tests/expansion.in +++ b/tests/expansion.in @@ -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 diff --git a/tests/function.in b/tests/function.in index 25b1f561d..11e0c503f 100644 --- a/tests/function.in +++ b/tests/function.in @@ -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 diff --git a/tests/function.out b/tests/function.out index 6845d37f0..da6ea47d2 100644 --- a/tests/function.out +++ b/tests/function.out @@ -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