Port function.in test to littlecheck
This commit is contained in:
parent
921fce3a51
commit
fc884e9cf4
@ -2,3 +2,120 @@
|
||||
function t --argument-names a b c
|
||||
echo t
|
||||
end
|
||||
|
||||
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
|
||||
set --show foo bar baz
|
||||
end
|
||||
|
||||
frob
|
||||
#CHECK: $foo: set in local scope, unexported, with 1 elements
|
||||
#CHECK: $foo[1]: length=9 value=|local foo|
|
||||
#CHECK: $foo: set in global scope, unexported, with 1 elements
|
||||
#CHECK: $foo[1]: length=10 value=|global foo|
|
||||
#CHECK: $foo: not set in universal scope
|
||||
#CHECK:
|
||||
#CHECK: $bar: set in local scope, unexported, with 5 elements
|
||||
#CHECK: $bar[1]: length=3 value=|one|
|
||||
#CHECK: $bar[2]: length=8 value=|two 2|
|
||||
#CHECK: $bar[3]: length=1 value=|\t|
|
||||
#CHECK: $bar[4]: length=0 value=||
|
||||
#CHECK: $bar[5]: length=1 value=|3|
|
||||
#CHECK: $bar: set in global scope, unexported, with 5 elements
|
||||
#CHECK: $bar[1]: length=3 value=|one|
|
||||
#CHECK: $bar[2]: length=8 value=|two 2|
|
||||
#CHECK: $bar[3]: length=1 value=|\t|
|
||||
#CHECK: $bar[4]: length=0 value=||
|
||||
#CHECK: $bar[5]: length=1 value=|3|
|
||||
#CHECK: $bar: not set in universal scope
|
||||
#CHECK:
|
||||
#CHECK: $baz: set in local scope, unexported, with 0 elements
|
||||
#CHECK: $baz: set in global scope, unexported, with 0 elements
|
||||
#CHECK: $baz: not set in universal scope
|
||||
|
||||
set foo 'bad foo'
|
||||
set bar 'bad bar'
|
||||
set baz 'bad baz'
|
||||
frob
|
||||
#CHECK: $foo: set in local scope, unexported, with 1 elements
|
||||
#CHECK: $foo[1]: length=9 value=|local foo|
|
||||
#CHECK: $foo: set in global scope, unexported, with 1 elements
|
||||
#CHECK: $foo[1]: length=10 value=|global foo|
|
||||
#CHECK: $foo: not set in universal scope
|
||||
#CHECK:
|
||||
#CHECK: $bar: set in local scope, unexported, with 5 elements
|
||||
#CHECK: $bar[1]: length=3 value=|one|
|
||||
#CHECK: $bar[2]: length=8 value=|two 2|
|
||||
#CHECK: $bar[3]: length=1 value=|\t|
|
||||
#CHECK: $bar[4]: length=0 value=||
|
||||
#CHECK: $bar[5]: length=1 value=|3|
|
||||
#CHECK: $bar: set in global scope, unexported, with 1 elements
|
||||
#CHECK: $bar[1]: length=7 value=|bad bar|
|
||||
#CHECK: $bar: not set in universal scope
|
||||
#CHECK:
|
||||
#CHECK: $baz: set in local scope, unexported, with 0 elements
|
||||
#CHECK: $baz: set in global scope, unexported, with 1 elements
|
||||
#CHECK: $baz[1]: length=7 value=|bad baz|
|
||||
#CHECK: $baz: not set in universal scope
|
||||
#CHECK:
|
||||
|
||||
# This sequence of tests originally verified that functions `name2` and
|
||||
# `name4` were created. See issue #2068. That behavior is not what we want.
|
||||
# The function name must always be the first argument of the `function`
|
||||
# command. See issue #2827.
|
||||
function name1 -a arg1 arg2
|
||||
echo hello
|
||||
end
|
||||
function -a arg1 arg2 name2 ; end
|
||||
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: Illegal function name '-a'
|
||||
#CHECKERR: function -a arg1 arg2 name2 ; end
|
||||
#CHECKERR: ^
|
||||
function name3 --argument-names arg1 arg2 ; echo hello; echo goodbye; end
|
||||
function --argument-names arg1 arg2 name4 ; end
|
||||
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: Illegal function name '--argument-names'
|
||||
#CHECKERR: function --argument-names arg1 arg2 name4 ; end
|
||||
#CHECKERR: ^
|
||||
function name5 abc --argument-names def ; end
|
||||
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: Unexpected positional argument 'abc'
|
||||
#CHECKERR: function name5 abc --argument-names def ; end
|
||||
#CHECKERR: ^
|
||||
functions -q name1; and echo "Function name1 found"
|
||||
functions -q name2; or echo "Function name2 not found as expected"
|
||||
functions -q name3; and echo "Function name3 found"
|
||||
functions -q name4; or echo "Function name4 not found as expected"
|
||||
#CHECK: Function name1 found
|
||||
#CHECK: Function name2 not found as expected
|
||||
#CHECK: Function name3 found
|
||||
#CHECK: Function name4 not found as expected
|
||||
|
||||
functions -c name1 name1a
|
||||
functions --copy name3 name3a
|
||||
functions -q name1a
|
||||
or echo "Function name1a not found as expected"
|
||||
functions -q name3a
|
||||
or echo "Function name3a not found as expected"
|
||||
|
||||
# Poor man's diff because on some systems diff defaults to unified output, but that prints filenames.
|
||||
#
|
||||
set -l name1 (functions name1)
|
||||
set -l name1a (functions name1a)
|
||||
set -l name3 (functions name3)
|
||||
set -l name3a (functions name3a)
|
||||
# First line for the non-copied function is "# Defined in checks/function.fish" - skip it to work around #6575.
|
||||
test "$name1[3..-1]" = "$name1a[2..-1]"; and echo "1 = 1a"
|
||||
#CHECK: 1 = 1a
|
||||
test "$name3[3..-1]" = "$name3a[2..-1]"; and echo "3 = 3a"
|
||||
#CHECK: 3 = 3a
|
||||
|
||||
function test; echo banana; end
|
||||
#CHECKERR: {{.*}}checks/function.fish (line {{\d+}}): function: The name 'test' is reserved,
|
||||
#CHECKERR: and can not be used as a function name
|
||||
#CHECKERR: function test; echo banana; end
|
||||
#CHECKERR: ^
|
||||
|
||||
functions -q; or echo "False"
|
||||
#CHECK: False
|
||||
exit 0
|
||||
|
@ -1,34 +0,0 @@
|
||||
|
||||
####################
|
||||
# Test the -V flag
|
||||
|
||||
####################
|
||||
# Testing -V
|
||||
|
||||
####################
|
||||
# Testing -V with changed variables
|
||||
fish: function: Illegal function name '-a'
|
||||
function -a arg1 arg2 name2 ; end
|
||||
^
|
||||
fish: function: Illegal function name '--argument-names'
|
||||
function --argument-names arg1 arg2 name4 ; end
|
||||
^
|
||||
fish: function: Unexpected positional argument 'abc'
|
||||
function name5 abc --argument-names def ; end
|
||||
^
|
||||
|
||||
####################
|
||||
# Verify that functions can be copied. Tests against regression of issue #3601
|
||||
|
||||
####################
|
||||
# Checking that the copied functions are identical other than the name
|
||||
|
||||
####################
|
||||
# Checking reserved names
|
||||
fish: function: The name 'test' is reserved,
|
||||
and can not be used as a function name
|
||||
function test; echo banana; end
|
||||
^
|
||||
|
||||
####################
|
||||
# Checking `functions -q` without arguments
|
@ -1,64 +0,0 @@
|
||||
# vim: set filetype=fish:
|
||||
#
|
||||
# Test the `function` builtin
|
||||
|
||||
logmsg 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
|
||||
set --show foo bar baz
|
||||
end
|
||||
|
||||
logmsg Testing -V
|
||||
frob
|
||||
|
||||
logmsg Testing -V with changed variables
|
||||
set foo 'bad foo'
|
||||
set bar 'bad bar'
|
||||
set baz 'bad baz'
|
||||
frob
|
||||
|
||||
# This sequence of tests originally verified that functions `name2` and
|
||||
# `name4` were created. See issue #2068. That behavior is not what we want.
|
||||
# The function name must always be the first argument of the `function`
|
||||
# command. See issue #2827.
|
||||
function name1 -a arg1 arg2 ; echo hello; end
|
||||
function -a arg1 arg2 name2 ; end
|
||||
function name3 --argument-names arg1 arg2 ; echo hello; echo goodbye; end
|
||||
function --argument-names arg1 arg2 name4 ; end
|
||||
function name5 abc --argument-names def ; end
|
||||
functions -q name1; and echo "Function name1 found"
|
||||
functions -q name2; or echo "Function name2 not found as expected"
|
||||
functions -q name3; and echo "Function name3 found"
|
||||
functions -q name4; or echo "Function name4 not found as expected"
|
||||
|
||||
logmsg Verify that functions can be copied. Tests against regression of issue \#3601
|
||||
functions -c name1 name1a
|
||||
functions --copy name3 name3a
|
||||
functions -q name1a
|
||||
or echo "Function name1a not found as expected"
|
||||
functions -q name3a
|
||||
or echo "Function name3a not found as expected"
|
||||
|
||||
logmsg Checking that the copied functions are identical other than the name
|
||||
# Poor man's diff because on some systems diff defaults to unified output, but that prints filenames.
|
||||
#
|
||||
set -l name1 (functions name1)
|
||||
set -l name1a (functions name1a)
|
||||
set -l name3 (functions name3)
|
||||
set -l name3a (functions name3a)
|
||||
echo $name1[1]
|
||||
echo $name1a[1]
|
||||
test "$name1[2..-1]" = "$name1a[2..-1]"; and echo "1 = 1a"
|
||||
echo $name3[1]
|
||||
echo $name3a[1]
|
||||
test "$name3[2..-1]" = "$name3a[2..-1]"; and echo "3 = 3a"
|
||||
|
||||
logmsg Checking reserved names
|
||||
function test; echo banana; end
|
||||
|
||||
logmsg Checking `functions -q` without arguments
|
||||
functions -q; or echo "False"
|
||||
exit 0
|
@ -1,77 +0,0 @@
|
||||
|
||||
####################
|
||||
# Test the -V flag
|
||||
|
||||
####################
|
||||
# Testing -V
|
||||
$foo: set in local scope, unexported, with 1 elements
|
||||
$foo[1]: length=9 value=|local foo|
|
||||
$foo: set in global scope, unexported, with 1 elements
|
||||
$foo[1]: length=10 value=|global foo|
|
||||
$foo: not set in universal scope
|
||||
|
||||
$bar: set in local scope, unexported, with 5 elements
|
||||
$bar[1]: length=3 value=|one|
|
||||
$bar[2]: length=8 value=|two 2|
|
||||
$bar[3]: length=1 value=|\t|
|
||||
$bar[4]: length=0 value=||
|
||||
$bar[5]: length=1 value=|3|
|
||||
$bar: set in global scope, unexported, with 5 elements
|
||||
$bar[1]: length=3 value=|one|
|
||||
$bar[2]: length=8 value=|two 2|
|
||||
$bar[3]: length=1 value=|\t|
|
||||
$bar[4]: length=0 value=||
|
||||
$bar[5]: length=1 value=|3|
|
||||
$bar: not set in universal scope
|
||||
|
||||
$baz: set in local scope, unexported, with 0 elements
|
||||
$baz: set in global scope, unexported, with 0 elements
|
||||
$baz: not set in universal scope
|
||||
|
||||
|
||||
####################
|
||||
# Testing -V with changed variables
|
||||
$foo: set in local scope, unexported, with 1 elements
|
||||
$foo[1]: length=9 value=|local foo|
|
||||
$foo: set in global scope, unexported, with 1 elements
|
||||
$foo[1]: length=10 value=|global foo|
|
||||
$foo: not set in universal scope
|
||||
|
||||
$bar: set in local scope, unexported, with 5 elements
|
||||
$bar[1]: length=3 value=|one|
|
||||
$bar[2]: length=8 value=|two 2|
|
||||
$bar[3]: length=1 value=|\t|
|
||||
$bar[4]: length=0 value=||
|
||||
$bar[5]: length=1 value=|3|
|
||||
$bar: set in global scope, unexported, with 1 elements
|
||||
$bar[1]: length=7 value=|bad bar|
|
||||
$bar: not set in universal scope
|
||||
|
||||
$baz: set in local scope, unexported, with 0 elements
|
||||
$baz: set in global scope, unexported, with 1 elements
|
||||
$baz[1]: length=7 value=|bad baz|
|
||||
$baz: not set in universal scope
|
||||
|
||||
Function name1 found
|
||||
Function name2 not found as expected
|
||||
Function name3 found
|
||||
Function name4 not found as expected
|
||||
|
||||
####################
|
||||
# Verify that functions can be copied. Tests against regression of issue #3601
|
||||
|
||||
####################
|
||||
# Checking that the copied functions are identical other than the name
|
||||
function name1 --argument arg1 arg2
|
||||
function name1a --argument arg1 arg2
|
||||
1 = 1a
|
||||
function name3 --argument arg1 arg2
|
||||
function name3a --argument arg1 arg2
|
||||
3 = 3a
|
||||
|
||||
####################
|
||||
# Checking reserved names
|
||||
|
||||
####################
|
||||
# Checking `functions -q` without arguments
|
||||
False
|
Loading…
x
Reference in New Issue
Block a user