Imported Upstream version 1.8.8
[platform/upstream/doxygen.git] / testing / 060_command_switch.tcl
1 #// objective: tests processing of switch, only references/referencedby relations are relevant
2 #// check: 060__command__switch_8tcl.xml
3 #// config: REFERENCED_BY_RELATION = yes
4 #// config: REFERENCES_RELATION = yes
5 #// config: EXTRACT_ALL = yes
6 #// config: INLINE_SOURCES = no
7
8 ##
9 # \brief should be reference by every proc below
10 proc Invoked args {
11     puts "Procedure \"Invoked\" is invoked indeed. Ok."
12     return $args
13 }
14 ##
15 # \brief must not be reference by every proc below
16 proc NotInvoked args {
17     puts "Procedure \"NotInvoked\" is invoked. Not Ok!"
18     return $args
19 }
20 #
21 # check if call references work at all
22 proc a args {
23     Invoked NotInvoked
24     return
25 }
26 #
27 # switch command
28 # switch ?options? string pattern body ?pattern body ...? 
29 proc b args {
30     switch value NotInvoked {
31         } NotInvoked {
32         } default {
33             Invoked
34         }
35     return
36 }
37 proc c args {
38     switch value NotInvoked {
39         } [Invoked] {
40         } default {
41         }
42     return
43 }
44 proc d args {
45     switch NotInvoked pattern {
46         } [Invoked] {
47         } default {
48         }
49     return
50 }
51 proc e args {
52     switch [Invoked] pattern {
53         } NotInvoked {
54         } default {
55         }
56     return
57 }
58 proc f args {
59     switch -exact value pattern {
60         } NotInvoked {
61         } default {
62             Invoked
63         }
64     return
65 }
66 proc g args {
67     switch -exact -- value pattern {
68         } NotInvoked {
69         } default {
70             Invoked
71         }
72     return
73 }
74 proc h args {
75     switch -exact -- -value pattern {
76         } NotInvoked {
77         } default {
78             Invoked
79         }
80     return
81 }
82 # switch ?options? string {pattern body ?pattern body ...?} 
83 proc i args {
84     switch value {
85         NotInvoked {
86         }
87         NotInvoked {
88         }
89         default {
90             Invoked
91         }
92     }
93     return
94 }
95 proc j args {
96     switch vale {
97         NotInvoked {
98         }
99         [NotInvoked] {
100         }
101         default {
102             Invoked
103         }
104     }
105     return
106 }
107 proc k args {
108     switch NotInvoked {
109         [NotInvoked] {
110         }
111         NotInvoked {
112             Invoked
113         }
114         default {
115         }
116     }
117     return
118 }
119 proc l args {
120     switch [Invoked] {
121         pattern {
122         }
123         NotInvoked {
124         }
125         default {
126         }
127     }
128     return
129 }
130 proc m args {
131     switch -exact value {
132         pattern {
133         }
134         NotInvoked {
135         }
136         default {
137             Invoked
138         }
139     }
140     return
141 }
142 proc n args {
143     switch -exact -- value {
144         pattern {
145         }
146         NotInvoked {
147         }
148         default {
149             Invoked
150         }
151     }
152     return
153 }
154 proc o args {
155     switch -exact -- -value {
156         pattern {
157         }
158         NotInvoked {
159         }
160         default {
161             Invoked
162         }
163     }
164     return
165 }
166 proc p args {
167     switch -exact -- inquotes {
168         "inquotes" {
169             Invoked
170         }
171         default {
172         }
173     }
174     return
175 }
176 proc q args {
177     switch -exact -- "in quotes" {
178         "in quotes" {
179             Invoked
180         }
181         default {
182         }
183     }
184     return
185 }
186 proc r args {
187     switch -exact -- inbraces {
188         {inbraces} {
189             Invoked
190         }
191         default {
192         }
193     }
194     return
195 }
196 proc s args {
197     switch -exact -- {in braces} {
198         {in braces} {
199             Invoked
200         }
201         default {
202         }
203     }
204     return
205 }
206 # wrong syntax
207 #proc x args {
208 #    catch {switch -exact -- [Invoked] pattern1 NotInvoked pattern2}
209 #    return
210 #}
211 # The current version does not check the last argument beforehand.
212 # Therefore, all script elements are evaluated as scripts before
213 # the parser detects the dangling pattern. It throws a warning, at the very least.
214 # Anyway, for working code the documentation will be correct.
215 #proc y args {
216 #    catch {switch -exact -- [Invoked] {
217 #        pattern {
218 #            NotInvoked
219 #        }
220 #        NotInvoked {
221 #            NotInvoked
222 #        }
223 #        default {
224 #            NotInvoked
225 #        }
226 #        pattern
227 #    }}
228 #    return
229 #}
230 #
231 # call all single letter procs
232 # let tcl check what is called and what is not called
233 foreach p [info procs ?] {
234     puts "Check procedure \"$p\""
235     $p
236 }
237 exit
238