summaryrefslogtreecommitdiff
path: root/tix/tests/general/var1.tcl
blob: 7422821fe71109444ea478116f276dec9131ccdb (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
proc About {} {
    return "Testing -variable option with Tix widgets"
}

proc Test {} {
    global foo bar arr

    set classes {tixControl tixComboBox}
    set value 1234

    foreach class $classes {
	set w [$class .foo]
	pack $w
	update idletasks

	TestBlock var1-1.1 {$class: config -variable with initialized value} {
	    set bar $value
	    $w config -variable bar
	    update idletasks
	    Assert {[$w cget -value] == $value}
	}

	TestBlock var1-1.2 {$class: config -variable w/ uninitialized value} {
	    destroy $w
	    set w [$class .foo]
	    $w config -variable bar
	    Assert {[$w cget -value] == $bar}
	}

	TestBlock var1-1.2 {$class: config -variable} {
	    set foo 111
	    $w config -variable foo
	    update idletasks
	    Assert {[$w cget -value] == $foo}
	}

	TestBlock var1-1.2 {$class: config -value} {
	    $w config -value 123
	    Assert {[$w cget -value] == 123}
	    Assert {[set [$w cget -variable]] == 123}
	}

	TestBlock var1-1.2 {$class: config -variable on array variable} {
	    set arr(12) 1234
	    $w config -variable arr(12)
	    Assert {[$w cget -value] == $arr(12)}
	}

	TestBlock var1-1.2 {$class: config -value on array variable} {
	    $w config -value 12
	    Assert {[$w cget -value] == 12}
	    Assert {[set [$w cget -variable]] == 12}
	}

	catch {
	    destroy $w
	}
    }
}