关于tcl测试的问题

发布于 2024-11-19 16:33:36 字数 381 浏览 2 评论 0原文

我有一个关于 Tcl 的问题,我们正在使用 Tcl 为 C 和 C++ 应用程序编写一些测试用例。我看到一些 Tcl 测试用例是:

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

这些代码如何工作? #START: 和 #END: 意味着什么?以及为什么他们有索引,例如:

HELLO1 HELLO2 HELLO3

任何人都可以帮助我吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

星星的轨迹 2024-11-26 16:33:37

对于 Tcl 术语来说,这些测试看起来非常奇怪。如果他们读成这样(带有额外的分号):

if {0} { #START:HELLO1
//some code here
};#END:HELLO1

那么他们只会被屏蔽掉什么都不做的代码(字面意思是;Tcl 不会尝试为其生成代码,就像 C 或 C++ 编译器不太可能为 if(0){...} 做很多事情),但您得到的版本只是一个语法错误。大括号后面不应跟空格以外的任何内容(除非它是特殊的 {*} 语法,它会扩展替换)。

也就是说,我希望测试代码看起来更像这样:

doATest "the test name" {
    // Whatever makes the body of the test, in whatever language
}

doATest 可能会根据某些逻辑忽略测试,但整个脚本会被忽略。 (Tcl 自己的内置测试工具 - tcltest 包 - 遵循此模式,并带有一些额外的参数来控制诸如运行测试的条件和预期结果之类的事情。)

Those are very odd looking tests by Tcl terms. If they'd read like this (with the extra semicolon):

if {0} { #START:HELLO1
//some code here
};#END:HELLO1

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:

doATest "the test name" {
    // Whatever makes the body of the test, in whatever language
}

The doATest might ignore the test based on some logic, but the overall script would be oblivious. (Tcl's own built-in test harness — the tcltest package — follows this pattern with some extra parameters for controlling things like the conditions under which to run the test and the expected result.)

陌上芳菲 2024-11-26 16:33:37

哈希开始注释,但要小心。

http://wiki.tcl.tk/1669

Hashes begin comments, but be careful.

http://wiki.tcl.tk/1669

可遇━不可求 2024-11-26 16:33:37

那是一些非常奇怪的 Tcl 代码。它看起来像专有(?)测试工具的语法。您能给我们关于测试工具名称的任何其他提示吗?

一般来说,# 会启动一条注释(尽管比这稍微复杂一些),而 if {0} 会有效地阻止下面的代码块运行。也许您的测试工具提取 START 和 END 之间的代码并在测试模式下运行它,否则代码将被忽略?不过,}#(即:两者之间没有空格)通常应该抛出语法错误。您确定您向我们展示了测试代码的具体内容吗?

That is some very strange Tcl code. It looks like the syntax to a proprietary (?) testing tool. Can you give us any other hints about the name of the testing tool?

In general, # starts a comment (though it's a little more complicated than that) and if {0} effectively prevents the following block of code from running. Maybe your testing tool extracts the code between START and END and runs it when in testing mode, and the code is ignored otherwise? Though, }# (ie: with no space between the two) should normally throw a syntax error. Are you sure you're showing us exactly what the testing code looks like?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文