diff options
Diffstat (limited to 'Test')
-rw-r--r-- | Test/.distfiles | 1 | ||||
-rw-r--r-- | Test/A07control.ztst | 6 | ||||
-rw-r--r-- | Test/B08shift.ztst | 33 | ||||
-rw-r--r-- | Test/C01arith.ztst | 16 | ||||
-rw-r--r-- | Test/C02cond.ztst | 8 | ||||
-rw-r--r-- | Test/C04funcdef.ztst | 5 | ||||
-rw-r--r-- | Test/D02glob.ztst | 39 | ||||
-rw-r--r-- | Test/D04parameter.ztst | 76 | ||||
-rw-r--r-- | Test/D09brace.ztst | 15 | ||||
-rw-r--r-- | Test/E01options.ztst | 44 | ||||
-rw-r--r-- | Test/X02zlevi.ztst | 57 | ||||
-rw-r--r-- | Test/comptest | 42 | ||||
-rwxr-xr-x | Test/ztst.zsh | 6 |
13 files changed, 335 insertions, 13 deletions
diff --git a/Test/.distfiles b/Test/.distfiles index 1c0102818..5826e7574 100644 --- a/Test/.distfiles +++ b/Test/.distfiles @@ -15,6 +15,7 @@ B04read.ztst B05eval.ztst B06fc.ztst B07emulate.ztst +B08shift.ztst C01arith.ztst C02cond.ztst C03traps.ztst diff --git a/Test/A07control.ztst b/Test/A07control.ztst index b9b89b588..397a821f1 100644 --- a/Test/A07control.ztst +++ b/Test/A07control.ztst @@ -23,12 +23,12 @@ >start 255 >255 - fn() { + $ZTST_testdir/../Src/zsh -fc 'fn() { continue } - fn + fn' 1:continue outside loop -?fn:continue:1 not in while, until, select, or repeat loop +?fn:continue:1: not in while, until, select, or repeat loop for outer in 0 1 2 3; do print outer $outer diff --git a/Test/B08shift.ztst b/Test/B08shift.ztst new file mode 100644 index 000000000..0aa922673 --- /dev/null +++ b/Test/B08shift.ztst @@ -0,0 +1,33 @@ +# Test the shift builtin. + +%test + + set -- one two three four five six seven eight nine ten + shift + print $* + shift 2 + print $* + shift -p 3 + print $* + shift -p + print $* +0:shifting positional parameters +>two three four five six seven eight nine ten +>four five six seven eight nine ten +>four five six seven +>four five six + + array=(yan tan tether mether pip azer sezar akker conter dick) + shift 2 array + print $array + shift array + print $array + shift -p 3 array + print $array + shift -p array + print $array +0:shifting array +>tether mether pip azer sezar akker conter dick +>mether pip azer sezar akker conter dick +>mether pip azer sezar +>mether pip azer diff --git a/Test/C01arith.ztst b/Test/C01arith.ztst index 7b005c2ab..25cd8b83a 100644 --- a/Test/C01arith.ztst +++ b/Test/C01arith.ztst @@ -266,3 +266,19 @@ >48.5 >77.5 >63.5 + + underscore_integer() { + setopt cbases localoptions + print $(( [#_] 1000000 )) + print $(( [#16_] 65536 )) + print $(( [#16_4] 65536 * 32768 )) + } + underscore_integer +0:Grouping output with underscores: integers +>1_000_000 +>0x10_000 +>0x8000_0000 + + print $(( [#_] (5. ** 10) / 16. )) +0:Grouping output with underscores: floating point +>610_351.562_5 diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst index 94fca8b68..69001476c 100644 --- a/Test/C02cond.ztst +++ b/Test/C02cond.ztst @@ -349,6 +349,14 @@ F:Failures in these cases do not indicate a problem in the shell. >0 >1 + foo='' + [[ $foo ]] || print foo is empty + foo=full + [[ $foo ]] && print foo is full +0:bash compatibility with single [[ ... ]] argument +>foo is empty +>foo is full + %clean # This works around a bug in rm -f in some versions of Cygwin chmod 644 unmodish diff --git a/Test/C04funcdef.ztst b/Test/C04funcdef.ztst index 706aa28c2..a2660315f 100644 --- a/Test/C04funcdef.ztst +++ b/Test/C04funcdef.ztst @@ -208,6 +208,11 @@ >Da de da >Do be do + () (cat $1 $2) <(print process expanded) =(print expanded to file) +0:Process substitution with anonymous functions +>process expanded +>expanded to file + () { 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 diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst index 1f8f65286..4697ca414 100644 --- a/Test/D02glob.ztst +++ b/Test/D02glob.ztst @@ -431,6 +431,7 @@ mkdir glob.tmp/dir5 touch glob.tmp/dir5/N123 print glob.tmp/dir5/N<->(N) + rm -rf glob.tmp/dir5 0:Numeric glob is not usurped by process substitution. >glob.tmp/dir5/N123 @@ -526,3 +527,41 @@ >+bus+bus matches +(+bus|-car) >@sinhats matches @(@sinhats|wrensinfens) >!kerror matches !(!somethingelse) + + ( + setopt extendedglob + cd glob.tmp + [[ -n a*(#qN) ]] && print File beginning with a + [[ -z z*(#qN) ]] && print No file beginning with z + setopt nonomatch + [[ -n z*(#q) ]] && print Normal string if nullglob not set + ) +0:Force glob expansion in conditions using (#q) +>File beginning with a +>No file beginning with z +>Normal string if nullglob not set + + (){ print $#@ } glob.tmp/dir*(Y1) + (){ print $#@ } glob.tmp/file*(NY1) + (){ [[ "$*" == */dir?\ */dir? ]] && print Returns matching filenames } glob.tmp/dir*(Y2) + (){ print "Limit is upper bound:" ${(o)@:t} } glob.tmp/dir*(Y5) + (){ 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) + (){ [[ $#@ -eq 0 ]] && print Respects qualifiers } glob.tmp/dir*(NY1.) + (print -- *(Y)) 2>/dev/null || print "Argument required" +0:short-circuit modifier +>1 +>0 +>Returns matching filenames +>Limit is upper bound: dir1 dir2 dir3 dir4 +>Negated: dir1 dir2 dir3 dir4 +>Sorting: dir4 dir3 dir2 dir1 +>Globs before last path component +>Respects qualifiers +>Argument required + + [[ "ce fichier n'existe pas" = (#b)ce\ (f[^ ]#)\ *s(#q./) ]] + print $match[1] +0:(#q) is ignored completely in conditional pattern matching +>fichier diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index a8cc93a12..49dcea901 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -1560,3 +1560,79 @@ 0:Intersection and disjunction with empty parameters >0 >0 + + foo=(a b c) + bar=(1 2 3) + print ${foo:^bar} + print ${foo:^^bar} + foo=(a b c d) + bar=(1 2) + print ${foo:^bar} + print ${foo:^^bar} + foo=('a a' b) + bar=(1 '2 2') + print -l "${foo:^bar}" + print -l "${(@)foo:^bar}" +0:Zipping arrays, correct output +>a 1 b 2 c 3 +>a 1 b 2 c 3 +>a 1 b 2 +>a 1 b 2 c 1 d 2 +# maybe this should be changed to output "a a b 1" +>a a b +>1 +>a a +>1 +>b +>2 2 + + foo=(a b c) + bar=() + print ${foo:^bar} + print ${foo:^^bar} + print ${bar:^foo} + print ${bar:^^foo} + print ${bar:^bar} + print ${bar:^^bar} +0:Zipping arrays, one or both inputs empty +> +>a b c +> +>a b c +> +> + + foo=text + bar=() + print ${foo:^bar} + print ${bar:^^foo} + bar=other + print ${foo:^bar} + bar=(array elements) + print ${foo:^bar} + print ${foo:^^bar} + print ${bar:^foo} + print ${bar:^^foo} +0:Zipping arrays, scalar input +> +>text +>text other +>text array +>text array text elements +>array text +>array text elements text + + foo=(a b c) + print ${foo:^^^bar} +1:Zipping arrays, parsing +?(eval):2: not an identifier: ^bar + + (setopt nounset + print ${foo:^noexist}) +1:Zipping arrays, NO_UNSET part 1 +?(eval):2: noexist: parameter not set + + (setopt nounset + print ${noexist:^foo}) +1:Zipping arrays, NO_UNSET part 2 +?(eval):2: noexist: parameter not set diff --git a/Test/D09brace.ztst b/Test/D09brace.ztst index d0ec93cd3..3e667a8d1 100644 --- a/Test/D09brace.ztst +++ b/Test/D09brace.ztst @@ -97,3 +97,18 @@ 0:BRACE_CCL off >X{za-q521}Y + print -r hey{a..j}there +0:{char..char} ranges, simple case +>heyathere heybthere heycthere heydthere heyethere heyfthere heygthere heyhthere heyithere heyjthere + + print -r gosh{1,{Z..a},2}cripes +0:{char..char} ranges, ASCII ordering +>gosh1cripes goshZcripes gosh[cripes gosh\cripes gosh]cripes gosh^cripes gosh_cripes gosh`cripes goshacripes gosh2cripes + + print -r crumbs{y..p}ooh +0:{char..char} ranges, reverse +>crumbsyooh crumbsxooh crumbswooh crumbsvooh crumbsuooh crumbstooh crumbssooh crumbsrooh crumbsqooh crumbspooh + + print -r left{[..]}right +0:{char..char} ranges with tokenized characters +>left[right left\right left]right diff --git a/Test/E01options.ztst b/Test/E01options.ztst index d9f219115..46b183776 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -430,7 +430,7 @@ foo unfunction foo 0:FUNCTION_ARGZERO option ->My name is ZTST_execchunk +>My name is (anon) >My name is foo setopt _NO_glob_ @@ -1114,3 +1114,45 @@ >1 >1 >2 + + for (( i = 0; i < 10; i++ )); do + () { + print $i + break + } + done +0:NO_LOCAL_LOOPS +>0 + + () { + emulate -L zsh + setopt localloops + for (( i = 0; i < 10; i++ )); do + () { + setopt nolocalloops # ignored in parent + print $i + break + } + done + } +0:LOCAL_LOOPS +>0 +>1 +>2 +>3 +>4 +>5 +>6 +>7 +>8 +>9 +?(anon):4: `break' active at end of function scope +?(anon):4: `break' active at end of function scope +?(anon):4: `break' active at end of function scope +?(anon):4: `break' active at end of function scope +?(anon):4: `break' active at end of function scope +?(anon):4: `break' active at end of function scope +?(anon):4: `break' active at end of function scope +?(anon):4: `break' active at end of function scope +?(anon):4: `break' active at end of function scope +?(anon):4: `break' active at end of function scope diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst index d4a125f21..19188dfb7 100644 --- a/Test/X02zlevi.ztst +++ b/Test/X02zlevi.ztst @@ -10,6 +10,63 @@ %test + zletest $'word\euaend' +0:undo initial change +>BUFFER: end +>CURSOR: 3 + + zletest $'text\e.' +0:repeat initial edit +>BUFFER: text +>text +>CURSOR: 8 + + zpty_run 'print -z before' + zletest $'after\e.' +0:repeat initial edit with non-blank starting line +>BUFFER: beforeafterafter +>CURSOR: 15 + + zpty_run 'setopt overstrike;print -z bung' + zletest $'ing\e2|.' +0:repeat initial edit with overstrike set +>BUFFER: binging +>CURSOR: 3 + + zpty_run 'bindkey "^_" undo' + zletest $'undoc\037e' +0:use of undo in vi insert mode +>BUFFER: undoe +>CURSOR: 5 + + zletest $'one\euatwo\e0clthree' +0:vi mode undo of initial and subsequent change +>BUFFER: threewo +>CURSOR: 5 + + zletest $'xxx\euiyyy\euAz' +0:undo invoked twice +>BUFFER: z +>CURSOR: 1 + + zpty_run 'bindkey -a "^K" redo' + zletest $'123\C-_\e\C-k' +0:undo in insert mode, redo in command +>BUFFER: 123 +>CURSOR: 2 + + zpty_run 'bindkey "^Y" redo' + zletest $'pre\eA123\C-_\C-y\eu' +0:undo and redo in insert mode, undo in command +>BUFFER: pre +>CURSOR: 2 + + zpty_run 'bindkey "^Gu" split-undo' + zletest $'one\C-gutwo\eu' +0:split the undo sequence +>BUFFER: one +>CURSOR: 2 + zletest $'one two\ebmt3|`tx``' 0:setting mark and returning to original position >BUFFER: one wo diff --git a/Test/comptest b/Test/comptest index 10814d635..4655f3b2b 100644 --- a/Test/comptest +++ b/Test/comptest @@ -69,12 +69,15 @@ comp-finish () { zle -R } zle-finish () { - print -lr "<WIDGET><finish>" "BUFFER: $BUFFER" "CURSOR: $CURSOR" - (( region_active )) && print -lr "MARK: $MARK" - zle -K main - zle kill-whole-line + local buffer="$BUFFER" cursor="$CURSOR" mark="$MARK" + (( region_active)) || unset mark + BUFFER="" + zle -I zle clear-screen - zle -R + zle redisplay + print -lr "<WIDGET><finish>" "BUFFER: $buffer" "CURSOR: $cursor" + (( $+mark )) && print -lr "MARK: $mark" + zle accept-line } zle -N expand-or-complete-with-report zle -N list-choices-with-report @@ -83,20 +86,41 @@ zle -N zle-finish bindkey "^I" expand-or-complete-with-report bindkey "^D" list-choices-with-report bindkey "^Z" comp-finish -bindkey "^M" zle-finish -bindkey -a "^M" zle-finish +bindkey "^X" zle-finish +bindkey -a "^X" zle-finish ' } +zpty_flush() { + local junk + if zpty -r -t zsh junk \*; then + (( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "$*: ${(V)junk}" + while zpty -r -t zsh junk \* ; do + (( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "${(V)junk}" + done + (( ZTST_verbose > 2 )) && print -u $ZTST_fd '' + fi +} + +zpty_run() { + zpty -w zsh "$*" + zpty -r -m zsh log "*<PROMPT>*" || { + print "prompt hasn't appeared." + return 1 + } +} + comptesteval () { local tmp=/tmp/comptest.$$ print -lr - "$@" > $tmp + # zpty_flush Before comptesteval zpty -w zsh ". $tmp" zpty -r -m zsh log_eval "*<PROMPT>*" || { print "prompt hasn't appeared." return 1 } + zpty_flush After comptesteval rm $tmp } @@ -136,10 +160,12 @@ comptest () { zletest () { input="$*" - zpty -n -w zsh "$input"$'\C-M' + # zpty_flush Before zletest + zpty -n -w zsh "$input"$'\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]}" } diff --git a/Test/ztst.zsh b/Test/ztst.zsh index 745a13cff..74111f6cc 100755 --- a/Test/ztst.zsh +++ b/Test/ztst.zsh @@ -260,8 +260,12 @@ $ZTST_redir" # Execute an indented chunk. Redirections will already have # been set up, but we need to handle the options. ZTST_execchunk() { + setopt localloops # don't let continue & break propagate out options=($ZTST_testopts) - eval "$ZTST_code" + () { + unsetopt localloops + eval "$ZTST_code" + } ZTST_status=$? # careful... ksh_arrays may be in effect. ZTST_testopts=(${(kv)options[*]}) |