mirror of
https://github.com/sheumann/hush.git
synced 2024-11-16 18:12:41 +00:00
ash: copy function tests from hush testsuite
Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
2cf4591413
commit
85405c80a2
6
shell/ash_test/ash-misc/func1.right
Normal file
6
shell/ash_test/ash-misc/func1.right
Normal file
@ -0,0 +1,6 @@
|
||||
Hello
|
||||
Zero: 0
|
||||
One: 1 Param1: World
|
||||
Zero: 0 Param1: Restored
|
||||
Multi line function
|
||||
One: 1
|
16
shell/ash_test/ash-misc/func1.tests
Executable file
16
shell/ash_test/ash-misc/func1.tests
Executable file
@ -0,0 +1,16 @@
|
||||
f() { echo Hello; }
|
||||
g () { echo One: $# Param1: $1; }
|
||||
h ( )
|
||||
{
|
||||
echo -n 'Multi ' && echo -n 'line '
|
||||
echo function
|
||||
false
|
||||
}
|
||||
|
||||
f
|
||||
echo Zero: $?
|
||||
set -- Restored
|
||||
{ g World; }
|
||||
echo Zero: $? Param1: $1
|
||||
( h )
|
||||
echo One: $?
|
5
shell/ash_test/ash-misc/func2.right
Normal file
5
shell/ash_test/ash-misc/func2.right
Normal file
@ -0,0 +1,5 @@
|
||||
First 0
|
||||
Second 0
|
||||
First 1
|
||||
Second 1
|
||||
Done
|
9
shell/ash_test/ash-misc/func2.tests
Executable file
9
shell/ash_test/ash-misc/func2.tests
Executable file
@ -0,0 +1,9 @@
|
||||
i=0
|
||||
while test $i != 2; do
|
||||
f() { echo First $i; }
|
||||
f
|
||||
f() { echo Second $i; }
|
||||
f
|
||||
: $((i++))
|
||||
done
|
||||
echo Done
|
4
shell/ash_test/ash-misc/func3.right
Normal file
4
shell/ash_test/ash-misc/func3.right
Normal file
@ -0,0 +1,4 @@
|
||||
One:1
|
||||
Zero:0
|
||||
One:1
|
||||
Five:5
|
8
shell/ash_test/ash-misc/func3.tests
Executable file
8
shell/ash_test/ash-misc/func3.tests
Executable file
@ -0,0 +1,8 @@
|
||||
f() { false; return; echo BAD; };
|
||||
{ f; echo One:$?; }; echo Zero:$?
|
||||
|
||||
f() { false; return; };
|
||||
f; echo One:$?
|
||||
|
||||
f() { return 5; };
|
||||
f; echo Five:$?
|
2
shell/ash_test/ash-misc/func4.right
Normal file
2
shell/ash_test/ash-misc/func4.right
Normal file
@ -0,0 +1,2 @@
|
||||
24
|
||||
Done
|
7
shell/ash_test/ash-misc/func4.tests
Executable file
7
shell/ash_test/ash-misc/func4.tests
Executable file
@ -0,0 +1,7 @@
|
||||
func() {
|
||||
eval "echo \"\${val_${1}}\""
|
||||
}
|
||||
|
||||
val_x=24
|
||||
(func x)
|
||||
echo Done
|
6
shell/ash_test/ash-misc/func5.right
Normal file
6
shell/ash_test/ash-misc/func5.right
Normal file
@ -0,0 +1,6 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
13
shell/ash_test/ash-misc/func5.tests
Executable file
13
shell/ash_test/ash-misc/func5.tests
Executable file
@ -0,0 +1,13 @@
|
||||
f() { echo $1; }
|
||||
f 1
|
||||
|
||||
f() ( echo $1; )
|
||||
f 2
|
||||
|
||||
f() ( echo $1 )
|
||||
f 3
|
||||
|
||||
f() for i in 1 2 3; do
|
||||
echo $i
|
||||
done
|
||||
f
|
5
shell/ash_test/ash-misc/func_args1.right
Normal file
5
shell/ash_test/ash-misc/func_args1.right
Normal file
@ -0,0 +1,5 @@
|
||||
params: a b c
|
||||
'f 1 2 3' called
|
||||
params: a b c
|
||||
'f 1 2 3' called
|
||||
params: a b c
|
9
shell/ash_test/ash-misc/func_args1.tests
Executable file
9
shell/ash_test/ash-misc/func_args1.tests
Executable file
@ -0,0 +1,9 @@
|
||||
|
||||
f() { echo "'f $1 $2 $3' called"; }
|
||||
|
||||
set -- a b c
|
||||
echo "params: $1 $2 $3"
|
||||
f 1 2 3
|
||||
echo "params: $1 $2 $3"
|
||||
true | f 1 2 3
|
||||
echo "params: $1 $2 $3"
|
3
shell/ash_test/ash-misc/func_local1.right
Normal file
3
shell/ash_test/ash-misc/func_local1.right
Normal file
@ -0,0 +1,3 @@
|
||||
z=a
|
||||
z=z
|
||||
Done
|
5
shell/ash_test/ash-misc/func_local1.tests
Executable file
5
shell/ash_test/ash-misc/func_local1.tests
Executable file
@ -0,0 +1,5 @@
|
||||
export z=z
|
||||
f() { local z=a; env | grep ^z; }
|
||||
f
|
||||
env | grep ^z
|
||||
echo Done
|
14
shell/ash_test/ash-misc/func_local2.right
Normal file
14
shell/ash_test/ash-misc/func_local2.right
Normal file
@ -0,0 +1,14 @@
|
||||
1
|
||||
2
|
||||
1
|
||||
2
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
3
|
||||
2
|
||||
2
|
||||
3
|
||||
1
|
||||
Done
|
7
shell/ash_test/ash-misc/func_local2.tests
Executable file
7
shell/ash_test/ash-misc/func_local2.tests
Executable file
@ -0,0 +1,7 @@
|
||||
x=1
|
||||
f() { echo $x; local x=$((x+1)); echo $x; }
|
||||
g() { f; echo $x; f; local x=$((x+1)); f; echo $x; f; }
|
||||
f
|
||||
g
|
||||
echo $x
|
||||
echo Done
|
Loading…
Reference in New Issue
Block a user