26754: tweak zgetdir() and test for realpath()
[zsh.git] / Test / V05styles.ztst
blobe932b54743f57da22ff1c6807c232f8c142e90f4
1 %prep
3 # Test the use of styles, if the zsh/zutil module is available.
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
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
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
25 0:defining styles
27 # styles are now sorted, but patterns are in order of definition
28   zstyle
29 0: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
40   zstyle -L
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
52 >yes
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
57 >no
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
62 >no
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
78 >scalar-value
79 >second-scalar-value
80 >other-scalar-value
81 >no match
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
91 >one
92 >two
93 >three
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
102 >:ztst:*
103 >:ztst:context*
104 >:ztst:context:*
105 >:ztst:context:sub1
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
115 >boolean-style
116 >scalar-style
118   zstyle -g array ':ztst:context:sub1' array-style && print -l $array
119 0:retrieving values by pattern and name
120 >array
121 >value
122 >elements
123 >with spaces
125   zstyle -d :ztst:context:sub1
126   zstyle
127 0: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
136   zstyle -d :ztst:context\* scalar-style
137   zstyle
138 0: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