diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2001-04-02 12:34:23 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2001-04-02 12:34:23 +0000 |
commit | b7b139f292c6786db23bfe448b515864e54fcc9b (patch) | |
tree | eebe9eda80dfe90d35d937480861cbe8bb72c7ed | |
parent | 0d86cf0668a0b1c9c7600e1e3fa9ce8f711e91a0 (diff) | |
download | zsh-b7b139f292c6786db23bfe448b515864e54fcc9b.tar.gz zsh-b7b139f292c6786db23bfe448b515864e54fcc9b.tar.xz zsh-b7b139f292c6786db23bfe448b515864e54fcc9b.zip |
moved from ./Test/14array.ztst
-rw-r--r-- | Test/D05array.ztst | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/Test/D05array.ztst b/Test/D05array.ztst new file mode 100644 index 000000000..35976899c --- /dev/null +++ b/Test/D05array.ztst @@ -0,0 +1,97 @@ +# Tests for array indexing + +%prep + + foo=(a b c d e f g) + mkdir array.tmp + touch array.tmp/{1..9} + +%test + + echo .$foo[1]. +0:The first element +>.a. + + echo .$foo[1,4]. +0:Normal multi-item indexing +>.a b c d. + + echo .$foo[1,0]. +0:This should be empty +>.. + + echo .$foo[4,1]. +0:Another empty slice +>.. + + echo .$foo[1,-8]. +0:An empty slice with a negative end +>.. + + echo .$foo[0]. +0:Treat 0 like 1 +>.a. + + echo .$foo[0,0]. +0:Treat 0,0 like 1,1. +>.a. + + echo .$foo[0,1]. +0:Another weird way to access the first element +>.a. + + echo .$foo[3]. +0:An inner element +>.c. + + echo .$foo[2,2]. +0:Another inner element +>.b. + + echo .$foo[2,-4]. +0:A slice with a negative end +>.b c d. + + echo .$foo[-4,5]. +0:A slice with a negative start +>.d e. + + echo .$foo[-6,-2]. +0:A slice with a negative start and end +>.b c d e f. + + setopt ksh_arrays + echo .${foo[1,2]}. + unsetopt ksh_arrays +0:Ksh array indexing +>.b c. + + setopt ksh_arrays + echo .${foo[0,1]}. + unsetopt ksh_arrays +0:Ksh array indexing (ii) +>.a b. + + setopt ksh_arrays + echo .${foo[1,-1]}. + unsetopt ksh_arrays +0:Ksh array indexing (iii) +>.b c d e f g. + + cd array.tmp + echo . ?([3,5]) . + cd .. +0:Glob array indexing +>. 3 4 5 . + + cd array.tmp + echo . ?([2,-2]) . + cd .. +0:Glob array indexing (ii) +>. 2 3 4 5 6 7 8 . + + cd array.tmp + echo . ?([-6,-4]) . + cd .. +0:Glob array indexing (iii) +>. 4 5 6 . |