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
