Blame tests/upstream-test-suite/059_command_catch.tcl
|
Than Ngo |
b7bcaa |
#// objective: tests processing of catch/eval, only references/referencedby relations are relevant
|
|
Than Ngo |
b7bcaa |
#// check: 059__command__catch_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 = no
|
|
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 |
# catch command
|
|
Than Ngo |
b7bcaa |
# Tcl8.5: catch script ?resultVarName? ?optionsVarName?
|
|
Than Ngo |
b7bcaa |
proc b args {
|
|
Than Ngo |
b7bcaa |
catch Invoked
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc c args {
|
|
Than Ngo |
b7bcaa |
catch Invoked NotInvoked
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc d args {
|
|
Than Ngo |
b7bcaa |
catch Invoked NotInvoked NotInvoked
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc e args {
|
|
Than Ngo |
b7bcaa |
set r [catch Invoked NotInvoked NotInvoked]
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc f args {
|
|
Than Ngo |
b7bcaa |
set r [catch {Invoked} NotInvoked NotInvoked]
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc g args {
|
|
Than Ngo |
b7bcaa |
set r [catch {
|
|
Than Ngo |
b7bcaa |
set x [Invoked]
|
|
Than Ngo |
b7bcaa |
} NotInvoked NotInvoked]
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
# eval arg ?arg ...?
|
|
Than Ngo |
b7bcaa |
proc h args {
|
|
Than Ngo |
b7bcaa |
eval Invoked NotInvoked
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
proc i args {
|
|
Than Ngo |
b7bcaa |
eval set NotInvoked [Invoked NotInvoked]
|
|
Than Ngo |
b7bcaa |
return
|
|
Than Ngo |
b7bcaa |
}
|
|
Than Ngo |
b7bcaa |
# This is a striped down example. Original:
|
|
Than Ngo |
b7bcaa |
#
|
|
Than Ngo |
b7bcaa |
# jpeg.tcl --
|
|
Than Ngo |
b7bcaa |
#
|
|
Than Ngo |
b7bcaa |
# Querying and modifying JPEG image files.
|
|
Than Ngo |
b7bcaa |
#
|
|
Than Ngo |
b7bcaa |
# Copyright (c) 2004 Aaron Faupell <afaupell@users.sourceforge.net>
|
|
Than Ngo |
b7bcaa |
#
|
|
Than Ngo |
b7bcaa |
# ...
|
|
Than Ngo |
b7bcaa |
# eval [list addComment $file] [lreplace $com 0 0 $comment]
|
|
Than Ngo |
b7bcaa |
# ...
|
|
Than Ngo |
b7bcaa |
proc j args {
|
|
Than Ngo |
b7bcaa |
eval [list set] [list NotInvoked] [Invoked NotInvoked]
|
|
Than Ngo |
b7bcaa |
return
|
|
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 |
|