about summary refs log tree commit diff
path: root/Test/C02cond.ztst
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2016-09-16 00:00:28 +0200
committerOliver Kiddle <opk@zsh.org>2016-09-16 00:00:28 +0200
commitfbafc5b509e311efee064bbd12396a2e207f3393 (patch)
tree9fdf8f236fb1d25b54079e81cf75bf05eeca0b26 /Test/C02cond.ztst
parent00708285e94ce42a31fd59bbcd06d010a6d0d6ee (diff)
downloadzsh-fbafc5b509e311efee064bbd12396a2e207f3393.tar.gz
zsh-fbafc5b509e311efee064bbd12396a2e207f3393.tar.xz
zsh-fbafc5b509e311efee064bbd12396a2e207f3393.zip
39332: support ksh's [[ -v varname ]] condition for checking if variables are set
Diffstat (limited to 'Test/C02cond.ztst')
-rw-r--r--Test/C02cond.ztst19
1 files changed, 19 insertions, 0 deletions
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 78e644a72..40e4dfb0b 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -269,6 +269,25 @@ F:Failures in these cases do not indicate a problem in the shell.
 0:-nt shouldn't abort on non-existent files
 >status = 1
 
+  str='string' empty=''
+  [[ -v IFS && -v str && -v empty && ! -v str[3] && ! -v not_a_variable ]]
+0:-v cond
+
+  arr=( 1 2 3 4 ) empty=()
+  [[ -v arr && -v arr[1,4] && -v arr[1] && -v arr[4] && -v arr[-4] &&
+    -v arr[(i)3] && ! -v arr[(i)x] &&
+    ! -v arr[0] && ! -v arr[5] && ! -v arr[-5] && ! -v arr[2][1] &&
+    ! -v arr[3]extra && -v empty && ! -v empty[1] ]]
+0:-v cond with array
+
+  typeset -A assoc=( key val num 4 )
+  [[ -v assoc && -v assoc[key] && -v assoc[(i)*] && -v assoc[(I)*] &&
+    ! -v assoc[x] && ! -v assoc[key][1] ]]
+0:-v cond with association
+
+  () { [[ -v 0 && -v 1 && -v 2 && ! -v 3 ]] } arg ''
+0:-v cond with positional parameters
+
 # core dumps on failure
   if zmodload zsh/regex 2>/dev/null; then
      echo >regex_test.sh 'if [[ $# = 1 ]]; then