summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
Diffstat (limited to 'Test')
-rw-r--r--Test/A02alias.ztst39
-rw-r--r--Test/A04redirect.ztst34
-rw-r--r--Test/A05execution.ztst46
-rw-r--r--Test/A06assign.ztst38
-rw-r--r--Test/A07control.ztst53
-rw-r--r--Test/B02typeset.ztst17
-rw-r--r--Test/B06fc.ztst14
-rw-r--r--Test/B07emulate.ztst4
-rw-r--r--Test/C01arith.ztst103
-rw-r--r--Test/C02cond.ztst38
-rw-r--r--Test/C04funcdef.ztst12
-rw-r--r--Test/D02glob.ztst2
-rw-r--r--Test/D04parameter.ztst65
-rw-r--r--Test/D07multibyte.ztst20
-rw-r--r--Test/D08cmdsubst.ztst42
-rw-r--r--Test/E01options.ztst39
-rw-r--r--Test/V07pcre.ztst4
-rw-r--r--Test/V08zpty.ztst3
-rw-r--r--Test/W01history.ztst60
-rw-r--r--Test/X02zlevi.ztst491
-rw-r--r--Test/Y01completion.ztst4
-rw-r--r--Test/Y02compmatch.ztst4
-rw-r--r--Test/Y03arguments.ztst4
-rw-r--r--Test/comptest16
24 files changed, 1110 insertions, 42 deletions
diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst
index 7121c50ef..08163eb52 100644
--- a/Test/A02alias.ztst
+++ b/Test/A02alias.ztst
@@ -42,3 +42,42 @@
cat <(echo foo | cat)
0:Alias expansion works at the end of parsed strings
>foo
+
+ alias -g '&&=(){ return $?; } && '
+ alias not_the_print_command=print
+ eval 'print This is output
+ && print And so is this
+ && { print And this too; false; }
+ && print But not this
+ && print Nor this
+ true
+ && not_the_print_command And aliases are expanded'
+0:We can now alias special tokens. Woo hoo.
+>This is output
+>And so is this
+>And this too
+>And aliases are expanded
+
+ $ZTST_testdir/../Src/zsh -fis <<<'
+ PROMPT=""
+ exec 2>&1
+ alias \{=echo
+ { begin
+ {end
+ fc -l -2' 2>/dev/null
+0:Aliasing reserved tokens
+>begin
+>end
+*>*4*{ begin
+*>*5*{end
+
+ $ZTST_testdir/../Src/zsh -fis <<<'
+ PROMPT=""
+ exec 2>&1
+ alias -g S=\"
+ echo S a string S "
+ fc -l -1' 2>/dev/null
+0:Global aliasing quotes
+> a string S
+*>*4*echo S a string S "
+# Note there is a trailing space on the "> a string S " line
diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst
index a39ce46c8..602341d05 100644
--- a/Test/A04redirect.ztst
+++ b/Test/A04redirect.ztst
@@ -152,11 +152,18 @@
>hello
>goodbye
- ({ exec 3<&- } 2>/dev/null
- exec 3<&-
- read foo <&-)
-1:'<&-' redirection
-*?\(eval\):*: failed to close file descriptor 3:*
+ ({exec 3<&- } 2>/dev/null
+ exec 3<&-
+ read foo <&-)
+1:'<&-' redirection with numeric fd (no error message on failure)
+
+ (exec {varid}<&0
+ exec {varid}<&-
+ print About to close a second time >&2
+ read {varid}<&-)
+1:'<&-' redirection with fd in variable (error message on failure)
+?About to close a second time
+*?\(eval\):*: failed to close file descriptor *
print foo >&-
0:'>&-' redirection
@@ -531,3 +538,20 @@
print $functions[noredirfn]
0:Output from $functions[] for definition with no redirection
> print This rather boring function has no redirection.
+
+ (x=43
+ x=$(print This should appear, really >&2; print Not used) exec >test.log
+ print x=$x)
+ cat test.log
+0:Assignment with exec used for redirection: no POSIX_BUILTINS
+>x=43
+?This should appear, really
+
+ (setopt POSIX_BUILTINS
+ x=45
+ x=$(print This should appear, too >&2; print And this) exec >test.log
+ print x=$x)
+ cat test.log
+0:Assignment with exec used for redirection: POSIX_BUILTINS
+>x=And this
+?This should appear, too
diff --git a/Test/A05execution.ztst b/Test/A05execution.ztst
index ca97f4f41..cc2d34d23 100644
--- a/Test/A05execution.ztst
+++ b/Test/A05execution.ztst
@@ -190,9 +190,9 @@
print "${pipestatus[@]}")
ZTST_hashmark
done | sort | uniq -c | sed 's/^ *//'
-0:Check whether `$pipestatus[]' behaves.
+0:Check whether '$pipestatus[]' behaves.
>2048 2 1 0
-F:This test checks for a bug in `$pipestatus[]' handling. If it breaks then
+F:This test checks for a bug in '$pipestatus[]' handling. If it breaks then
F:the bug is still there or it reappeared. See workers-29973 for details.
{ setopt MONITOR } 2>/dev/null
@@ -244,3 +244,45 @@ F:anonymous function, and a descriptor leak when backgrounding a pipeline
>autoload_redir () {
> print Autoloaded ksh style
>} > autoload.log
+
+# This tests that we record the status of processes that have already exited
+# for when we wait for them.
+#
+# Actually, we don't guarantee here that the jobs have already exited, but
+# the order of the waits means it's highly likely we do need to recall a
+# previous status, barring accidents which shouldn't happen very often. In
+# other words, we rely on the test working repeatedly rather than just
+# once. The monitor option is irrelevant to the logic, so we'll make
+# our job easier by turning it off.
+ { unsetopt MONITOR } 2>/dev/null
+ (exit 1) &
+ one=$!
+ (exit 2) &
+ two=$!
+ (exit 3) &
+ three=$!
+ wait $three
+ print $?
+ wait $two
+ print $?
+ wait $one
+1:The status of recently exited background jobs is recorded
+>3
+>2
+
+# Regression test for workers/34060 (patch in 34065)
+ setopt ERR_EXIT NULL_GLOB
+ if false; then :; else echo if:$?; fi
+ if false; then :; else for x in _*_; do :; done; echo for:$?; fi
+0:False "if" condition handled correctly by "for" loops with ERR_EXIT
+>if:1
+>for:0
+
+# Regression test for workers/34065 (uses setopt from preceding test)
+ select x; do :; done; echo $?
+ select x in; do :; done; echo $?
+ select x in _*_; do :; done; echo $?
+0:The status of "select" is zero when the loop body does not execute
+>0
+>0
+>0
diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst
index 9a0a4f0cc..0ad9a0aca 100644
--- a/Test/A06assign.ztst
+++ b/Test/A06assign.ztst
@@ -1,5 +1,10 @@
# Tests of parameter assignments
+%prep
+ mkdir assign.tmp && cd assign.tmp
+
+ touch tmpfile1 tmpfile2
+
%test
typeset -A assoc
@@ -413,3 +418,36 @@
>world
>worldliness
>world
+
+ integer i n x
+ float f
+ setopt globassign
+ i=tmpfile1
+ n=tmp*
+ x=*2
+ f=2+2
+ typeset -p i n x f
+0:GLOB_ASSIGN with numeric types
+>typeset -i i=0
+>typeset -a n
+>n=(tmpfile1 tmpfile2)
+>typeset x=tmpfile2
+>typeset -E f=4.000000000e+00
+
+ A=(first second)
+ A="${A[*]}" /bin/sh -c 'echo $A'
+ print -l "${A[@]}"
+0:command execution with assignments shadowing array parameter
+>first second
+>first
+>second
+
+ setopt ksharrays
+ A=(first second)
+ A="${A[*]}" /bin/sh -c 'echo $A'
+ print -l "${A[@]}"
+ unsetopt ksharrays
+0:command execution with assignments shadowing array parameter with ksharrays
+>first second
+>first
+>second
diff --git a/Test/A07control.ztst b/Test/A07control.ztst
index 397a821f1..b1a248732 100644
--- a/Test/A07control.ztst
+++ b/Test/A07control.ztst
@@ -110,3 +110,56 @@
done
1:break error case -1
?(eval):break:2: argument is not positive: -1
+
+ false
+ for x in; do
+ print nothing executed
+ done
+0:Status 0 from for with explicit empty list
+
+ set --
+ false
+ for x; do
+ print nothing executed
+ done
+0:Status 0 from for with implicit empty list
+
+ (exit 2)
+ for x in 1 2; do
+ print $?
+ done
+0:Status from previous command propagated into for loop
+>2
+>0
+
+ false
+ for x in $(echo 1 2; (exit 3)); do
+ print $?
+ done
+0:Status from expansion propagated into for loop
+>3
+>0
+
+ false
+ for x in $(exit 4); do
+ print not executed
+ done
+0:Status from expansion not propagated after unexecuted for loop
+
+ false
+ for x in NonExistentFilePrefix*(N); do
+ print not executed, either
+ done
+0:Status from before for loop not propagated if empty after expansion
+
+ for x in $(echo 1; false); do
+ done
+0:Status reset by empty list in for loop
+
+ false
+ for x in $(echo 1; false); do
+ echo $?
+ (exit 4)
+ done
+4:Last status from loop body is kept even with other funny business going on
+>1
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 51ebc6535..f4fb8ecb9 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -468,3 +468,20 @@
0:retying arrays to same array works
>foo bar
>goo car
+
+ (
+ setopt POSIXBUILTINS
+ readonly pbro
+ print ${+pbro} >&2
+ (typeset pbro=3)
+ (pbro=4)
+ typeset -r pbro # idempotent (no error)...
+ print ${+pbro} >&2 # ...so still readonly...
+ typeset +r pbro # ...can't turn it off
+ )
+1:Readonly with POSIX_BUILTINS
+?0
+?(eval):5: read-only variable: pbro
+?(eval):6: read-only variable: pbro
+?0
+?(eval):9: read-only variable: pbro
diff --git a/Test/B06fc.ztst b/Test/B06fc.ztst
index eb73eaa14..922b0010f 100644
--- a/Test/B06fc.ztst
+++ b/Test/B06fc.ztst
@@ -9,3 +9,17 @@
$ZTST_testdir/../Src/zsh -f ./fcl
1:Checking that fc -l foo doesn't core dump when history is empty
?./fcl:fc:1: event not found: foo
+
+ PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< $'fc -p /dev/null 0 0\n:'
+0:Checking that fc -p doesn't core dump when history size is zero
+*?*%*
+
+ PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null a 0'
+1:Checking that fc -p rejects non-integer history size
+*?*% fc: HISTSIZE must be an integer
+*?*%*
+
+ PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null 0 a'
+1:Checking that fc -p rejects non-integer history save size
+*?*% fc: SAVEHIST must be an integer
+*?*%*
diff --git a/Test/B07emulate.ztst b/Test/B07emulate.ztst
index 315206a20..2de097e25 100644
--- a/Test/B07emulate.ztst
+++ b/Test/B07emulate.ztst
@@ -247,3 +247,7 @@
>extendedglob is initially off
>bareglobqual is still on
>extendedglob is on, too
+
+ emulate sh -c '[[ a == a ]]'
+0:regression test for POSIX_ALIASES reserved words
+F:Some reserved tokens are handled in alias expansion
diff --git a/Test/C01arith.ztst b/Test/C01arith.ztst
index 4c55b961e..e2dfe56fc 100644
--- a/Test/C01arith.ztst
+++ b/Test/C01arith.ztst
@@ -16,7 +16,13 @@
print -- $(( rnd = there * 10000 ))
# save rounding problems by converting to integer
0:basic floating point arithmetic
->31415.
+>31415
+
+ integer rnd
+ (( rnd = ((29.1 % 13.0 * 10) + 0.5) ))
+ print $rnd
+0:Test floating point modulo function
+>31
print $(( 0x10 + 0X01 + 2#1010 ))
0:base input
@@ -286,3 +292,98 @@
env SHLVL=1+RANDOM $ZTST_testdir/../Src/zsh -f -c 'print $SHLVL'
0:Imported integer functions are not evaluated
>2
+
+ print $(( 0b0 + 0b1 + 0b11 + 0b110 ))
+0:Binary input
+>10
+
+ print $(( 0b2 ))
+1:Binary numbers don't tend to have 2's in
+?(eval):1: bad math expression: operator expected at `2 '
+# ` for emacs shell mode
+
+ integer varassi
+ print $(( varassi = 5.5 / 2.0 ))
+ print $varassi
+0:Integer variable assignment converts result to integer
+>2
+>2
+# It's hard to test for integer to float.
+
+ integer ff1=3 ff2=4
+ print $(( ff1/ff2 ))
+ setopt force_float
+ print $(( ff1/ff2 ))
+ unsetopt force_float
+0:Variables are forced to floating point where necessary
+# 0.75 is exactly representable, don't expect rounding error.
+>0
+>0.75
+
+ # The following tests for a bug that only happens when
+ # backing up over input read a line at a time, so we'll
+ # read the input from stdin.
+ $ZTST_testdir/../Src/zsh -f <<<'
+ print $((echo first command
+ ); echo second command)
+ print third command
+ '
+0:Backing up a line of input when finding out it's not arithmetic
+>first command second command
+>third command
+
+ $ZTST_testdir/../Src/zsh -f <<<'
+ print $((3 +
+ 4))
+ print next line
+ '
+0:Not needing to back up a line when reading multiline arithmetic
+>7
+>next line
+
+ $ZTST_testdir/../Src/zsh -f <<<'
+ print $((case foo in
+ bar)
+ echo not this no, no
+ ;;
+ foo)
+ echo yes, this one
+ ;;
+ esac)
+ print after case in subshell)
+ '
+0:Non-arithmetic subst with command subsitution parse from hell
+>yes, this one after case in subshell
+
+ print "a$((echo one subst)
+ (echo two subst))b"
+0:Another tricky case that is actually a command substitution
+>aone subst
+>two substb
+
+ print "x$((echo one frob); (echo two frob))y"
+0:Same on a single line
+>xone frob
+>two froby
+
+ # This case actually only works by accident: if it wasn't for the
+ # unbalanced parenthesis this would be a valid math substitution.
+ # Hence it's definitely not recommended code. However, it does give
+ # the algorithm an extra check.
+ print $((case foo in
+ foo)
+ print Worked OK
+ ;;
+ esac))
+0:Would-be math expansion with extra parenthesis making it a cmd subst
+>Worked OK
+
+ (setopt extendedglob
+ set -- 32.463
+ print ${$(( $1 * 100 ))%%.[0-9]#})
+0:Arithmetic substitution nested in parameter substitution
+>3246
+
+ print $((`:`))
+0:Null string in arithmetic evaluation after command substitution
+>0
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 69001476c..6581b9d6b 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -8,11 +8,28 @@
cd cond.tmp
- touch unmodified
+ typeset -gi isnfs
+ [[ "$(find . -prune -fstype nfs 2>/dev/null)" == "." ]] && isnfs=1
+ if (( isnfs )) &&
+ (cd -q ${TMPPREFIX:h} >/dev/null 2>&1 &&
+ [[ "$(find . -prune -fstype nfs 2>/dev/null)" != "." ]]); then
+ filetmpprefix=${TMPPREFIX}-$$-
+ isnfs=0
+ else
+ filetmpprefix=
+ fi
+ newnewnew=${filetmpprefix}newnewnew
+ unmodified=${filetmpprefix}unmodified
+ zlnfs=${filetmpprefix}zlnfs
+
+ touch $unmodified
touch zerolength
chgrp $EGID zerolength
+ touch $zlnfs
+ chgrp $EGID $zlnfs
+
print 'Garbuglio' >nonzerolength
mkdir modish
@@ -131,19 +148,19 @@
print -u $ZTST_fd 'This test takes two seconds...'
sleep 2
- cat unmodified
- touch newnewnew
+ cat $unmodified
+ touch $newnewnew
if [[ $OSTYPE == "cygwin" ]]; then
print -u$ZTST_fd "Warning: not testing [[ -N file ]] (not supported on Cygwin)"
true
- elif [[ "$(find . -prune -fstype nfs 2>/dev/null)" == "." ]]; then
+ elif (( isnfs )); then
print -u$ZTST_fd "Warning: not testing [[ -N file ]] (not supported with NFS)"
true
elif test -f /etc/mtab && { grep $(df . 2>/dev/null| tail -n1 | awk '{print $1}') /etc/mtab | grep -q noatime; }; then
print -u$ZTST_fd "Warning: not testing [[ -N file ]] (not supported with noatime file system)"
true
else
- [[ -N newnewnew && ! -N unmodified ]]
+ [[ -N $newnewnew && ! -N $unmodified ]]
fi
0:-N cond
F:This test can fail on NFS-mounted filesystems as the access and
@@ -153,10 +170,10 @@ F:are not recorded. Also, Linux ext3 filesystems may be mounted
F:with the noatime option which does not update access times.
F:Failures in these cases do not indicate a problem in the shell.
- [[ newnewnew -nt zerolength && ! (unmodified -nt zerolength) ]]
+ [[ $newnewnew -nt $zlnfs && ! ($unmodified -nt $zlnfs) ]]
0:-nt cond
- [[ zerolength -ot newnewnew && ! (zerolength -ot unmodified) ]]
+ [[ $zlnfs -ot $newnewnew && ! ($zlnfs -ot $unmodified) ]]
0:-ot cond
[[ link -ef zerolength && ! (link -ef nonzerolength) ]]
@@ -234,8 +251,8 @@ F:Failures in these cases do not indicate a problem in the shell.
fn() {
# careful: first file must exist to trigger bug
- [[ -e unmodified ]] || print Where\'s my file\?
- [[ unmodified -nt NonExistentFile ]]
+ [[ -e $unmodified ]] || print Where\'s my file\?
+ [[ $unmodified -nt NonExistentFile ]]
print status = $?
}
fn
@@ -360,3 +377,6 @@ F:Failures in these cases do not indicate a problem in the shell.
%clean
# This works around a bug in rm -f in some versions of Cygwin
chmod 644 unmodish
+ for tmpfile in $newnewnew $unmodified $zlnfs; do
+ [[ -f $tmpfile ]] && rm -f $tmpfile
+ done
diff --git a/Test/C04funcdef.ztst b/Test/C04funcdef.ztst
index 10491a229..74f881587 100644
--- a/Test/C04funcdef.ztst
+++ b/Test/C04funcdef.ztst
@@ -271,6 +271,7 @@
>OK
>ignorebraces is off
>ignorebraces is still on here
+#` (matching error message for editors parsing the file)
# lsfoo should not be expanded as an anonymous function argument
alias lsfoo='This is not ls.'
@@ -283,6 +284,17 @@
0:Simple anonymous function should not simplify enclosing pipeline
>foo
+ alias fooalias=barexpansion
+ funcwithalias() { echo $(fooalias); }
+ functions funcwithalias
+ barexpansion() { print This is the correct output.; }
+ funcwithalias
+0:Alias expanded in command substitution does not appear expanded in text
+>funcwithalias () {
+> echo $(fooalias)
+>}
+>This is the correct output.
+
%clean
rm -f file.in file.out
diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
index 217ce7c06..3e2095a0c 100644
--- a/Test/D02glob.ztst
+++ b/Test/D02glob.ztst
@@ -548,6 +548,7 @@
(){ print "Negated:" $@:t } glob.tmp/dir*(Y1^Y)
(){ print "Sorting:" $@:t } glob.tmp/dir*(Y4On)
(){ [[ $#@ -eq 1 ]] && print Globs before last path component } glob.tmp/dir?/subdir(NY1)
+ (){ [[ $1 == glob.tmp/a ]] } glob.tmp/**/a(Y1) && print Breadth first
(){ [[ $#@ -eq 0 ]] && print Respects qualifiers } glob.tmp/dir*(NY1.)
(print -- *(Y)) 2>/dev/null || print "Argument required"
0:short-circuit modifier
@@ -558,6 +559,7 @@
>Negated: dir1 dir2 dir3 dir4
>Sorting: dir4 dir3 dir2 dir1
>Globs before last path component
+>Breadth first
>Respects qualifiers
>Argument required
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 49dcea901..42c7b4ec6 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1548,7 +1548,7 @@
foo=
print ${foo:wq}
print ${:wq}
-0:Empty parameter shouldn't cause modifiers to crash the shell
+0:Empty parameter should not cause modifiers to crash the shell
>
>
@@ -1636,3 +1636,66 @@
print ${noexist:^foo})
1:Zipping arrays, NO_UNSET part 2
?(eval):2: noexist: parameter not set
+
+ expr="a@b,c@d:e@f,g@h:i@j,k@l"
+ for sep in : , @; do
+ print -l ${(ps.$sep.)expr}
+ done
+0:Use of variable to get separator when splitting parameter
+>a@b,c@d
+>e@f,g@h
+>i@j,k@l
+>a@b
+>c@d:e@f
+>g@h:i@j
+>k@l
+>a
+>b,c
+>d:e
+>f,g
+>h:i
+>j,k
+>l
+
+ SHLVL=1
+ $ZTST_testdir/../Src/zsh -fc 'echo $SHLVL'
+ $ZTST_testdir/../Src/zsh -fc '(echo $SHLVL)'
+0:SHLVL appears sensible when about to exit shell
+>2
+>2
+
+# The following tests the return behaviour of parsestr/parsestrnoerr
+ alias param-test-alias='print $'\''\x45xpanded in substitution'\'
+ param='$(param-test-alias)'
+ print ${(e)param}
+0:Alias expansion in command substitution in parameter evaluation
+>Expanded in substitution
+
+ a=1 b=2 c=3
+ : One;
+ function {
+ : Two
+ echo $_
+ print -l $argv
+ } $_ Three
+ print -l $_ Four;
+0:$_ with anonymous function
+>Two
+>One
+>Three
+>Three
+>Four
+
+ a=1 b=2 c=3
+ : One
+ function {
+ : Two
+ echo $_
+ print -l $argv
+ }
+ print -l "$_" Four
+0:$_ with anonymous function without arguments
+>Two
+>
+>
+>Four
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index 2cb995346..33e76bee7 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -448,20 +448,30 @@
0:read passes through invalid multibyte characters
>0xC5
- word=abcま
+ word=abcま
word[-1]=
print $word
- word=abcま
+ word=abcま
word[-2]=
print $word
- word=abcま
+ word=abcま
word[4]=d
print $word
- word=abcま
+ word=abcま
word[3]=not_c
- print $word
+ print $word
0:assignment with negative indices
>abc
>abま
>abcd
>abnot_cま
+
+ # The following doesn't necessarily need UTF-8, but this gives
+ # us the full effect --- if we parse this wrongly the \xe9
+ # in combination with the tokenized input afterwards looks like a
+ # valid UTF-8 character. But it isn't.
+ print $'$\xe9#``' >test_bad_param
+ (setopt nonomatch
+ . ./test_bad_param)
+127:Invalid parameter name with following tokenized input
+?./test_bad_param:1: command not found: $\M-i#
diff --git a/Test/D08cmdsubst.ztst b/Test/D08cmdsubst.ztst
index 5661b0aaa..a4c69a010 100644
--- a/Test/D08cmdsubst.ztst
+++ b/Test/D08cmdsubst.ztst
@@ -106,3 +106,45 @@
>34
>"
>" OK
+
+ echo $(case foo in
+ foo)
+ echo This test worked.
+ ;;
+ bar)
+ echo This test failed in a rather bizarre way.
+ ;;
+ *)
+ echo This test failed.
+ ;;
+ esac)
+0:Parsing of command substitution with unmatched parentheses: case, basic
+>This test worked.
+
+ echo "$(case bar in
+ foo)
+ echo This test spoobed.
+ ;;
+ bar)
+ echo This test plurbled.
+ ;;
+ *)
+ echo This test bzonked.
+ ;;
+ esac)"
+0:Parsing of command substitution with unmatched parentheses: case with quotes
+>This test plurbled.
+
+ echo before $(
+ echo start; echo unpretentious |
+ while read line; do
+ case $line in
+ u*)
+ print Word began with u
+ print and ended with a crunch
+ ;;
+ esac
+ done | sed -e 's/Word/Universe/'; echo end
+ ) after
+0:Parsing of command substitution with ummatched parentheses: with frills
+>before start Universe began with u and ended with a crunch end after
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index 46b183776..5c453c80b 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -783,14 +783,37 @@
>print is a shell builtin
?(eval):8: command not found: print
-# This option seems to be problematic. I don't quite know how it works.
-## func() {
-## setopt localoptions printexitvalue
-## false
-## }
-## func
-## 1:PRINT_EXIT_VALUE option
-## ?(eval):2: exit 1
+ # With non-special command: original value restored
+ # With special builtin: new value kept
+ # With special builtin preceeded by "command": original value restored.
+ (setopt posixbuiltins
+ FOO=val0
+ FOO=val1 true; echo $FOO
+ FOO=val2 times 1>/dev/null 2>&1; echo $FOO
+ FOO=val3 command times 1>/dev/null 2>&1; echo $FOO)
+0:POSIX_BUILTINS and restoring variables
+>val0
+>val2
+>val2
+
+# PRINTEXITVALUE only works if shell input is coming from standard input.
+# Goodness only knows why.
+ $ZTST_testdir/../Src/zsh -f <<<'
+ setopt printexitvalue
+ func() {
+ false
+ }
+ func
+ '
+1:PRINT_EXIT_VALUE option
+?zsh: exit 1
+
+ $ZTST_testdir/../Src/zsh -f <<<'
+ setopt printexitvalue
+ () { false; }
+ '
+1:PRINT_EXIT_VALUE option for anonymous function
+?zsh: exit 1
setopt promptbang
print -P !
diff --git a/Test/V07pcre.ztst b/Test/V07pcre.ztst
index 3a65331b3..ddfd3f5cd 100644
--- a/Test/V07pcre.ztst
+++ b/Test/V07pcre.ztst
@@ -1,10 +1,12 @@
%prep
- if ! zmodload zsh/pcre 2>/dev/null
+ if ! zmodload -F zsh/pcre C:pcre-match 2>/dev/null
then
ZTST_unimplemented="the zsh/pcre module is not available"
return 0
fi
+# Load the rest of the builtins
+ zmodload zsh/pcre
setopt rematch_pcre
# Find a UTF-8 locale.
setopt multibyte
diff --git a/Test/V08zpty.ztst b/Test/V08zpty.ztst
index 5b08fc281..b0cbfa050 100644
--- a/Test/V08zpty.ztst
+++ b/Test/V08zpty.ztst
@@ -6,7 +6,8 @@
if ! zmodload zsh/zpty 2>/dev/null
then
ZTST_unimplemented="the zsh/zpty module is not available"
- return 0
+ elif [[ $OSTYPE = cygwin ]]; then
+ ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
fi
%test
diff --git a/Test/W01history.ztst b/Test/W01history.ztst
new file mode 100644
index 000000000..6ef9b11cc
--- /dev/null
+++ b/Test/W01history.ztst
@@ -0,0 +1,60 @@
+# Tests for BANG_HIST replacements
+
+%prep
+
+ if [[ -t 0 ]]; then print -u $ZTST_fd History tests write to /dev/tty; fi
+
+%test
+
+ $ZTST_testdir/../Src/zsh -fis <<<'
+ print one two three four five six seven eight nine ten
+ print !:$ !:10 !:9 !:1 !:0
+ print one two three four five six seven eight nine ten
+ print !:0-$ !:1-2
+ ' 2>/dev/null
+0:History word references
+>one two three four five six seven eight nine ten
+>ten ten nine one print
+>one two three four five six seven eight nine ten
+>print one two three four five six seven eight nine ten one two
+
+ $ZTST_testdir/../Src/zsh -fis <<<'
+ print line one of an arbitrary series
+ print issue two for some mystery sequence
+ print !-1:5-$
+ print !1:2
+ print !2:2
+ print !-3:1-$
+ ' 2>/dev/null
+0:History line numbering
+>line one of an arbitrary series
+>issue two for some mystery sequence
+>mystery sequence
+>one
+>two
+>mystery sequence
+
+ $ZTST_testdir/../Src/zsh -fis <<<'
+ print All metaphor, Malachi, stilts and all
+ print !1:2:s/,/\\\\?/ !1:2:s/m/shm/:s/,/\!/
+ print !1:2:&
+ print -l !1:2-3:gs/a/o/
+ ' 2>/dev/null
+0:History substitution
+>All metaphor, Malachi, stilts and all
+>metaphor? shmetaphor!
+>metaphor!
+>metophor,
+>Molochi,
+
+ $ZTST_testdir/../Src/zsh -fis <<<'
+ echo foo bar
+ echo $(!!) again
+ echo more $( !! )' 2>/dev/null
+0:Regression test for history references in command substitution
+>foo bar
+>foo bar again
+>more foo bar again
+*?*
+F:Check that a history bug introduced by workers/34160 is working again.
+# Discarded line of error output consumes prompts printed by "zsh -i".
diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst
index 19188dfb7..14bc02ef8 100644
--- a/Test/X02zlevi.ztst
+++ b/Test/X02zlevi.ztst
@@ -1,7 +1,9 @@
# Tests of the vi mode of ZLE
%prep
- if ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+ if [[ $OSTYPE = cygwin ]]; then
+ ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
+ elif ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
. $ZTST_srcdir/comptest
comptestinit -v -z $ZTST_testdir/../Src/zsh
else
@@ -10,6 +12,215 @@
%test
+ zletest $'goox\ecld'
+0:change last character in buffer
+>BUFFER: good
+>CURSOR: 4
+
+ zletest $'{ ({[}]) }\e0c%chg'
+0:change forward to matching bracket
+>BUFFER: chg
+>CURSOR: 3
+
+ zletest $'s( match )\ed%'
+0:delete backwards to matching bracket
+>BUFFER: s
+>CURSOR: 0
+
+ zletest $'one\eo\edd'
+0:delete empty line
+>BUFFER: one
+>CURSOR: 0
+
+ zletest $'1\eo\eyya2\epa3'
+0:yank and paste blank line
+>BUFFER: 1
+>2
+>3
+>CURSOR: 5
+
+ zpty_run 'bindkey -r "\e~"'
+ zletest $'\e' $'~aI\e' $'~o\e' \~
+0:swap case on a blank line
+>BUFFER: i
+>
+>CURSOR: 2
+
+ zletest $'\eOword\eO\eraok\ejrxj.rae'
+0:replace character when at end of buffer or newline
+>BUFFER: ok
+>wxrd
+>e
+>CURSOR: 9
+
+ zletest $'two\eOone\ehRreplace'
+0:replace acts like insert at newline
+>BUFFER: oreplace
+>two
+>CURSOR: 8
+
+ zletest $' four\eO\C-v\tthree\eO two\eOone\e3J'
+0:join lines with line count
+>BUFFER: one two three
+> four
+>CURSOR: 7
+
+# like real vi, we just join as many as possible, in vim this beeps
+ zletest $'two\eOone\e3J'
+0:join more lines than possible
+>BUFFER: one two
+>CURSOR: 3
+
+ zletest $'fi\eO\eOif\e2>j'
+0:don't indent blank lines
+>BUFFER: if
+>
+> fi
+>CURSOR: 1
+
+ zletest $'\C-v\ti\e>>'
+0:additional indentation
+>BUFFER: i
+>CURSOR: 2
+
+ zletest $'one\eox\e>k'
+0:indent with one character on final line
+>BUFFER: one
+> x
+>CURSOR: 1
+
+ zletest $'one two\eyb'
+0:yank left moves the cursor
+>BUFFER: one two
+>CURSOR: 4
+
+ zletest $'one two\e0ye'
+0:yank right leaves the cursor
+>BUFFER: one two
+>CURSOR: 0
+
+ zletest $'short\eoand longer\eyk'
+0:yank up line moves cursor up but not to buffer start
+>BUFFER: short
+>and longer
+>CURSOR: 4
+
+ zletest $'one\eotwo\ekyj'
+0:yank down line leaves the cursor
+>BUFFER: one
+>two
+>CURSOR: 2
+
+ zletest $'long\eo s\eolong\ekjy-k'
+0:yank up clears lastcol
+>BUFFER: long
+> s
+>long
+>CURSOR: 2
+
+ zletest $'long\eos\eklljyk'
+0:yank up honours lastcol
+>BUFFER: long
+>s
+>CURSOR: 2
+
+ zletest $'long\eolong\eo s\eolong\ekjd-k'
+0:delete up clears lastcol
+>BUFFER: long
+>long
+>CURSOR: 0
+
+ zletest $'yankee doodle\ebhDyy0"1P'
+0:paste register 1 to get last deletion
+>BUFFER: doodleyankee
+>CURSOR: 6
+
+ zletest $'yankee\eyyodoodle\edd"0p'
+0:paste register 0 to get last yank
+>BUFFER: yankee
+>yankee
+>CURSOR: 7
+
+ zletest $'err\eddahello\e"hddP'
+0:setting named register also sets unnamed register
+>BUFFER: hello
+>
+>CURSOR: 0
+
+ zletest $'first\e"ay0ddasecond\e"Add"aP'
+0:appending to named register
+>BUFFER: firs
+>second
+>
+>CURSOR: 0
+
+ zletest $'word\e"a"byy"bp'
+0:set one and then a different register
+>BUFFER: word
+>word
+>CURSOR: 5
+
+ zletest $'i\exaar\e0"a"_cewn\eP'
+0:set register then set black hole register
+>BUFFER: win
+>CURSOR: 1
+
+ zletest $'double\eyy"_"0P'
+0:reset register after selecting black hole
+>BUFFER: double
+>double
+>CURSOR: 0
+
+# zsh works like vi here; in vim you get the concatenated string
+ zletest $'first\e"addasecond\eddP'
+0:retrieve unnamed register after appending
+>BUFFER: second
+>
+>CURSOR: 0
+
+ zletest $'Z\exayankee doodle\e"_db0"_yeP'
+0:yank and delete to black hole register
+>BUFFER: Zyankee e
+>CURSOR: 0
+
+ zletest $'foo\eddabar\e"_p..'
+0:paste from black hole register and repeat
+>BUFFER: bar
+>CURSOR: 2
+
+ zletest $'start\eFa"ac2lnew\eX"ap..'
+0:repeat paste from named register
+>BUFFER: stnwararart
+>CURSOR: 9
+
+ zpty_run 'bindkey -a "^P" yank-pop'
+ zletest $'word\C-wline\eddiSE\eP\C-P'
+0:line based put before followed by character based yank-pop
+>BUFFER: SwordE
+>CURSOR: 4
+
+ zletest $'line\eddiword\C-w\eiSE\eP\C-P'
+0:character based put before followed by line based yank-pop
+>BUFFER: line
+>SE
+>CURSOR: 0
+
+ zletest $'one two three\C-w\C-w\C-wSE\e0p\C-P\C-P'
+0:put after cycled twice with yank-pop
+>BUFFER: SthreeE
+>CURSOR: 5
+
+ zletest $'word\C-wline\eddiSE\ehp\C-P'
+0:line based put after followed by character based yank-pop
+>BUFFER: SwordE
+>CURSOR: 4
+
+ zletest $'line\eddiword\C-w\eiSE\ehp\C-P'
+0:character based after before followed by line based yank-pop
+>BUFFER: SE
+>line
+>CURSOR: 3
+
zletest $'word\euaend'
0:undo initial change
>BUFFER: end
@@ -61,6 +272,12 @@
>BUFFER: pre
>CURSOR: 2
+ zletest $'two\eOone\eo\euo\eu'
+0:undo starting with a next change in the change list
+>BUFFER: one
+>two
+>CURSOR: 2
+
zpty_run 'bindkey "^Gu" split-undo'
zletest $'one\C-gutwo\eu'
0:split the undo sequence
@@ -72,6 +289,278 @@
>BUFFER: one wo
>CURSOR: 2
+ zletest $'keepnot\eo unwanted\ekhhcvj '
+0:force character-wise change to join lines
+>BUFFER: keep wanted
+>CURSOR: 5
+
+ zletest $'}\eOkeep{del\eF{dvj'
+0:character-wise delete to beginning of line leaves the newline'
+>BUFFER: keep
+>}
+>CURSOR: 3
+
+ zletest $'keep\eOdel\edVh'
+0:force line-wise delete of line
+>BUFFER: keep
+>CURSOR: 0
+
+ zletest $'one two three\eFwdVawaX'
+0:line-wise force of a text object
+>BUFFER: X
+>CURSOR: 1
+
+ zletest $'one two\evbcx'
+0:change selection
+>BUFFER: one x
+>CURSOR: 5
+
+ zletest $'four\eOthree\eOtwo\eOone\evjjhCnew'
+0:change character wise selection with C acts linewise
+>BUFFER: new
+>four
+>CURSOR: 3
+
+ zletest $'x testing\ehvbx'
+0:x kills selections
+>BUFFER: x g
+>CURSOR: 2
+
+ zletest $'line end\eOstart 1 back new\e0verawvrbwevbrcwvj0erdwv$re'
+0:replace characters in selections
+>BUFFER: aaaaa b cccc dddddddd eee
+>CURSOR: 24
+
+ zletest $'one two\eyb0vep'
+0:put over selection at start of buffer
+>BUFFER: tw two
+>CURSOR: 1
+
+ zletest $'hello\C-wbye\evhp'
+0:put over selection at end of buffer
+>BUFFER: bhello
+>CURSOR: 5
+
+ zletest $'old\C-w\evyvP'
+0:yank empty selection
+>BUFFER: old
+>CURSOR: 2
+
+ zletest $'old\C-w\evdvP'
+0:delete empty selection
+>BUFFER: old
+>CURSOR: 2
+
+ zletest $'one\eotwo\eyykVp'
+0:yank linewise and put over linewise selection at start of buffer
+>BUFFER: two
+>two
+>CURSOR: 0
+
+ zletest $'one\eotwo\eothree\eyykVp'
+0:yank linewise and put over linewise selection in middle of buffer
+>BUFFER: one
+>three
+>three
+>CURSOR: 4
+
+ zletest $'two\eOone\eyyjVp'
+0:yank linewise and put over linewise selection at end of buffer
+>BUFFER: one
+>one
+>CURSOR: 4
+
+ zletest $'one\eyhVp'
+0:yank character-wise and put over linewise selection
+>BUFFER: n
+>CURSOR: 0
+
+# vim puts a blank line above in this test
+ zletest $'one\eotwo\eyy0kvlp'
+0:yank linewise and put over character-wise selection at start of buffer
+>BUFFER: two
+>e
+>two
+>CURSOR: 0
+
+ zletest $'one\eyyhvp'
+0:yank linewise and put over character-wise selection in middle of buffer
+>BUFFER: o
+>one
+>e
+>CURSOR: 2
+
+# vim behaviour on this one really looks like a bug
+ zletest $'two\eOone\eyyjvhp'
+0:yank linewise and put over character-wise selection at end of buffer
+>BUFFER: one
+>t
+>one
+>CURSOR: 6
+
+ zletest $'abc123456789\exxxxxxxxxhv"9p0P'
+0:paste last (9th) register over a selection
+>BUFFER: ba9c
+>CURSOR: 0
+
+ zletest $'one\eo\eo\eotwo\ekkVdvd'
+0:delete blank line using selection
+>BUFFER: one
+>two
+>CURSOR: 4
+
+ zletest $'One Two Three\e2bvw~'
+0:toggle case of selection
+>BUFFER: One tWO three
+>CURSOR: 4
+
+ zletest $' --ww ww--\eo\eoww\eo\eo--\eo\eo ww\e' bi{a,b,c,d,e,f,g,h,i,j,k}$'\e'
+0:backward word
+>BUFFER: k j--iww hwwg--
+>f
+>eww
+>d
+>c--
+>b
+> aww
+>CURSOR: 0
+
+ zletest $' --ww ww--\eo\eoww\eo\eo--\eo\eo ww\e' Bi{a,b,c,d,e,f,g,h,i}$'\e'
+0:backword blank word
+>BUFFER: i h--ww gww--
+>f
+>eww
+>d
+>c--
+>b
+> aww
+>CURSOR: 0
+
+ zletest $' --ww ww--\eo\eoww\eo\eo--\eo\eo ww\e' gei{a,=,b,c,=,d,e,=,f}$'\e'
+0:backward word end
+>BUFFER: f -=-wew wdw-=-
+>c
+>wbw
+>
+>-=-
+>a
+> ww
+>CURSOR: 0
+
+ zletest $' --ww ww--\eo\eoww\eo\eo--\eo\eo ww\e' gEi{=,b,=,d,e}$'\e'
+0:backward blank word end
+>BUFFER: e --wdw ww-=-
+>
+>wbw
+>
+>-=-
+>
+> ww
+>CURSOR: 0
+
+ zletest $' ww\eO\eO--\eO\eOww\eO\eO --ww ww--\e0' wi{=,a,b,=,c,d,e,=,f,g}$'\e'
+0:forward word
+>BUFFER: =--aww bww=--
+>c
+>dww
+>e
+>=--
+>f
+> gww
+>CURSOR: 32
+
+ zletest $' ww\eO\eO--\eO\eOww\eO\eO --ww ww--\e0' Wi{=,a,b,c,d,=,e,f}$'\e'
+0:forward blank word
+>BUFFER: =--ww aww--
+>b
+>cww
+>d
+>=--
+>e
+> fww
+>CURSOR: 30
+
+ zletest $' ww\eO\eO--\eO\eOww\eO\eO --ww ww--\e0' ea{a,b,c,d,e,f,g}$'\e'
+0:forward word end
+>BUFFER: --awwb wwc--d
+>
+>wwe
+>
+>--f
+>
+> wwg
+>CURSOR: 31
+
+ zletest $' ww\eO\eO--\eO\eOww\eO\eO --ww ww--\e0' Ea{a,b,c,d,e}$'\e'
+0:forward blank word end
+>BUFFER: --wwa ww--b
+>
+>wwc
+>
+>--d
+>
+> wwe
+>CURSOR: 29
+
+ zletest $' ----word ---- word word---- ----\e42|daw30|daw22|daw14|daw2|daw'
+0:delete all word on blanks
+>BUFFER: word
+>CURSOR: 0
+
+ zletest $' word----word word----word word \e38|daw30|daw22|daw14|daw6|daw'
+0:delete all word on alphanumerics
+>BUFFER: --------
+>CURSOR: 4
+
+ zletest $' ----word---- ----word---- ---- \e38|daw30|daw22|daw14|daw6|daw'
+0:delete all word on other characters
+>BUFFER: wordword
+>CURSOR: 4
+
+ zletest $'- word word\e4|2daw'
+0:delete all word with numeric argument
+>BUFFER: -
+>CURSOR: 0
+
+ zletest $'---- word ----word\eo \eo----\eodone\eh' \
+ 'vhawmaawmbawmcawmdawmeawmfawmgv`ara`brb`crc$r$`drd`ere`frf`grg'
+0:all word with existing selection and cursor before mark
+>BUFFER: g---f worde ----dord
+>c $
+>b---
+>aone
+>CURSOR: 0
+
+ zletest $'---- word word----\e0lvlawmaawmbawmcawvrd`ara`brb`crc'
+0:all word with existing selection and mark before cursor
+>BUFFER: ---- aword bworc---d
+>CURSOR: 19
+
+ zletest $' --ww ww---\eo\eoww\evhiwiw' m{a,b,c,d,e}iw vrE \`{a,b,c,d,e}r.
+0:in word with existing selection and cursor before mark
+>BUFFER: E.-.w. .w.--
+>
+>ww
+>CURSOR: 1
+
+ zletest $' --ww ww--\eO \ev0o' m{a,b,c,d,e}iw vrE \`{a,b,c,d,e}r.
+0:in word with existing selection and mark before cursor
+>BUFFER: .
+> .-.w. .wE--
+>CURSOR: 10
+
+ zletest $' `one` $(echo two) " three " $\'four\'\C-v\tfive ${six:-6}\e' \
+ vaaom{a,b,c,d,e,f}v \`{a,b,c,d,e,f}rX
+0:all argument for different arguments
+>BUFFER: X `one`X $(echo two)X" three "X$'four'XfiveX${six:-6}
+>CURSOR: 0
+
+ zletest $'{ls `echo x` $((3+4)) "a b" $\'\\t\\n\' ${d%/}\e' \
+ cia{6,5,4,3,2,1}$'\eBB'
+0:in argument for different arguments
+>BUFFER: 1ls `2` $(3) "4" $'5' ${6}
+>CURSOR: 0
+
%clean
zmodload -ui zsh/zpty
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index a2aa00717..383e6529f 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -1,7 +1,9 @@
# Tests for completion system.
%prep
- if ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+ if [[ $OSTYPE = cygwin ]]; then
+ ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
+ elif ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
. $ZTST_srcdir/comptest
mkdir comp.tmp
cd comp.tmp
diff --git a/Test/Y02compmatch.ztst b/Test/Y02compmatch.ztst
index 704580043..db734facc 100644
--- a/Test/Y02compmatch.ztst
+++ b/Test/Y02compmatch.ztst
@@ -11,7 +11,9 @@
# contains the compadd output.
%prep
- if ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+ if [[ $OSTYPE = cygwin ]]; then
+ ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
+ elif ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
. $ZTST_srcdir/comptest
mkdir match.tmp
cd match.tmp
diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst
index bfdcdec63..0627104f5 100644
--- a/Test/Y03arguments.ztst
+++ b/Test/Y03arguments.ztst
@@ -1,7 +1,9 @@
# Tests for _arguments.
%prep
- if ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
+ if [[ $OSTYPE = cygwin ]]; then
+ ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
+ elif ( zmodload -i zsh/zpty ) >/dev/null 2>&1; then
. $ZTST_srcdir/comptest
mkdir comp.tmp
cd comp.tmp
diff --git a/Test/comptest b/Test/comptest
index 4655f3b2b..20a3a5b1d 100644
--- a/Test/comptest
+++ b/Test/comptest
@@ -34,8 +34,9 @@ comptestinit () {
"fpath=( $fpath )" \
"bindkey -$comptest_keymap" \
'LISTMAX=10000000
-stty 38400 columns 80 rows 24
+stty 38400 columns 80 rows 24 tabs -icanon -iexten
TERM=vt100
+KEYTIMEOUT=1
setopt zle
autoload -U compinit
compinit -u
@@ -159,13 +160,18 @@ comptest () {
}
zletest () {
- input="$*"
- # zpty_flush Before zletest
- zpty -n -w zsh "$input"$'\C-X'
+ local first=0
+ for input; do
+ # zpty_flush Before zletest
+ # sleep for $KEYTIMEOUT
+ (( first++ )) && { sleep 2 & } | read -t 0.011 -u 0 -k 1
+ zpty -n -w zsh "$input"
+ done
+ zpty -n -w zsh $'\C-X'
zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
print "failed to invoke finish widget."
return 1
}
# zpty_flush After zletest
- print -lr "${(@)${(ps:\r\n:)log##*<WIDGET><finish>}[1,-2]}"
+ print -lr "${(@)${(@ps:\r\n:)log##*<WIDGET><finish>}[2,-2]}"
}