aboutsummaryrefslogtreecommitdiff
path: root/tests/leval.test
blob: 1d924d107fc179274925d1b8fd0ccce931d60ecb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
source [file dirname [info script]]/testing.tcl

needs cmd leval

test leval-1.1 {no args} -body {
    leval
} -returnCodes error -result {wrong # args: should be "leval string"}

test leval-1.2 {too many args} -body {
    leval
} -returnCodes error -result {wrong # args: should be "leval string"}

test leval-1.3 {basic, no subst} -body {
    leval {a b c}
} -result {a b c}

test leval-1.4 {basics, vars} -body {
    set a 1
    set b "2 3"
    set c "4 5 6"
    set d ".1"
    leval {$a $b $c$d}
} -result {1 {2 3} {4 5 6.1}}

test leval-1.5 {comments} -body {
    # It is helpful to be able to include comments in a list definition
    # just like in a script
    leval {
        # comment line
        1
        2 3
        # comment line with continuation \
        this is also a comments
        4 ;# comment at end of line
        5
    }
} -result {1 2 3 4 5}

test leval-1.6 {commands} -body {
    set a 0
    leval {
        [incr a]
        [incr a]
        [list d e]
        [string cat f g][string cat h i]
    }
} -result {1 2 {d e} fghi}

test leval-1.7 {expand} -body {
    set a {1 2}
	set space " "
    set b {3 4 5}
    leval {
        {*}$a
        {*}$a$space$b$space[list 6 7]
    }
} -result {1 2 1 2 3 4 5 6 7}

testreport