Imported Upstream version 1.8.8
[platform/upstream/doxygen.git] / testing / 058_bracket_recursion.tcl
1 #// objective: tests processing of commands inside brackets [], only references/referencedby relations are relevant
2 #// check: 058__bracket__recursion_8tcl.xml
3 #// config: REFERENCED_BY_RELATION = yes
4 #// config: REFERENCES_RELATION = yes
5 #// config: EXTRACT_ALL = yes
6 #// config: INLINE_SOURCES = yes
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 # check brackets with various quoting, bracing
28 proc b args {
29     set r [Invoked]
30     set r [list \[NotInvoked \]]
31     return
32 }
33 proc c args {
34     set r \{[Invoked]\}
35     set r {[NotInvoked]}
36     return
37 }
38 proc d args {
39     set r "[Invoked]"
40     set r "\[NotInvoked \]"
41     return
42 }
43 proc e args {
44     set r [list \[NotInvoked [Invoked]\]]
45     return
46 }
47 proc f args {
48     set r [list [Invoked \[NotInvoked \]]]
49     return
50 }
51 proc g args {
52     set r "{[Invoked]}"
53     set r "{\[NotInvoked \]}"
54     return
55 }
56 proc h args {
57     [Invoked set] r {[NotInvoked]}
58     return
59 }
60 # check brackets in tcl commands containing script arguments
61 #
62 # example generated according to
63 # https://groups.google.com/d/msg/comp.lang.tcl/G5-mc3GiIyY/e-AVD9t7xMkJ
64 proc i args {
65     foreach item [Invoked] {
66     return
67     }
68 }
69 proc j args {
70     foreach [Invoked item] [list one two three] {
71     }
72     return
73 }
74 proc k args {
75     while {[Invoked 0]} {
76     }
77 }
78 proc l args {
79     for {} {[Invoked 0]} {} {
80     }
81 }
82 proc m args {
83     if {[Invoked 1]} {
84     }
85 }
86 proc n args {
87     if [Invoked 1] {
88     }
89 }
90 proc o args {
91     if {0} {
92     } elseif {[Invoked 0]} {
93     }
94 }
95 # these are really nasty examples
96 # they shows, that the condition argument may not be parsed as a script
97 set NotInvoked \$NotInvoked
98 proc $NotInvoked args {
99     puts "Procedure \"\$NotInvoked\" is invoked. Not Ok!"
100     return $args
101 }
102 proc p args {
103     set NotInvoked \$NotInvoked
104     if {$NotInvoked eq [Invoked 1]} {
105     }
106     return
107 }
108 proc q args {
109     set NotInvoked \$NotInvoked
110     if {0} {
111     } elseif {$NotInvoked eq [Invoked 1]} {
112     }
113     return
114 }
115 proc r args {
116     set NotInvoked \$NotInvoked
117     while {$NotInvoked eq [Invoked 1]} {
118     }
119     return
120 }
121 proc s args {
122     set NotInvoked \$NotInvoked
123     for {} {$NotInvoked eq [Invoked 1]} {} {
124     }
125     return
126 }
127 # dangling open brackets should not confuse the scanner
128 proc t args {
129     set foo ]]]][Invoked]
130     return
131 }
132 # Example according to
133 # https://bugzilla.gnome.org/show_bug.cgi?id=729135
134 #                                       |
135 # Note the subtle difference in this    | whitespace
136 #                                       V
137 proc y {} {
138     set classifier_state {{bphy} }
139     if { ($classifier_state == {{bphy} }) } {
140         Invoked
141     }
142 }
143 proc z {} {
144     set classifier_state {{bphy} }
145     if { ($classifier_state == {{bphy} } ) } {
146         Invoked
147     }
148 }
149 #
150 # call all single letter procs
151 # let tcl check what is called and what is not called
152 foreach p [info procs ?] {
153     puts "Check procedure \"$p\""
154     $p
155 }
156 exit
157