I have a question about Tcl, we are using Tcl to write some test cases for c and c++ application. I saw some Tcl test cases are:
if {0} { #START:HELLO1
//some code here
}#END:HELLO1
if {0} { #START:HELLO2
//some code here
}#END:HELLO2
if {0} { #START:HELLO3
//some code here
}#END:HELLO3
How does these code works? #START: and #END: means what? and why they have index such as:
HELLO1 HELLO2 HELLO3
can anyone help me on this?
Those are very odd looking tests by Tcl terms. If they’d read like this (with the extra semicolon):
Then they’d just be blocked out code that does nothing (literally; Tcl won’t attempt to generate code for it, just as a C or C++ compiler is unlikely to do much for
if(0){...}) but the version you’ve got is just a syntax error. Braces shouldn’t be followed by anything other than whitespace (unless it is the special{*}syntax, which does expanding substitution).That said, I’d expect testing code to look more like this:
The
doATestmight ignore the test based on some logic, but the overall script would be oblivious. (Tcl’s own built-in test harness — thetcltestpackage — follows this pattern with some extra parameters for controlling things like the conditions under which to run the test and the expected result.)