3 # Test the use of styles, if the zsh/zutil module is available.
5 if (zmodload zsh/zutil >/dev/null 2>/dev/null); then
8 ZTST_unimplemented="can't load the zsh/zutil module for testing"
12 zstyle :random:stuff any-old-style with any old value
13 zstyle :randomly:chosen some-other-style I can go on and on
16 0:zstyle -d restores a pristine state
18 # patterns should be ordered by weight, so add in reverse order to check
19 zstyle ':ztst:context*' scalar-style other-scalar-value
20 zstyle ':ztst:context:*' scalar-style second-scalar-value
21 zstyle ':ztst:context:sub1' scalar-style scalar-value
22 zstyle ':ztst:context:sub1' array-style array value elements 'with spaces'
23 zstyle ':ztst:context*' boolean-style false
24 zstyle ':ztst:context:sub1' boolean-style true
27 # styles are now sorted, but patterns are in order of definition
29 0:listing styles in default format
31 > :ztst:context:sub1 array value elements 'with spaces'
33 > :ztst:context:sub1 true
34 > :ztst:context* false
36 > :ztst:context:sub1 scalar-value
37 > :ztst:context:* second-scalar-value
38 > :ztst:context* other-scalar-value
41 0:listing styles in zstyle format
42 >zstyle :ztst:context:sub1 array-style array value elements 'with spaces'
43 >zstyle :ztst:context:sub1 boolean-style true
44 >zstyle ':ztst:context*' boolean-style false
45 >zstyle :ztst:context:sub1 scalar-style scalar-value
46 >zstyle ':ztst:context:*' scalar-style second-scalar-value
47 >zstyle ':ztst:context*' scalar-style other-scalar-value
49 zstyle -b :ztst:context:sub1 boolean-style bool; print $bool
50 zstyle -t :ztst:context:sub1 boolean-style
51 0:boolean test -b/-t + true
54 zstyle -b :ztst:context:sub2 boolean-style bool; print $bool
55 zstyle -t :ztst:context:sub2 boolean-style
56 1:boolean test -b/-t + false
59 zstyle -b :ztst:context:sub1 boolean-unset-style bool; print $bool
60 zstyle -t :ztst:context:sub1 boolean-unset-style
61 2:boolean test -b/-t + unset
64 zstyle -T :ztst:context:sub1 boolean-style
65 0:boolean test -T + true
67 zstyle -T :ztst:context:sub2 boolean-style
68 1:boolean test -T + false
70 zstyle -T :ztst:context:sub1 boolean-unset-style
71 0:boolean test -T + unset
73 zstyle -s :ztst:context:sub1 scalar-style scalar && print $scalar
74 zstyle -s :ztst:context:sub2 scalar-style scalar && print $scalar
75 zstyle -s :ztst:contextual-psychedelia scalar-style scalar && print $scalar
76 zstyle -s :ztst:contemplative scalar-style scalar || print no match
77 0:pattern matching rules
83 zstyle -s :ztst:context:sub1 array-style scalar + && print $scalar
84 0:scalar with separator
85 >array+value+elements+with spaces
87 zstyle -e :ztst:\* eval-style 'reply=($something)'
88 something=(one two three)
89 zstyle -a :ztst:eval eval-style array && print -l $array
90 0:zstyle -e evaluations
95 # pattern ordering on output is not specified, so although in the
96 # current implementation it's deterministic we shouldn't
97 # assume it's always the same. Thus we sort the array.
98 # (It might be a nice touch to order patterns by weight, which is
99 # the way they are stored for each separate style.)
100 zstyle -g array && print -l ${(o)array}
101 0:retrieving patterns
107 zstyle -m :ztst:context:sub1 array-style 'w* *s'
108 0:positive pattern match
110 zstyle -m :ztst:context:sub1 array-style 'v'
111 1:negative pattern match
113 zstyle -g array ':ztst:context*' && print -l $array
114 0:retrieving styles by pattern
118 zstyle -g array ':ztst:context:sub1' array-style && print -l $array
119 0:retrieving values by pattern and name
125 zstyle -d :ztst:context:sub1
127 0:deleting styles by pattern only
129 > :ztst:context* false
131 >(eval) :ztst:* 'reply=($something)'
133 > :ztst:context:* second-scalar-value
134 > :ztst:context* other-scalar-value
136 zstyle -d :ztst:context\* scalar-style
138 0:deleting styles by pattern and style name
140 > :ztst:context* false
142 >(eval) :ztst:* 'reply=($something)'
144 > :ztst:context:* second-scalar-value