Blame tests/upstream-test-suite/057_caller_graphs.tcl

Than Ngo b7bcaa
#// objective: test for completeness and correctness of references/referencedby relations 
Than Ngo b7bcaa
#// check: 057__caller__graphs_8tcl.xml
Than Ngo b7bcaa
#// check: __057__caller__graphs_8tcl.xml
Than Ngo b7bcaa
#// check: namespacebar.xml
Than Ngo b7bcaa
#// check: namespacefoo.xml
Than Ngo b7bcaa
#// check: namespace1.xml
Than Ngo b7bcaa
#// check: namespace1_1_11.xml
Than Ngo b7bcaa
#// check: namespace1_1_11_1_11.xml
Than Ngo b7bcaa
#// check: namespace2.xml
Than Ngo b7bcaa
#// check: namespace2_1_12.xml
Than Ngo b7bcaa
#// check: namespace2_1_12_1_12.xml
Than Ngo b7bcaa
#// check: namespace2_1_12_1_12_1_12.xml
Than Ngo b7bcaa
#// check: namespace2_1_12_1_12_1_12_1_12.xml
Than Ngo b7bcaa
#// config: EXTRACT_ALL = yes
Than Ngo b7bcaa
#// config: INLINE_SOURCES = no
Than Ngo b7bcaa
#// config: REFERENCED_BY_RELATION = yes
Than Ngo b7bcaa
#// config: REFERENCES_RELATION = yes
Than Ngo b7bcaa
#// config: INPUT = $INPUTDIR/057_caller_graphs.tcl $INPUTDIR/_057_caller_graphs.tcl
Than Ngo b7bcaa
# config: HAVE_DOT = yes
Than Ngo b7bcaa
# config: CALLER_GRAPH = yes
Than Ngo b7bcaa
# config: CALL_GRAPH = yes
Than Ngo b7bcaa
# config: GENERATE_HTML = yes
Than Ngo b7bcaa
Than Ngo b7bcaa
# This is a stripped down example from my code.
Than Ngo b7bcaa
# Doxygen 1.8.7 generates the correct relations (xml)
Than Ngo b7bcaa
# but caller graphs will be incomplete.
Than Ngo b7bcaa
# It does not generate any relations at all if INLINE_SOURCES = no.
Than Ngo b7bcaa
namespace eval bar {}
Than Ngo b7bcaa
proc bar::slave { } {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
    if {1} then {
Than Ngo b7bcaa
        bar::baz
Than Ngo b7bcaa
    }
Than Ngo b7bcaa
    return 
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc bar::baz {} {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
    bar::bazbaz
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc bar::bazbaz {} {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
}
Than Ngo b7bcaa
namespace eval foo {}
Than Ngo b7bcaa
proc foo::master {  } {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline $info(proc)
Than Ngo b7bcaa
    bar::slave
Than Ngo b7bcaa
    return
Than Ngo b7bcaa
}
Than Ngo b7bcaa
#
Than Ngo b7bcaa
# now we check tcl's rules: from the help
Than Ngo b7bcaa
# NAME RESOLUTION
Than Ngo b7bcaa
#... Command names are also always resolved by looking in the current
Than Ngo b7bcaa
#namespace first. If not found there, they are searched for in every namespace on
Than Ngo b7bcaa
#the current namespace's command path (which is empty by default). If not found
Than Ngo b7bcaa
#there, command names are looked up in the global namespace (or, failing that,
Than Ngo b7bcaa
#are processed by the unknown command.) ...
Than Ngo b7bcaa
#
Than Ngo b7bcaa
namespace eval ::1::1::1 {}
Than Ngo b7bcaa
proc ::baz args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::1::baz args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::bar args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::1::bar args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::1::1::bar args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::1::1::1::bar args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::1::test1 args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline $info(proc)
Than Ngo b7bcaa
    baz
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::1::test2 args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline $info(proc)
Than Ngo b7bcaa
    bar
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::1::test3 args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline $info(proc)
Than Ngo b7bcaa
    ::bar
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::1::test4 args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline $info(proc)
Than Ngo b7bcaa
    1::bar
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::1::test5 args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline $info(proc)
Than Ngo b7bcaa
    1::baz
Than Ngo b7bcaa
}
Than Ngo b7bcaa
#
Than Ngo b7bcaa
# funny example, do you see the infinite loop?
Than Ngo b7bcaa
# we stop before the interpreter crashes
Than Ngo b7bcaa
set ::countdown 10
Than Ngo b7bcaa
namespace eval ::2::2::2::2::2 {}
Than Ngo b7bcaa
proc ::next args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts $info(proc)
Than Ngo b7bcaa
    2::next
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::2::next args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts $info(proc)
Than Ngo b7bcaa
    incr ::countdown -1
Than Ngo b7bcaa
    if {$::countdown>0} then {
Than Ngo b7bcaa
        2::next
Than Ngo b7bcaa
    } else {
Than Ngo b7bcaa
        puts "stop after 10 rounds."
Than Ngo b7bcaa
    }
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::2::2::next args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts $info(proc)
Than Ngo b7bcaa
    2::next
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::2::2::2::next args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts $info(proc)
Than Ngo b7bcaa
    2::next
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::2::2::2::2::next args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts $info(proc)
Than Ngo b7bcaa
    2::next
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc ::2::2::2::2::2::next args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts $info(proc)
Than Ngo b7bcaa
    2::next
Than Ngo b7bcaa
}
Than Ngo b7bcaa
#
Than Ngo b7bcaa
# cross check with two files
Than Ngo b7bcaa
# If doxygen did not do two passes, then xrefs would depend on file order
Than Ngo b7bcaa
# and would be incomplete.
Than Ngo b7bcaa
source _057_caller_graphs.tcl
Than Ngo b7bcaa
proc master args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
    inFileB
Than Ngo b7bcaa
    return
Than Ngo b7bcaa
}
Than Ngo b7bcaa
proc inFileA args {
Than Ngo b7bcaa
    array set info [info frame 0]; puts -nonewline ->$info(proc)
Than Ngo b7bcaa
    return
Than Ngo b7bcaa
}
Than Ngo b7bcaa
# now, check with tcl what is called
Than Ngo b7bcaa
foo::master
Than Ngo b7bcaa
puts ""
Than Ngo b7bcaa
foreach proc [lsort [info procs ::1::test?]] {
Than Ngo b7bcaa
    $proc
Than Ngo b7bcaa
    puts ""
Than Ngo b7bcaa
}
Than Ngo b7bcaa
::next
Than Ngo b7bcaa
master
Than Ngo b7bcaa
exit
Than Ngo b7bcaa