auto.def: tclprefix should not be enabled by default
[jimtcl.git] / tests / exprsugar.test
blob9579203ac591f66abea85e5e414f89c6d3045ce9
1 source [file dirname [info script]]/testing.tcl
3 needs constraint jim
5 # Test the expr-sugar syntax: $(...)
7 test exprsugar-1.1 {Simple operations} {
8         set x $(2)
9 } 2
10 test exprsugar-1.2 {Simple operations} {
11         set x $(-3)
12 } -3
13 test exprsugar-1.3 {Simple operations} {
14         set x $(!0)
15 } 1
16 test exprsugar-1.4 {Simple operations} {
17         set a 3
18         set x $($a)
19 } 3
20 test exprsugar-1.5 {Simple operations} {
21         set x $($a + 4)
22 } 7
23 test exprsugar-1.6 {Simple operations} {
24         set x $(6 * 7 + 2)
25 } 44
26 test exprsugar-1.7 {Simple operations} {
27         set a bb
28         set x $($a in {aa bb cc})
29 } 1
30 test exprsugar-1.8 {Simple operations} {
31         set a 1
32         set x $($a ? "yes" : "no")
33 } yes
34 test exprsugar-1.9 {Simple operations} {
35         set a 1
36         set x $([incr a])
37         list $a $x
38 } {2 2}
39 # expr sugar inside an expression is an error
40 test exprsugar-1.10 {Simple operations} {
41         catch {set x $(1 + $(5 * 7))}
42 } 1
43 test exprsugar-1.11 {Simple operations} {
44         unset a
45         set a(b) 3
46         set x $(2 + $a(b))
47 } 5
48 test exprsugar-1.12 {Simple operations} {
49         set x $((2 + 4))
50 } 6
52 testreport