1 Star 0 Fork 0

liangkangnan/jimtcl

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
exprsugar.test 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
Steve Bennett 提交于 2019-11-05 16:16 +08:00 . expr-sugar: $() should return non-error codes
source [file dirname [info script]]/testing.tcl
needs constraint jim
# Test the expr-sugar syntax: $(...)
test exprsugar-1.1 {Simple operations} {
set x $(2)
} 2
test exprsugar-1.2 {Simple operations} {
set x $(-3)
} -3
test exprsugar-1.3 {Simple operations} {
set x $(!0)
} 1
test exprsugar-1.4 {Simple operations} {
set a 3
set x $($a)
} 3
test exprsugar-1.5 {Simple operations} {
set x $($a + 4)
} 7
test exprsugar-1.6 {Simple operations} {
set x $(6 * 7 + 2)
} 44
test exprsugar-1.7 {Simple operations} {
set a bb
set x $($a in {aa bb cc})
} 1
test exprsugar-1.8 {Simple operations} {
set a 1
set x $($a ? "yes" : "no")
} yes
test exprsugar-1.9 {Simple operations} {
set a 1
set x $([incr a])
list $a $x
} {2 2}
# expr sugar inside an expression is an error
test exprsugar-1.10 {Simple operations} {
catch {set x $(1 + $(5 * 7))}
} 1
test exprsugar-1.11 {Simple operations} {
unset a
set a(b) 3
set x $(2 + $a(b))
} 5
test exprsugar-1.12 {Simple operations} {
set x $((2 + 4))
} 6
# This necessary to ensure that things like exit will pass through expr-sugar
test exprsugar-1.13 {Non-error return inside expr-sugar} -body {
proc a {} { break }
set x $([a])
} -returnCodes break
testreport
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liangkangnan/jimtcl.git
git@gitee.com:liangkangnan/jimtcl.git
liangkangnan
jimtcl
jimtcl
master

搜索帮助