diff options
Diffstat (limited to 'Test')
-rw-r--r-- | Test/A04redirect.ztst | 6 | ||||
-rw-r--r-- | Test/B04read.ztst | 17 | ||||
-rw-r--r-- | Test/C04funcdef.ztst | 52 | ||||
-rw-r--r-- | Test/D03procsubst.ztst | 4 | ||||
-rw-r--r-- | Test/D04parameter.ztst | 36 | ||||
-rw-r--r-- | Test/D08cmdsubst.ztst | 8 | ||||
-rw-r--r-- | Test/E01options.ztst | 4 | ||||
-rw-r--r-- | Test/V01zmodload.ztst | 2 | ||||
-rw-r--r-- | Test/V04features.ztst | 10 | ||||
-rw-r--r-- | Test/V07pcre.ztst | 110 |
10 files changed, 233 insertions, 16 deletions
diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst index 4d96d8bb9..e58102664 100644 --- a/Test/A04redirect.ztst +++ b/Test/A04redirect.ztst @@ -155,10 +155,16 @@ (exec 3<&- read foo <&-) 1:'<&-' redirection +?(eval):1: failed to close file descriptor 3: bad file descriptor print foo >&- 0:'>&-' redirection + (exec >&- + print foo) +0:'>&-' with attempt to use closed fd +?(eval):2: write error: bad file descriptor + fn() { local foo; read foo; print $foo; } coproc fn print test output >&p diff --git a/Test/B04read.ztst b/Test/B04read.ztst index ad427dc0d..25c3d4173 100644 --- a/Test/B04read.ztst +++ b/Test/B04read.ztst @@ -93,3 +93,20 @@ read foo) <<<bar 1:return status on failing to set parameter ?(eval):2: read-only variable: foo + + read -AE array <<<'one two three' + print ${(j.:.)array} +0:Behaviour of -A and -E combination +>one +>two +>three +>one:two:three + + array=() + read -Ae array <<<'four five six' + print ${(j.:.)array} +0:Behaviour of -A and -e combination +>four +>five +>six +> diff --git a/Test/C04funcdef.ztst b/Test/C04funcdef.ztst index f71e5ce77..90f01e397 100644 --- a/Test/C04funcdef.ztst +++ b/Test/C04funcdef.ztst @@ -1,3 +1,8 @@ +%prep + + mkdir funcdef.tmp + cd funcdef.tmp + %test fn1() { return 1; } @@ -26,7 +31,7 @@ print regress expansion of function names } f$$ -0:Regression test: `function f$$ () { ... }' +0:Regression test: 'function f$$ () { ... }' >regress expansion of function names function foo () print bar @@ -109,6 +114,8 @@ >really useful >args +# ' deconfuse emacs + command_not_found_handler() { print "Your command:" >&2 print "$1" >&2 @@ -201,6 +208,49 @@ >Da de da >Do be do + () { print This has arguments $*; } of all sorts; print After the function + function { print More stuff $*; } and why not; print Yet more +0:Anonymous function with arguments +>This has arguments of all sorts +>After the function +>More stuff and why not +>Yet more + + fn() { + (){ print Anonymous function 1 $*; } with args + function { print Anonymous function 2 $*; } with more args + print Following bit + } + functions fn +0:Text representation of anonymous function with arguments +>fn () { +> () { +> print Anonymous function 1 $* +> } with args +> () { +> print Anonymous function 2 $* +> } with more args +> print Following bit +>} + + touch yes no + () { echo $1 } (y|z)* + (echo here) + () { echo $* } some (y|z)* + () { echo empty };(echo here) +0:Anonymous function arguments and command arguments +>yes +>here +>some yes +>empty +>here + + if true; then f() { echo foo1; } else f() { echo bar1; } fi; f + if false; then f() { echo foo2; } else f() { echo bar2; } fi; f +0:Compatibility with other shells when not anonymous functions +>foo1 +>bar2 + %clean rm -f file.in file.out diff --git a/Test/D03procsubst.ztst b/Test/D03procsubst.ztst index 37a67630f..602b1da15 100644 --- a/Test/D03procsubst.ztst +++ b/Test/D03procsubst.ztst @@ -84,3 +84,7 @@ ) 0:=(...) preceded by other stuff has no special effect >everything,=(here is left),alone + + print something=${:-=(echo 'C,D),(F,G)'} +1: Graceful handling of bad substitution in enclosed context +?(eval):1: unterminated `=(...)' diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index 6379c8cd0..71c79687f 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -179,9 +179,17 @@ print ${##} set 1 2 3 4 5 6 7 8 9 10 print ${##} -0:${##} is length of $# + print ${##""} + print ${##1} + print ${##2} + print ${###<->} # oh, for pete's sake... +0:${##} is length of $#, and other tales of hash horror >1 >2 +>10 +>0 +>10 +> array=(once bitten twice shy) print IF${array}THEN @@ -300,23 +308,16 @@ foo='\u65\123' print -r ${(g:o:)foo} - foo='\u65\0123' + foo='\u65\0123^X\C-x' print -r ${(g::)foo} - foo='\u65^X' - print -r ${(V)${(g:c:)foo}} - foo='\u65\C-x\M-a' - print -r ${(V)${(g:e:)foo}} - foo='\u65\123\C-x' - print -r ${(V)${(g:eo:)foo}} - foo=('\u65' '\0123' '^X\M-a') - print -r ${(V)${(g:e:)foo}} + foo='^X' + bar='\C-\130' + [[ ${(g:c:)foo} == ${(g:oe:)bar} ]] + echo $? 0:${(g)...} >eS ->eS ->e^X ->e^X\M-a ->eS^X ->e S ^X\M-a +>eS^X\C-x +>0 foo='I'\''m nearly out of my mind with tedium' bar=foo @@ -1452,3 +1453,8 @@ print ${foo:5:-6} 1:Regression test for total length < 0 in array ?(eval):2: substring expression: 3 < 5 + + foo=(${(0)"$(print -n)"}) + print ${#foo} +0:Nularg removed from split empty string +>0 diff --git a/Test/D08cmdsubst.ztst b/Test/D08cmdsubst.ztst index 9962c6cad..5661b0aaa 100644 --- a/Test/D08cmdsubst.ztst +++ b/Test/D08cmdsubst.ztst @@ -98,3 +98,11 @@ echo `echo $?` 0:Non-empty command substitution inherits status >1 + + echo $(( ##\" )) + echo $(echo \") + echo $((echo \"); echo OK) +0:Handling of backslash double quote in parenthesised substitutions +>34 +>" +>" OK diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 4b53840c6..1bbfdbda1 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -353,6 +353,10 @@ echo *NonExistentFile*) 0:NO_EXEC option should not do globbing + (setopt noexec + echo ${unset_var?Not an error}) +0:NO_EXEC should not test for unset variables + setopt NO_eval_lineno eval 'print $LINENO' setopt eval_lineno diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst index d74b0ef18..ea908e952 100644 --- a/Test/V01zmodload.ztst +++ b/Test/V01zmodload.ztst @@ -125,8 +125,10 @@ fi 0d:Autoload a module via a builtin + if [[ $mods[(r)zsh/example] == zsh/example ]]; then zmodload -u zsh/example builtin example + fi 0d:Autoloads are persistent (zmodload -u zsh/parameter diff --git a/Test/V04features.ztst b/Test/V04features.ztst index 240336611..2790456e2 100644 --- a/Test/V04features.ztst +++ b/Test/V04features.ztst @@ -17,18 +17,24 @@ 0:Loading modules with no features >-b:strftime >-p:EPOCHSECONDS +>-p:EPOCHREALTIME +>-p:epochtime zmodload -F zsh/datetime b:strftime zmodload -lF zsh/datetime 0:Enabling features >+b:strftime >-p:EPOCHSECONDS +>-p:EPOCHREALTIME +>-p:epochtime zmodload -F zsh/datetime +p:EPOCHSECONDS -b:strftime zmodload -lF zsh/datetime 0:Disabling features >-b:strftime >+p:EPOCHSECONDS +>-p:EPOCHREALTIME +>-p:epochtime zmodload -Fe zsh/datetime p:EPOCHSECONDS b:strftime 0:Testing existing features @@ -109,6 +115,8 @@ 0:Feature state with loading after error enabling >+b:strftime >-p:EPOCHSECONDS +>+p:EPOCHREALTIME +>+p:epochtime zmodload -F zsh/datetime p:EPOCHSECONDS zmodload -Fe zsh/datetime +p:EPOCHSECONDS @@ -159,3 +167,5 @@ 0:zmodload with no -F enables all features >+b:strftime >+p:EPOCHSECONDS +>+p:EPOCHREALTIME +>+p:epochtime diff --git a/Test/V07pcre.ztst b/Test/V07pcre.ztst new file mode 100644 index 000000000..f5b05deaa --- /dev/null +++ b/Test/V07pcre.ztst @@ -0,0 +1,110 @@ +%prep + + if ! zmodload zsh/pcre 2>/dev/null + then + ZTST_unimplemented="the zsh/pcre module is not available" + return 0 + fi + setopt rematch_pcre +# Find a UTF-8 locale. + setopt multibyte +# Don't let LC_* override our choice of locale. + unset -m LC_\* + mb_ok= + langs=(en_{US,GB}.{UTF-,utf}8 en.UTF-8 + $(locale -a 2>/dev/null | egrep 'utf8|UTF-8')) + for LANG in $langs; do + if [[ é = ? ]]; then + mb_ok=1 + break; + fi + done + if [[ -z $mb_ok ]]; then + ZTST_unimplemented="no UTF-8 locale or multibyte mode is not implemented" + else + print -u $ZTST_fd Testing PCRE multibyte with locale $LANG + mkdir multibyte.tmp && cd multibyte.tmp + fi + +%test + + [[ 'foo→bar' =~ .([^[:ascii:]]). ]] + print $MATCH + print $match[1] +0:Basic non-ASCII regexp matching +>o→b +>→ + + [[ foo =~ f.+ ]] ; print $? + [[ foo =~ x.+ ]] ; print $? + [[ ! foo =~ f.+ ]] ; print $? + [[ ! foo =~ x.+ ]] ; print $? + [[ foo =~ f.+ && bar =~ b.+ ]] ; print $? + [[ foo =~ x.+ && bar =~ b.+ ]] ; print $? + [[ foo =~ f.+ && bar =~ x.+ ]] ; print $? + [[ ! foo =~ f.+ && bar =~ b.+ ]] ; print $? + [[ foo =~ f.+ && ! bar =~ b.+ ]] ; print $? + [[ ! ( foo =~ f.+ && bar =~ b.+ ) ]] ; print $? + [[ ! foo =~ x.+ && bar =~ b.+ ]] ; print $? + [[ foo =~ x.+ && ! bar =~ b.+ ]] ; print $? + [[ ! ( foo =~ x.+ && bar =~ b.+ ) ]] ; print $? +0:Regex result inversion detection +>0 +>1 +>1 +>0 +>0 +>1 +>1 +>1 +>1 +>1 +>0 +>1 +>0 + +# Note that PCRE_ANCHORED only means anchored at the start +# Also note that we don't unset MATCH/match on failed match (and it's an +# open issue as to whether or not we should) + pcre_compile '.(→.)' + pcre_match foo→bar + print $? $MATCH $match ; unset MATCH match + pcre_match foo.bar + print $? $MATCH $match ; unset MATCH match + pcre_match foo†bar + print $? $MATCH $match ; unset MATCH match + pcre_match foo→†ar + print $? $MATCH $match ; unset MATCH match + pcre_study + pcre_match foo→bar + print $? $MATCH $match ; unset MATCH match + pcre_compile -a '.(→.)' + pcre_match foo→bar + print $? $MATCH $match ; unset MATCH match + pcre_match o→bar + print $? $MATCH $match ; unset MATCH match + pcre_match o→b + print $? $MATCH $match ; unset MATCH match + pcre_compile 'x.(→.)' + pcre_match xo→t + print $? $MATCH $match ; unset MATCH match + pcre_match Xo→t + print $? $MATCH $match ; unset MATCH match + pcre_compile -i 'x.(→.)' + pcre_match xo→t + print $? $MATCH $match ; unset MATCH match + pcre_match Xo→t + print $? $MATCH $match ; unset MATCH match +0:pcre_compile interface testing: basic, anchored & case-insensitive +>0 o→b →b +>1 +>1 +>0 o→† →† +>0 o→b →b +>1 +>0 o→b →b +>0 o→b →b +>0 xo→t →t +>1 +>0 xo→t →t +>0 Xo→t →t |