Blame testing/060_command_switch.tcl

Packit Service 50c9f2
#// objective: tests processing of switch, only references/referencedby relations are relevant
Packit Service 50c9f2
#// check: 060__command__switch_8tcl.xml
Packit Service 50c9f2
#// config: REFERENCED_BY_RELATION = yes
Packit Service 50c9f2
#// config: REFERENCES_RELATION = yes
Packit Service 50c9f2
#// config: EXTRACT_ALL = yes
Packit Service 50c9f2
#// config: INLINE_SOURCES = no
Packit Service 50c9f2
Packit Service 50c9f2
##
Packit Service 50c9f2
# \brief should be reference by every proc below
Packit Service 50c9f2
proc Invoked args {
Packit Service 50c9f2
    puts "Procedure \"Invoked\" is invoked indeed. Ok."
Packit Service 50c9f2
    return $args
Packit Service 50c9f2
}
Packit Service 50c9f2
##
Packit Service 50c9f2
# \brief must not be reference by every proc below
Packit Service 50c9f2
proc NotInvoked args {
Packit Service 50c9f2
    puts "Procedure \"NotInvoked\" is invoked. Not Ok!"
Packit Service 50c9f2
    return $args
Packit Service 50c9f2
}
Packit Service 50c9f2
#
Packit Service 50c9f2
# check if call references work at all
Packit Service 50c9f2
proc a args {
Packit Service 50c9f2
    Invoked NotInvoked
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
#
Packit Service 50c9f2
# switch command
Packit Service 50c9f2
# switch ?options? string pattern body ?pattern body ...? 
Packit Service 50c9f2
proc b args {
Packit Service 50c9f2
    switch value NotInvoked {
Packit Service 50c9f2
        } NotInvoked {
Packit Service 50c9f2
        } default {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc c args {
Packit Service 50c9f2
    switch value NotInvoked {
Packit Service 50c9f2
        } [Invoked] {
Packit Service 50c9f2
        } default {
Packit Service 50c9f2
        }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc d args {
Packit Service 50c9f2
    switch NotInvoked pattern {
Packit Service 50c9f2
        } [Invoked] {
Packit Service 50c9f2
        } default {
Packit Service 50c9f2
        }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc e args {
Packit Service 50c9f2
    switch [Invoked] pattern {
Packit Service 50c9f2
        } NotInvoked {
Packit Service 50c9f2
        } default {
Packit Service 50c9f2
        }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc f args {
Packit Service 50c9f2
    switch -exact value pattern {
Packit Service 50c9f2
        } NotInvoked {
Packit Service 50c9f2
        } default {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc g args {
Packit Service 50c9f2
    switch -exact -- value pattern {
Packit Service 50c9f2
        } NotInvoked {
Packit Service 50c9f2
        } default {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc h args {
Packit Service 50c9f2
    switch -exact -- -value pattern {
Packit Service 50c9f2
        } NotInvoked {
Packit Service 50c9f2
        } default {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
# switch ?options? string {pattern body ?pattern body ...?} 
Packit Service 50c9f2
proc i args {
Packit Service 50c9f2
    switch value {
Packit Service 50c9f2
        NotInvoked {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        NotInvoked {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc j args {
Packit Service 50c9f2
    switch vale {
Packit Service 50c9f2
        NotInvoked {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        [NotInvoked] {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc k args {
Packit Service 50c9f2
    switch NotInvoked {
Packit Service 50c9f2
        [NotInvoked] {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        NotInvoked {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc l args {
Packit Service 50c9f2
    switch [Invoked] {
Packit Service 50c9f2
        pattern {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        NotInvoked {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc m args {
Packit Service 50c9f2
    switch -exact value {
Packit Service 50c9f2
        pattern {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        NotInvoked {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc n args {
Packit Service 50c9f2
    switch -exact -- value {
Packit Service 50c9f2
        pattern {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        NotInvoked {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc o args {
Packit Service 50c9f2
    switch -exact -- -value {
Packit Service 50c9f2
        pattern {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        NotInvoked {
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc p args {
Packit Service 50c9f2
    switch -exact -- inquotes {
Packit Service 50c9f2
        "inquotes" {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc q args {
Packit Service 50c9f2
    switch -exact -- "in quotes" {
Packit Service 50c9f2
        "in quotes" {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc r args {
Packit Service 50c9f2
    switch -exact -- inbraces {
Packit Service 50c9f2
        {inbraces} {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
proc s args {
Packit Service 50c9f2
    switch -exact -- {in braces} {
Packit Service 50c9f2
        {in braces} {
Packit Service 50c9f2
            Invoked
Packit Service 50c9f2
        }
Packit Service 50c9f2
        default {
Packit Service 50c9f2
        }
Packit Service 50c9f2
    }
Packit Service 50c9f2
    return
Packit Service 50c9f2
}
Packit Service 50c9f2
# wrong syntax
Packit Service 50c9f2
#proc x args {
Packit Service 50c9f2
#    catch {switch -exact -- [Invoked] pattern1 NotInvoked pattern2}
Packit Service 50c9f2
#    return
Packit Service 50c9f2
#}
Packit Service 50c9f2
# The current version does not check the last argument beforehand.
Packit Service 50c9f2
# Therefore, all script elements are evaluated as scripts before
Packit Service 50c9f2
# the parser detects the dangling pattern. It throws a warning, at the very least.
Packit Service 50c9f2
# Anyway, for working code the documentation will be correct.
Packit Service 50c9f2
#proc y args {
Packit Service 50c9f2
#    catch {switch -exact -- [Invoked] {
Packit Service 50c9f2
#        pattern {
Packit Service 50c9f2
#            NotInvoked
Packit Service 50c9f2
#        }
Packit Service 50c9f2
#        NotInvoked {
Packit Service 50c9f2
#            NotInvoked
Packit Service 50c9f2
#        }
Packit Service 50c9f2
#        default {
Packit Service 50c9f2
#            NotInvoked
Packit Service 50c9f2
#        }
Packit Service 50c9f2
#        pattern
Packit Service 50c9f2
#    }}
Packit Service 50c9f2
#    return
Packit Service 50c9f2
#}
Packit Service 50c9f2
#
Packit Service 50c9f2
# call all single letter procs
Packit Service 50c9f2
# let tcl check what is called and what is not called
Packit Service 50c9f2
foreach p [info procs ?] {
Packit Service 50c9f2
    puts "Check procedure \"$p\""
Packit Service 50c9f2
    $p
Packit Service 50c9f2
}
Packit Service 50c9f2
exit
Packit Service 50c9f2