mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-27 16:50:58 +01:00
51945: assorted documentation improvements, bug fixes, and new test
1) Document the behavior of "typeset -n existing_var" (via Jun T. comment)
2) Prohibit "typeset -nm pattern" because, well, it's insane. Add test.
3) Improve doc for ${(!)ref} including ${{t!)ref} (Jun T.)
4) Fix doc for how-to unset of a named ref (Jun T.)
5) Allow "typeset +r -n ref" and "typeset +r +n ref" (Jun T.)
6) Fix "typeset -r -n ref=param" to create readonly references
7) Avoid accidental removal of PM_UNSET flag (Jun T.) and update test
8) Fix "typeset -gn ref=value" and add a test for it
9) Add tests for read-only reference behavior
10) Fix infinite recursion when resolving scope of an unset local
named reference, add test.
This commit is contained in:
parent
5ff23c2c6d
commit
baa19d2a85
7 changed files with 132 additions and 18 deletions
|
|
@ -515,7 +515,7 @@ F:Same test, should part 5 output look like this?
|
|||
>ptr1=val
|
||||
>ptr2=
|
||||
>typeset -n ptr1=ptr2
|
||||
>typeset -n ptr2=''
|
||||
>typeset -n ptr2
|
||||
>typeset ptr2=val
|
||||
|
||||
if zmodload zsh/parameter; then
|
||||
|
|
@ -694,4 +694,72 @@ F:Checking for a bug in zmodload that affects later tests
|
|||
F:runs in `setopt noexec` so $(...) returns nothing
|
||||
*?*bad math expression: empty string
|
||||
|
||||
unset -n ref
|
||||
typeset -n ref=GLOBAL
|
||||
() {
|
||||
typeset -gn ref=RESET
|
||||
}
|
||||
typeset -p ref
|
||||
0:reset global reference within function
|
||||
>typeset -n ref=RESET
|
||||
|
||||
unset -n ref
|
||||
typeset -rn ref=RO
|
||||
typeset -p ref
|
||||
(typeset -n ref=RW)
|
||||
print status: $? expected: 1
|
||||
typeset +r -n ref
|
||||
typeset -p ref
|
||||
typeset -r +n ref
|
||||
typeset -p ref
|
||||
(typeset -rn ref)
|
||||
print status: $? expected: 1
|
||||
typeset +r -n ref=RW # Assignment occurs after type change,
|
||||
typeset -p ref RO # so RO=RW here. Potentially confusing.
|
||||
typeset -r -n ref=RX # No type change, so referent changes ...
|
||||
typeset -p ref RO # ... and previous refererent does not.
|
||||
typeset +rn ref=RW # Here ref=RW, again type changed first.
|
||||
typeset -p ref
|
||||
0:add and remove readonly attribute with references
|
||||
>typeset -rn ref=RO
|
||||
*?*: ref: read-only reference
|
||||
>status: 1 expected: 1
|
||||
>typeset -n ref=RO
|
||||
>typeset -r ref=RO
|
||||
*?*: ref: read-only variable
|
||||
>status: 1 expected: 1
|
||||
>typeset -n ref=RO
|
||||
>typeset -g RO=RW
|
||||
>typeset -rn ref=RX
|
||||
>typeset -g RO=RW
|
||||
>typeset ref=RW
|
||||
|
||||
() {
|
||||
typeset -n r1 r2=
|
||||
typeset -p r1 r2
|
||||
print -- ${(!)r1-unset}
|
||||
print -- ${+r1}
|
||||
typeset -p r1
|
||||
}
|
||||
0:unset nameref remains unset when resolved
|
||||
F:relies on global TYPESET_TO_UNSET in %prep
|
||||
>typeset -n r1
|
||||
>typeset -n r2=''
|
||||
>unset
|
||||
>0
|
||||
>typeset -n r1
|
||||
|
||||
bar=xx
|
||||
typeset -n foo=bar
|
||||
() { typeset -n foo; foo=zz; foo=zz; print $bar $zz }
|
||||
() { typeset -n foo; foo=zz; local zz; foo=zz; print $bar $zz }
|
||||
0:regression: local nameref may not in-scope a global parameter
|
||||
F:previously this could create an infinite recursion and crash
|
||||
>xx
|
||||
>xx zz
|
||||
|
||||
typeset -nm foo=bar
|
||||
1:create nameref by pattern match not allowed
|
||||
*?*typeset:1: invalid reference
|
||||
|
||||
%clean
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue