summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
Diffstat (limited to 'Test')
-rw-r--r--Test/A01grammar.ztst2
-rw-r--r--Test/D02glob.ztst27
-rw-r--r--Test/E02xtrace.ztst34
-rw-r--r--Test/V01zmodload.ztst41
-rw-r--r--Test/V13zformat.ztst67
5 files changed, 160 insertions, 11 deletions
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 1e0e9a04e..0dbf468f6 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -930,5 +930,5 @@ F:Note that the behaviour of 'exit' inside try-list inside a function is unspeci
>or false
$ZTST_testdir/../Src/zsh -fc '{ ( ) } always { echo foo }'
--f:exec last command optimization inhibited for try/always
+0:exec last command optimization inhibited for try/always
>foo
diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
index 973dc2207..4e6dc2a7a 100644
--- a/Test/D02glob.ztst
+++ b/Test/D02glob.ztst
@@ -729,16 +729,12 @@
>not/exist
>exist
- if [[ $OSTYPE = cygwin* ]]; then
- ZTST_skip='Cygwin ignores search permission of directories'
- else
- mkdir -m 000 glob.tmp/secret-d000
- mkdir -m 111 glob.tmp/secret-d111
- mkdir -m 444 glob.tmp/secret-d444
- for 1 in 000 111 444 ; do ln -s secret-d$1 glob.tmp/secret-s$1; done
- print -rC 2 -- glob.tmp/secret-*/ glob.tmp/secret-*(-/)
- fi
--f:unreadable directories can be globbed (users/24619, users/24626)
+ mkdir -m 000 glob.tmp/secret-d000
+ mkdir -m 111 glob.tmp/secret-d111
+ mkdir -m 444 glob.tmp/secret-d444
+ for 1 in 000 111 444 ; do ln -s secret-d$1 glob.tmp/secret-s$1; done
+ print -rC 2 -- glob.tmp/secret-*/ glob.tmp/secret-*(-/)
+0:unreadable directories can be globbed (users/24619, users/24626)
>glob.tmp/secret-d000/ glob.tmp/secret-d000
>glob.tmp/secret-d111/ glob.tmp/secret-d111
>glob.tmp/secret-d444/ glob.tmp/secret-d444
@@ -746,6 +742,17 @@
>glob.tmp/secret-s111/ glob.tmp/secret-s111
>glob.tmp/secret-s444/ glob.tmp/secret-s444
+ # On macOS, stat(2) allows files to be treated as directories if the calling
+ # process has super-user privileges. e.g., stat() on /my/regular/file/. will
+ # succeed as root but (correctly) fail otherwise. This can produce strange
+ # results when globbing, depending on how it's implemented. This test should,
+ # when run with privileges, confirm that the implementation avoids this
+ # problem. See workers/42891 and workers/45291
+ : > glob.tmp/not-a-directory
+ print -r - glob.tmp/not-a-dir*(N) , glob.tmp/not-a-dir*/(N)
+0:non-directories not globbed as directories
+>glob.tmp/not-a-directory ,
+
() { echo $1:P } ////dev
-f:(workers/45367) modifier ':P' squashes multiple slashes
>/dev
diff --git a/Test/E02xtrace.ztst b/Test/E02xtrace.ztst
index da6191cd0..a5a7bc55c 100644
--- a/Test/E02xtrace.ztst
+++ b/Test/E02xtrace.ztst
@@ -146,3 +146,37 @@
?+(anon):0> '(anon)'
?+(anon):0> true
?+fn:0> gn
+
+ test_cases=(
+ f # baseline
+ foo-bar # Dash
+ ヌ # Meta (the UTF-8 representation of this character has an 0x83 byte)
+ \$\'ba\\0z\' # Nul, escaped as though by ${(qqqq)}
+ )
+ for 1 in "$test_cases[@]"; do
+ eval "
+ ${1}() {
+ ${1}() { echo inner }
+ }
+ functions -T ${1}
+ ${1}
+ which ${1}
+ "
+ done
+0:a function that redefines itself preserves tracing
+>f () {
+> # traced
+> echo inner
+>}
+>foo-bar () {
+> # traced
+> echo inner
+>}
+>$'\M-c\M-\C-C\M-\C-L' () {
+> # traced
+> echo inner
+>}
+>$'ba\C-@z' () {
+> # traced
+> echo inner
+>}
diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst
index 55c3c314b..c3c64a79d 100644
--- a/Test/V01zmodload.ztst
+++ b/Test/V01zmodload.ztst
@@ -348,6 +348,47 @@
?(eval):6: unknown function: systell
?(eval):9: file descriptor out of range
+ $ZTST_testdir/../Src/zsh -fc '
+ if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi
+ unset options
+ zmodload zsh/parameter
+ echo $+options
+ '
+-f:can unset a non-readonly autoloadable parameter before loading the module
+>0
+# Currently prints '1'.
+
+ $ZTST_testdir/../Src/zsh -fc '
+ zmodload zsh/parameter
+ unset options
+ echo $+options
+ '
+0:can unset a non-readonly autoloadable parameter after loading the module
+>0
+
+ $ZTST_testdir/../Src/zsh -fc '
+ if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi
+ unset builtins
+ '
+-f:can't unset a readonly autoloadable parameter before loading the module
+*?zsh:?: read-only variable: builtins
+# Currently, the 'unset' succeeds.
+
+ $ZTST_testdir/../Src/zsh -fc '
+ zmodload zsh/parameter
+ unset builtins
+ '
+1:can't unset a readonly autoloadable parameter after loading the module
+?zsh:3: read-only variable: builtins
+
+ $ZTST_testdir/../Src/zsh -fc '
+ zmodload zsh/parameter
+ zmodload -u zsh/parameter
+ echo $options
+ '
+0:unloading a module doesn't implicitly unset autoloadable parameters
+*>(on|off) *
+
$ZTST_testdir/../Src/zsh -fc "
MODULE_PATH=${(q)MODULE_PATH}
#
diff --git a/Test/V13zformat.ztst b/Test/V13zformat.ztst
new file mode 100644
index 000000000..982866e13
--- /dev/null
+++ b/Test/V13zformat.ztst
@@ -0,0 +1,67 @@
+# Test the use of zformat, if the zsh/zutil module is available.
+
+%prep
+
+ if ! zmodload zsh/zutil 2>/dev/null; then
+ ZTST_unimplemented="can't load the zsh/zutil module for testing"
+ fi
+
+ # Helper function. Expects a single format using %s and a value for it.
+ zformat_and_print_s() {
+ zformat -f REPLY "$1" "s:$2"
+ print -r - ${(qq)REPLY}
+ }
+
+%test
+
+ zformat_and_print_s '%s' foo
+ zformat_and_print_s '%5s' min
+ zformat_and_print_s '%-5s' neg
+ zformat_and_print_s '%5.s' empty
+ zformat_and_print_s '%.5s' max
+ zformat_and_print_s '%.5s' truncated
+0:basic zformat test
+>'foo'
+>'min '
+>' neg'
+>'empty'
+>'max'
+>'trunc'
+
+ # There may be a set of digits either before or after the opening parenthesis.
+ zformat_and_print_s 'The answer is "%3(s.yes.no)".' 3
+ zformat_and_print_s 'The answer is "%(3s.yes.no)".' 3
+ # The test number defaults to zero.
+ zformat_and_print_s '%(s.equal.unequal)' -1
+ zformat_and_print_s '%(s.equal.unequal)' 0
+ zformat_and_print_s '%(s.equal.unequal)' 1
+ # Negative numbers are allowed
+ # The delimiter is arbitrary
+ zformat_and_print_s '%-4(s.minus four.)' -4
+ zformat_and_print_s '%(-4s//minus four)' -4
+ # The argument is evaluated as a math expression
+ zformat_and_print_s '%18(s.math.)' '6*3'
+0:basic conditionals test
+>'The answer is "yes".'
+>'The answer is "yes".'
+>'unequal'
+>'equal'
+>'unequal'
+>'minus four'
+>''
+>'math'
+
+ () {
+ zformat -f 1 '%(8n.%(5j.yes.no).no)' 'n:8' 'j:5'
+ echo $1
+ }
+0:nested conditionals test
+>yes
+
+ zformat -a argv . foo:lorem ipsum:bar bazbaz '\\esc\:ape'
+ print -rl -- "$@"
+0:basic -a test
+>foo .lorem
+>ipsum.bar
+>bazbaz
+>\esc:ape