|
Than Ngo |
b7bcaa |
#// objective: tests processing of commands inside brackets [], only references/referencedby relations are relevant
|
|
Than Ngo |
b7bcaa |
#// check: 058__bracket__recursion_8tcl.xml
|
|
Than Ngo |
b7bcaa |
#// config: REFERENCED_BY_RELATION = yes
|
|
Than Ngo |
b7bcaa |
#// config: REFERENCES_RELATION = yes
|
|
Than Ngo |
b7bcaa |
#// config: EXTRACT_ALL = yes
|
|
Than Ngo |
b7bcaa |
#// config: INLINE_SOURCES = yes
|
|
Than Ngo |
b7bcaa |
|
|
Than Ngo |
b7bcaa |
##
|
|
Than Ngo |
b7bcaa |
# \brief should be reference by every proc below
|
|
Than Ngo |
b7bcaa |
proc Invoked args {
|
|
Than Ngo |
b7bcaa |
puts "Procedure \"Invoked\" is invoked indeed. Ok."
|
|
Than Ngo |
b7bcaa |
return $args
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
##
|
|
Than Ngo |
b7bcaa |
# \brief must not be reference by every proc below
|
|
Than Ngo |
b7bcaa |
proc NotInvoked args {
|
|
Than Ngo |
b7bcaa |
puts "Procedure \"NotInvoked\" is invoked. Not Ok!"
|
|
Than Ngo |
b7bcaa |
return $args
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
#
|
|
Than Ngo |
b7bcaa |
# check if call references work at all
|
|
Than Ngo |
b7bcaa |
proc a args {
|
|
Than Ngo |
b7bcaa |
Invoked NotInvoked
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
#
|
|
Than Ngo |
b7bcaa |
# check brackets with various quoting, bracing
|
|
Than Ngo |
b7bcaa |
proc b args {
|
|
Than Ngo |
b7bcaa |
set r [Invoked]
|
|
Than Ngo |
b7bcaa |
set r [list \[NotInvoked \]]
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc c args {
|
|
Than Ngo |
b7bcaa |
set r \{[Invoked]\}
|
|
Than Ngo |
b7bcaa |
set r {[NotInvoked]}
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc d args {
|
|
Than Ngo |
b7bcaa |
set r "[Invoked]"
|
|
Than Ngo |
b7bcaa |
set r "\[NotInvoked \]"
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc e args {
|
|
Than Ngo |
b7bcaa |
set r [list \[NotInvoked [Invoked]\]]
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc f args {
|
|
Than Ngo |
b7bcaa |
set r [list [Invoked \[NotInvoked \]]]
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc g args {
|
|
Than Ngo |
b7bcaa |
set r "{[Invoked]}"
|
|
Than Ngo |
b7bcaa |
set r "{\[NotInvoked \]}"
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc h args {
|
|
Than Ngo |
b7bcaa |
[Invoked set] r {[NotInvoked]}
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
# check brackets in tcl commands containing script arguments
|
|
Than Ngo |
b7bcaa |
#
|
|
Than Ngo |
b7bcaa |
# example generated according to
|
|
Than Ngo |
b7bcaa |
# https://groups.google.com/d/msg/comp.lang.tcl/G5-mc3GiIyY/e-AVD9t7xMkJ
|
|
Than Ngo |
b7bcaa |
proc i args {
|
|
Than Ngo |
b7bcaa |
foreach item [Invoked] {
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc j args {
|
|
Than Ngo |
b7bcaa |
foreach [Invoked item] [list one two three] {
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc k args {
|
|
Than Ngo |
b7bcaa |
while {[Invoked 0]} {
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc l args {
|
|
Than Ngo |
b7bcaa |
for {} {[Invoked 0]} {} {
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc m args {
|
|
Than Ngo |
b7bcaa |
if {[Invoked 1]} {
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc n args {
|
|
Than Ngo |
b7bcaa |
if [Invoked 1] {
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc o args {
|
|
Than Ngo |
b7bcaa |
if {0} {
|
|
Than Ngo |
b7bcaa |
} elseif {[Invoked 0]} {
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
# these are really nasty examples
|
|
Than Ngo |
b7bcaa |
# they shows, that the condition argument may not be parsed as a script
|
|
Than Ngo |
b7bcaa |
set NotInvoked \$NotInvoked
|
|
Than Ngo |
b7bcaa |
proc $NotInvoked args {
|
|
Than Ngo |
b7bcaa |
puts "Procedure \"\$NotInvoked\" is invoked. Not Ok!"
|
|
Than Ngo |
b7bcaa |
return $args
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc p args {
|
|
Than Ngo |
b7bcaa |
set NotInvoked \$NotInvoked
|
|
Than Ngo |
b7bcaa |
if {$NotInvoked eq [Invoked 1]} {
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc q args {
|
|
Than Ngo |
b7bcaa |
set NotInvoked \$NotInvoked
|
|
Than Ngo |
b7bcaa |
if {0} {
|
|
Than Ngo |
b7bcaa |
} elseif {$NotInvoked eq [Invoked 1]} {
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc r args {
|
|
Than Ngo |
b7bcaa |
set NotInvoked \$NotInvoked
|
|
Than Ngo |
b7bcaa |
while {$NotInvoked eq [Invoked 1]} {
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc s args {
|
|
Than Ngo |
b7bcaa |
set NotInvoked \$NotInvoked
|
|
Than Ngo |
b7bcaa |
for {} {$NotInvoked eq [Invoked 1]} {} {
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
# dangling open brackets should not confuse the scanner
|
|
Than Ngo |
b7bcaa |
proc t args {
|
|
Than Ngo |
b7bcaa |
set foo ]]]][Invoked]
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
# Example according to
|
|
Than Ngo |
b7bcaa |
# https://bugzilla.gnome.org/show_bug.cgi?id=729135
|
|
Than Ngo |
b7bcaa |
# |
|
|
Than Ngo |
b7bcaa |
# Note the subtle difference in this | whitespace
|
|
Than Ngo |
b7bcaa |
# V
|
|
Than Ngo |
b7bcaa |
proc y {} {
|
|
Than Ngo |
b7bcaa |
set classifier_state {{bphy} }
|
|
Than Ngo |
b7bcaa |
if { ($classifier_state == {{bphy} }) } {
|
|
Than Ngo |
b7bcaa |
Invoked
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc z {} {
|
|
Than Ngo |
b7bcaa |
set classifier_state {{bphy} }
|
|
Than Ngo |
b7bcaa |
if { ($classifier_state == {{bphy} } ) } {
|
|
Than Ngo |
b7bcaa |
Invoked
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
#
|
|
Than Ngo |
b7bcaa |
# call all single letter procs
|
|
Than Ngo |
b7bcaa |
# let tcl check what is called and what is not called
|
|
Than Ngo |
b7bcaa |
foreach p [info procs ?] {
|
|
Than Ngo |
b7bcaa |
puts "Check procedure \"$p\""
|
|
Than Ngo |
b7bcaa |
$p
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
exit
|
|
Than Ngo |
b7bcaa |
|