1%prep
2
3# Test the use of styles, if the zsh/zutil module is available.
4
5  if (zmodload zsh/zutil >/dev/null 2>/dev/null); then
6    zmodload zsh/zutil
7  else
8    ZTST_unimplemented="can't load the zsh/zutil module for testing"
9  fi
10
11%test
12  zstyle :random:stuff any-old-style with any old value
13  zstyle :randomly:chosen some-other-style I can go on and on
14  zstyle -d
15  zstyle
160:zstyle -d restores a pristine state
17
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
250:defining styles
26
27# styles are now sorted, but patterns are in order of definition
28  zstyle
290:listing styles in default format
30>array-style
31>        :ztst:context:sub1 array value elements 'with spaces'
32>boolean-style
33>        :ztst:context:sub1 true
34>        :ztst:context* false
35>scalar-style
36>        :ztst:context:sub1 scalar-value
37>        :ztst:context:* second-scalar-value
38>        :ztst:context* other-scalar-value
39
40  zstyle -L
410: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
48
49  zstyle -b :ztst:context:sub1 boolean-style bool; print $bool
50  zstyle -t :ztst:context:sub1 boolean-style
510:boolean test -b/-t + true
52>yes
53
54  zstyle -b :ztst:context:sub2 boolean-style bool; print $bool
55  zstyle -t :ztst:context:sub2 boolean-style
561:boolean test -b/-t + false
57>no
58
59  zstyle -b :ztst:context:sub1 boolean-unset-style bool; print $bool
60  zstyle -t :ztst:context:sub1 boolean-unset-style
612:boolean test -b/-t + unset
62>no
63
64  zstyle -T :ztst:context:sub1 boolean-style
650:boolean test -T + true
66
67  zstyle -T :ztst:context:sub2 boolean-style
681:boolean test -T + false
69
70  zstyle -T :ztst:context:sub1 boolean-unset-style
710:boolean test -T + unset
72
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
770:pattern matching rules
78>scalar-value
79>second-scalar-value
80>other-scalar-value
81>no match
82
83  zstyle -s :ztst:context:sub1 array-style scalar + && print $scalar
840:scalar with separator
85>array+value+elements+with spaces
86
87  zstyle -e :ztst:\* eval-style 'reply=($something)'
88  something=(one two three)
89  zstyle -a :ztst:eval eval-style array && print -l $array
900:zstyle -e evaluations
91>one
92>two
93>three
94
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}
1010:retrieving patterns
102>:ztst:*
103>:ztst:context*
104>:ztst:context:*
105>:ztst:context:sub1
106
107  zstyle -m :ztst:context:sub1 array-style 'w* *s'
1080:positive pattern match
109
110  zstyle -m :ztst:context:sub1 array-style 'v'
1111:negative pattern match
112
113  zstyle -g array ':ztst:context*' && print -l $array
1140:retrieving styles by pattern
115>boolean-style
116>scalar-style
117
118  zstyle -g array ':ztst:context:sub1' array-style && print -l $array
1190:retrieving values by pattern and name
120>array
121>value
122>elements
123>with spaces
124
125  zstyle -d :ztst:context:sub1
126  zstyle
1270:deleting styles by pattern only
128>boolean-style
129>        :ztst:context* false
130>eval-style
131>(eval)  :ztst:* 'reply=($something)'
132>scalar-style
133>        :ztst:context:* second-scalar-value
134>        :ztst:context* other-scalar-value
135
136  zstyle -d :ztst:context\* scalar-style
137  zstyle
1380:deleting styles by pattern and style name
139>boolean-style
140>        :ztst:context* false
141>eval-style
142>(eval)  :ztst:* 'reply=($something)'
143>scalar-style
144>        :ztst:context:* second-scalar-value
145
146