summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2018-12-24 04:40:22 +0100
committerAxel Beckert <abe@deuxchevaux.org>2018-12-24 04:40:22 +0100
commitbf8b7f713a5b04a191f4596fb86bbbfca0a855ce (patch)
treeb647a8dc990c8c845b8a8eca7bf92fbbf17e1fb5 /Test
parent06946d431a4426c6e5dffec1d7edb17c1dbd467c (diff)
parent9dbde9e9c7d22ee0d301e4a2fecf97906d1ddce9 (diff)
downloadzsh-bf8b7f713a5b04a191f4596fb86bbbfca0a855ce.tar.gz
zsh-bf8b7f713a5b04a191f4596fb86bbbfca0a855ce.zip
New upstream release candidate 5.6.2-test-2
Merge branch 'upstream' at 'zsh-5.6.2-test-2' into branch debian
Diffstat (limited to 'Test')
-rw-r--r--Test/A01grammar.ztst10
-rw-r--r--Test/B02typeset.ztst288
-rw-r--r--Test/C03traps.ztst19
-rw-r--r--Test/D04parameter.ztst7
-rw-r--r--Test/V07pcre.ztst5
-rw-r--r--Test/V09datetime.ztst29
6 files changed, 352 insertions, 6 deletions
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 217f7bea4..339ce7494 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -873,3 +873,13 @@
0:Assignment-only current shell commands in LHS of pipelin
>1
>1
+
+ echo pipe | ; sed s/pipe/PIPE/
+ true && ; echo and true
+ false && ; echo and false
+ true || ; echo or true
+ false || ; echo or false
+0:semicolon is equivalent to newline
+>PIPE
+>and true
+>or false
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 996af064f..ac86e0ad1 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -20,6 +20,14 @@
# Not yet tested:
# Assorted illegal flag combinations
+# For a few tests, we include a
+# typeset -p param
+# typeset -m param
+# typeset +m param
+# to test the proper output of typeset for a number of different types
+# of variables. Note that we can't use a dedicated function to factorize
+# that code, as that would affect the scoping.
+
%prep
## Do not remove the next line, it's used by V10private.ztst
# test_zsh_param_private
@@ -37,6 +45,9 @@
typeset -a array
array=(l o c a l)
print $scalar $array
+ typeset -p scalar array
+ typeset -m scalar array
+ typeset +m scalar array
}
scope01() {
local scalar
@@ -44,6 +55,9 @@
local -a array
array=(l o c a l)
print $scalar $array
+ typeset -p scalar array
+ typeset -m scalar array
+ typeset +m scalar array
}
scope02() {
declare scalar
@@ -51,10 +65,16 @@
declare -a array
array=(l o c a l)
print $scalar $array
+ typeset -p scalar array
+ typeset -m scalar array
+ typeset +m scalar array
}
scope10() {
export outer=outer
/bin/sh -fc 'echo $outer'
+ typeset -p outer
+ typeset -m outer
+ typeset +m outer
}
scope11() {
typeset -x outer=outer
@@ -68,6 +88,9 @@
local -xT OUTER outer
outer=(i n n e r)
/bin/sh -fc 'echo $OUTER'
+ typeset -p OUTER outer
+ typeset -m OUTER outer
+ typeset +m OUTER outer
}
# Bug? `typeset -h' complains that ! # $ * - ? @ are not identifiers.
@@ -79,8 +102,14 @@
%test
+ typeset -p scalar array
+ typeset -m scalar array
typeset +m scalar array
-0:Report types of parameters with typeset +m
+0:Report types for global variables
+>typeset -g scalar=scalar
+>typeset -g -a array=( a r r a y )
+>scalar=scalar
+>array=( a r r a y )
>scalar
>array array
@@ -88,18 +117,36 @@
print $scalar $array
0:Simple local declarations
>local l o c a l
+>typeset scalar=local
+>typeset -a array=( l o c a l )
+>scalar=local
+>array=( l o c a l )
+>local scalar
+>array local array
>scalar a r r a y
scope01
print $scalar $array
0:Equivalence of local and typeset in functions
>local l o c a l
+>typeset scalar=local
+>typeset -a array=( l o c a l )
+>scalar=local
+>array=( l o c a l )
+>local scalar
+>array local array
>scalar a r r a y
scope02
print $scalar $array
0:Basic equivalence of declare and typeset
>local l o c a l
+>typeset scalar=local
+>typeset -a array=( l o c a l )
+>scalar=local
+>array=( l o c a l )
+>local scalar
+>array local array
>scalar a r r a y
declare +m scalar
@@ -110,6 +157,9 @@
print $outer
0:Global export
>outer
+>export outer=outer
+>outer=outer
+>outer
>outer
scope11
@@ -130,18 +180,30 @@
print $f
float -F f
print $f
+ typeset -p f
+ typeset -m f
+ typeset +m f
0:Floating point, adding a precision, and fixed point
>float local f
>3.14e+00
>3.142
+>typeset -F f=3.142
+>f=3.142
+>float local f
integer i=3.141
typeset +m i
integer -i2 i
print $i
+ typeset -p i
+ typeset -m i
+ typeset +m i
0:Integer and changing the base
>integer local i
>2#11
+>typeset -i2 i=3
+>i=3
+>integer 2 local i
float -E3 f=3.141
typeset +m f
@@ -174,16 +236,33 @@
typeset -gU array
print $array
+ typeset -p array
+ typeset -m array
+ typeset +m array
0:Uniquified arrays and non-local scope
>a r y
+>typeset -g -aU array=( a r y )
+>array=( a r y )
+>array unique array
typeset -T SCALAR=l:o:c:a:l array
print $array
typeset -U SCALAR
print $SCALAR $array
+ typeset -p SCALAR array
+ typeset -m SCALAR array
+ typeset +m SCALAR array
+ print ${(t)SCALAR} ${(t)array}
0:Tied parameters and uniquified colon-arrays
>l o c a l
>l:o:c:a l o c a
+>typeset -UT SCALAR array=( l o c a )
+>typeset -aT SCALAR array=( l o c a )
+>SCALAR=l:o:c:a
+>array=( l o c a )
+>local unique tied array SCALAR
+>array local tied SCALAR array
+>scalar-local-tied-unique array-local-tied
(setopt NO_multibyte cbases
LC_ALL=C 2>/dev/null
@@ -209,9 +288,18 @@
typeset -T SCALAR=$'l\000o\000c\000a\000l' array $'\000'
typeset -U SCALAR
print $array
+ typeset -p SCALAR array
+ typeset -m SCALAR array
+ typeset +m SCALAR array
[[ $SCALAR == $'l\000o\000c\000a' ]]
0:Tied parameters and uniquified arrays with NUL-character as separator
>l o c a
+>typeset -UT SCALAR array=( l o c a ) ''
+>typeset -aT SCALAR array=( l o c a ) ''
+>SCALAR=$'l\C-@o\C-@c\C-@a'
+>array=( l o c a )
+>local unique tied array SCALAR
+>array local tied SCALAR array
typeset -T SCALAR array
typeset +T SCALAR
@@ -223,15 +311,30 @@
print $OUTER
0:Export of tied parameters
>i:n:n:e:r
+>typeset -xT OUTER outer=( i n n e r )
+>typeset -aT OUTER outer=( i n n e r )
+>OUTER=i:n:n:e:r
+>outer=( i n n e r )
+>local exported tied outer OUTER
+>array local tied OUTER outer
>outer
typeset -TU MORESTUFF=here-we-go-go-again morestuff '-'
print -l $morestuff
+ typeset -p MORESTUFF morestuff
+ typeset -m MORESTUFF morestuff
+ typeset +m MORESTUFF morestuff
0:Tied arrays with separator specified
>here
>we
>go
>again
+>typeset -UT MORESTUFF morestuff=( here we go again ) -
+>typeset -aUT MORESTUFF morestuff=( here we go again ) -
+>MORESTUFF=here-we-go-again
+>morestuff=( here we go again )
+>local unique tied morestuff MORESTUFF
+>array local unique tied MORESTUFF morestuff
typeset -T THIS will not work
1:Tied array syntax
@@ -251,13 +354,25 @@
local b=1 ;: to stomp assoc[1] if assoc[b] is broken
typeset assoc[1]=a assoc[b]=2 assoc[3]=c
print $assoc[1] $assoc[b] $assoc[3]
+ typeset -p assoc
+ typeset -m assoc
+ typeset +m assoc
0:Legal local associative array element assignment
>a 2 c
+>typeset -A assoc=( [1]=a [3]=c [b]=2 )
+>assoc=( [1]=a [3]=c [b]=2 )
+>association local assoc
local scalar scalar[1]=a scalar[2]=b scalar[3]=c
print $scalar
+ typeset -p scalar
+ typeset -m scalar
+ typeset +m scalar
0:Local scalar subscript assignment
>abc
+>typeset scalar=abc
+>scalar=abc
+>local scalar
typeset -L 10 fools
for fools in " once" "twice" " thrice" " oops too long here"; do
@@ -273,11 +388,17 @@
for foolf in 1.3 4.6 -2.987 -4.91031; do
print "'$foolf'"
done
+ typeset -p foolf
+ typeset -m foolf
+ typeset +m foolf
0:Left justification of floating point
>'1.300 '
>'4.600 '
>'-2.987 '
>'-4.910 '
+>typeset -FL10 foolf=-4.910
+>foolf=-4.910
+>float local left justified 10 foolf
typeset -L 10 -Z foolzs
for foolzs in 001.3 04.6 -2.987 -04.91231; do
@@ -293,10 +414,16 @@
for foors in short longer even-longer; do
print "'$foors'"
done
+ typeset -p foors
+ typeset -m foors
+ typeset +m foors
0:Right justification of scalars
>' short'
>' longer'
>'ven-longer'
+>typeset -R10 foors=even-longer
+>foors=even-longer
+>local right justified 10 foors
typeset -Z 10 foozs
for foozs in 42 -42 " 43" " -43"; do
@@ -436,24 +563,36 @@
print $case1
upper="VALUE OF \$UPPER"
print ${(P)case1}
+ typeset -p case1
+ typeset -m case1
+ typeset +m case1
0:Upper case conversion, does not apply to values used internally
>UPPER
>VALUE OF $UPPER
+>typeset -u case1=upper
+>case1=upper
+>local uppercase case1
local case2=LOWER
typeset -l case2
print $case2
LOWER="value of \$lower"
print ${(P)case2}
+ typeset -p case2
+ typeset -m case2
+ typeset +m case2
0:Lower case conversion, does not apply to values used internally
>lower
>value of $lower
+>typeset -l case2=LOWER
+>case2=LOWER
+>local lowercase case2
typeset -a array
array=(foo bar)
fn() { typeset -p array nonexistent; }
fn
-1:declare -p shouldn't create scoped values
+1:typeset -p shouldn't create scoped values
>typeset -g -a array=( foo bar )
?fn:typeset: no such variable: nonexistent
@@ -490,7 +629,7 @@
?0
?(eval):5: read-only variable: pbro
?(eval):6: read-only variable: pbro
-?typeset -g -r pbro
+?readonly pbro
?0
?(eval):10: read-only variable: pbro
@@ -819,3 +958,146 @@
> [one]=two
> [three]=''
>)
+
+ (export PATH MANPATH
+ path=(/bin)
+ MANPATH=/
+ # read-only special params like zsh_eval_context are not output by typeset -p
+ specials=(path PATH manpath MANPATH zsh_eval_context ZSH_EVAL_CONTEXT)
+ typeset -p $specials
+ typeset -m $specials
+ typeset +m $specials
+ for var ($specials) print $var: ${(Pt)var}
+ )
+0:typeset output for some special tied parameters
+>typeset -g -aT PATH path=( /bin )
+>export -T PATH path=( /bin )
+>typeset -g -aT MANPATH manpath=( / )
+>export -T MANPATH manpath=( / )
+>path=( /bin )
+>PATH=/bin
+>manpath=( / )
+>MANPATH=/
+>zsh_eval_context=( toplevel shfunc shfunc shfunc eval )
+>ZSH_EVAL_CONTEXT=toplevel:shfunc:shfunc:shfunc:eval
+>array tied PATH path
+>tied path PATH
+>array tied MANPATH manpath
+>tied manpath MANPATH
+>array readonly tied ZSH_EVAL_CONTEXT zsh_eval_context
+>readonly tied zsh_eval_context ZSH_EVAL_CONTEXT
+>path: array-tied-special
+>PATH: scalar-tied-export-special
+>manpath: array-tied-special
+>MANPATH: scalar-tied-export-special
+>zsh_eval_context: array-readonly-tied-special
+>ZSH_EVAL_CONTEXT: scalar-readonly-tied-special
+
+ typeset -T VAR var=(a b a b)
+ typeset -UuT VAR var +
+ print $VAR
+0:redeclare a tied variable with different attributes
+>A+B
+
+ typeset -T VAR=a+b var
+ typeset -T VAR var +
+ print $var
+0:colonarray re-split when changing the join character
+>a b
+
+ readonly -T VAR var=(a b)
+ readonly -T VAR var +
+1:cannot change the join character on a readonly tied variable
+?(eval):1: read-only variable: var
+
+ typeset -T FOO manpath
+1:Can't tie a special tied array to a different variable
+?(eval):typeset:1: manpath special parameter can only be tied to special parameter MANPATH
+
+ typeset -T MANPATH foo
+1:Can't tie a special tied scalar to a different variable
+?(eval):typeset:1: MANPATH special parameter can only be tied to special parameter manpath
+
+ typeset -T MANPATH manpath +
+1:Can't change the join character of a special tied variable
+?(eval):typeset:1: cannot change the join character of special tied parameters
+
+ (){
+ typeset -h path
+ typeset -T PATH path=(x)
+ }
+ (){
+ typeset -h PATH
+ typeset -T PATH path=(x)
+ }
+1:reject attempt to tie special to downgraded peer
+?(anon):typeset:2: PATH special parameter can only be tied to special parameter path
+?(anon):typeset:2: path special parameter can only be tied to special parameter PATH
+
+ typeset MANPATH
+ manpath=(/ /)
+ typeset -UT MANPATH manpath
+ print $manpath
+0:OK to run typeset -T on tied specials as long as peer and joinchar are unchanged
+>/
+
+ typeset FOO=a:b
+ export FOO
+ typeset +x -T FOO foo
+ typeset -p FOO
+0:Make sure +x is honoured when tying a parameter
+>typeset -T FOO foo=( a b )
+
+ $ZTST_testdir/../Src/zsh --emulate sh -f -c '
+ PATH=/bin; export PATH; readonly PATH
+ export -p PATH
+ typeset -p PATH
+ readonly -p'
+0: readonly/export output for exported+readonly+special when started as sh
+>export PATH=/bin
+>export -r PATH=/bin
+>readonly PATH=/bin
+
+ function {
+ emulate -L sh
+ MANPATH=/bin; export MANPATH; readonly MANPATH
+ export -p MANPATH
+ typeset -p MANPATH
+ readonly -p
+ }
+0: readonly/export output for exported+readonly+tied+special after switching to sh emulation
+>export MANPATH=/bin
+>export -rT MANPATH manpath=( /bin )
+>readonly MANPATH=/bin
+
+ function {
+ local -rax zsh_exported_readonly_array=(2)
+ local -rAx zsh_exported_readonly_hash=(3 3)
+ local -rx zsh_exported_readonly_scalar=1
+ print zsh:
+ export -p | grep zsh_exported_readonly
+ readonly -p | grep zsh_exported_readonly
+ print sh:
+ emulate -L sh
+ export -p | grep zsh_exported_readonly
+ readonly -p | grep zsh_exported_readonly
+ print still asking for arrays:
+ export -ap | grep zsh_exported_readonly
+ readonly -ap | grep zsh_exported_readonly
+ }
+0: no array/hash in POSIX export/readonly -p
+>zsh:
+>typeset -arx zsh_exported_readonly_array=( 2 )
+>typeset -Arx zsh_exported_readonly_hash=( [3]=3 )
+>typeset -rx zsh_exported_readonly_scalar=1
+>typeset -arx zsh_exported_readonly_array=( 2 )
+>typeset -Arx zsh_exported_readonly_hash=( [3]=3 )
+>typeset -rx zsh_exported_readonly_scalar=1
+>sh:
+>export zsh_exported_readonly_scalar=1
+>readonly zsh_exported_readonly_scalar=1
+>still asking for arrays:
+>export zsh_exported_readonly_array=( 2 )
+>export zsh_exported_readonly_scalar=1
+>readonly zsh_exported_readonly_array=( 2 )
+>readonly zsh_exported_readonly_scalar=1
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index dce263f94..4aebd92b7 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -863,6 +863,25 @@ F:Must be tested with a top-level script rather than source or function
>a
>b
+ $ZTST_testdir/../Src/zsh -fc 'fn() { exit 13; }; trap fn EXIT; exit'
+13:Explicit exit in exit trap overrides status
+
+ $ZTST_testdir/../Src/zsh -fc 'fn() { exit $?+8; }; trap fn EXIT; exit 7'
+15:Progated exit status through exit trap
+
+ $ZTST_testdir/../Src/zsh -fc 'fn() { exit 13; }; trap fn EXIT'
+13:Explicit exit in exit trap overrides implicit exit status
+
+ $ZTST_testdir/../Src/zsh -fc 'fn() { exit 0; }; trap fn EXIT; false'
+0:Explicit exit status 0 in exit trap overrides implicit non-zero status
+
+ $ZTST_testdir/../Src/zsh -f <<<'fn() { exit 13; }; trap fn EXIT; false'
+13:Exit status from exit trap, script-like path
+
+ $ZTST_testdir/../Src/zsh -f <<<'fn() { exit 0; }; trap fn EXIT; false'
+0:Explicit exit status overrides implicit: script-like code path
+
%clean
rm -f TRAPEXIT
+
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index e327a784c..7ab2384aa 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2430,3 +2430,10 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
)
0:Use of parameter subst + to test element of hash with KSH_ARRAYS.
>0
+
+ for baz in "" "inga"; do
+ echo ${#${baz}} "${#${baz}}" ${#baz} "${#baz}"
+ done
+0:double-quoted nested evaluation of empty string
+>0 0 0 0
+>4 4 4 4
diff --git a/Test/V07pcre.ztst b/Test/V07pcre.ztst
index 9feeb47fb..ab67f3d80 100644
--- a/Test/V07pcre.ztst
+++ b/Test/V07pcre.ztst
@@ -1,11 +1,10 @@
%prep
- if ! zmodload -F zsh/pcre C:pcre-match 2>/dev/null
+ if grep '^name=zsh/pcre .* link=no ' $ZTST_testdir/../config.modules >/dev/null
then
- ZTST_unimplemented="the zsh/pcre module is not available"
+ ZTST_unimplemented="the zsh/pcre module was disabled by configure (see config.modules)"
return 0
fi
-# Load the rest of the builtins
zmodload zsh/pcre
setopt rematch_pcre
# Find a UTF-8 locale.
diff --git a/Test/V09datetime.ztst b/Test/V09datetime.ztst
index ffad96c04..22d560750 100644
--- a/Test/V09datetime.ztst
+++ b/Test/V09datetime.ztst
@@ -82,3 +82,32 @@
# The result can be '%@' (Linux), '@' (BSDs) or an error (Cygwin).
[[ $(strftime '%@' 0 2> /dev/null) == (%|)@ || $? != 0 ]]
0:bad format specifier
+
+# This test may fail at 23:59:59.xxx on New Year's Eve :/
+ [[ "$( strftime '%Y' )" == "$( strftime '%Y' "$EPOCHSECONDS" )" ]]
+0:epochtime optional
+
+ strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322
+ strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 0
+ strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 2
+ strftime '%Y-%m-%d %H:%M:%S.%3.' 1012615322 $(( 222 * (10 ** 9) ))
+0:optional nanoseconds
+>2002-02-02 02:02:02.000
+>2002-02-02 02:02:02.000
+>2002-02-02 02:02:02.000
+>2002-02-02 02:02:02.222
+
+ strftime '%Y' '' 2> /dev/null
+1:empty epochtime not allowed
+
+ strftime '%Y' 1012615322 '' 2> /dev/null
+1:empty nanoseconds not allowed
+
+ strftime '%N' 1012615322 ${(l<64><9>):-} 2> /dev/null
+1:overflowed nanoseconds not allowed
+
+ strftime '%N' 1012615322 -1 2> /dev/null
+1:negative nanoseconds not allowed
+
+ strftime -r '%Y' 2> /dev/null
+1:-r timestring not optional