1# Commands covered:  treectrl's widget command item
2#
3# This file contains a collection of tests for the item widget command of
4# the tktreectrl extension.  Sourcing this file into Tcl runs the tests and
5# generates output for errors.  No output means no errors were found.
6#
7# Copyright (c) 2000 by Scriptics Corporation.
8# Copyright (c) 2002 by Christian Krone.
9#
10# See the file "license.terms" for information on usage and redistribution
11# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
13if {[lsearch [namespace children] ::tcltest] == -1} {
14    package require tcltest 2
15    namespace import ::tcltest::*
16}
17
18package require Tk
19package require treectrl
20
21test item-0.1 {some needed preparations} -body {
22    pack [treectrl .t]
23} -result {}
24
25test item-1.1 {item: missing command} -body {
26    .t item
27} -returnCodes error -result {wrong # args: should be ".t item command ?arg arg ...?"}
28
29test item-2.2 {item: invalid command} -body {
30    .t item foo
31} -returnCodes error -result {bad command "foo": must be *} -match glob
32
33# Before continuing to test the item descriptions and their modifiers,
34# lets create some items with this hierarchy:
35# 0
36# + 1
37# | + 2
38# | + 3
39# |   + 4
40# + 5
41# | + 6
42# | + 7
43# + 8
44test item-2.4 {create some items} -body {
45    set n1 [.t item create]; .t item lastchild 0   $n1
46    set n2 [.t item create]; .t item lastchild $n1 $n2
47    set n3 [.t item create]; .t item lastchild $n1 $n3
48    set n4 [.t item create]; .t item lastchild $n3 $n4
49    set n5 [.t item create]; .t item lastchild 0   $n5
50    set n6 [.t item create]; .t item lastchild $n5 $n6
51    set n7 [.t item create]; .t item lastchild $n5 $n7
52    set n8 [.t item create]; .t item lastchild 0   $n8
53} -result {8}
54
55test item-2.5 {some more preparations} -body {
56    .t state define state0
57    .t element create eBorder border
58    .t element create eImage image
59    .t element create eRect rect
60    .t element create eText text -fill red
61    .t style create testStyle
62    .t style elements testStyle {eText eBorder}
63} -result {}
64
65test item-2.6 {item create} -body {
66    list [.t item create] [.t item create] [.t item create]
67} -result {9 10 11}
68
69test item-3.1 {item delete: missing itemDesc} -body {
70    .t item delete
71} -returnCodes error -result {wrong # args: should be ".t item delete first ?last?"}
72
73test item-3.2 {item delete: unknown item} -body {
74    .t item delete 999
75} -returnCodes error -result {item "999" doesn't exist}
76
77test item-3.3 {item delete: one item} -body {
78    .t item delete 9
79} -result {}
80
81test item-3.4 {item delete: item range without common ancestor} -body {
82    .t item delete 10 11
83} -returnCodes error -result {item 10 and item 11 don't share a common ancestor}
84
85test item-3.5 {item delete: item range with common ancestor} -body {
86    .t item lastchild 8 10
87    .t item lastchild 8 11
88    .t item delete 10 11
89} -result {}
90
91test item-3.6 {item delete: don't delete "root" itemDesc} -body {
92    .t item delete root
93    .t item id root
94} -result {0}
95
96test item-3.7 {item delete: deleting root should be ignored} -body {
97    .t item delete [.t item id root]
98    update idletasks
99} -result {}
100
101test item-4.1 {item ancestors: no ancestor yet} -body {
102    .t item create
103    .t item ancestors 12
104} -result {}
105
106test item-4.2 {item ancestors} -body {
107    .t item lastchild 7 12
108    .t item ancestors 12
109} -result {7 5 0}
110
111test item-5.1 {item children: no children} -body {
112    .t item children 12
113} -result {}
114
115test item-5.2 {item children} -body {
116    .t item children 0
117} -result {1 5 8}
118
119test item-6.1 {item firstchild: missing itemDesc} -body {
120    .t item firstchild
121} -returnCodes error -result {wrong # args: should be ".t item firstchild item ?newFirstChild?"}
122
123test item-6.2 {item firstchild: no children} -body {
124    .t item firstchild 12
125} -result {}
126
127test item-6.3 {item firstchild} -body {
128    .t item firstchild 1
129} -result {2}
130
131test item-7.1 {item lastchild: no children} -body {
132    .t item lastchild 1
133} -result {3}
134
135test item-8.1 {item nextsibling: no sibling} -body {
136    .t item nextsibling 12
137} -result {}
138
139test item-8.2 {item nextsibling: no sibling} -body {
140    .t item nextsibling 2
141} -result {3}
142
143test item-9.1 {item numchildren: no children} -body {
144    .t item numchildren 12
145} -result {0}
146
147test item-9.2 {item numchildren} -body {
148    .t item numchildren 1
149} -result {2}
150
151test item-10.1 {item parent: no parent} -body {
152    .t item parent root
153} -result {}
154
155test item-10.2 {item parent} -body {
156    .t item parent "root firstchild"
157} -result {0}
158
159test item-11.1 {item prevsibling: missing arg} -body {
160    .t item prevsibling
161} -returnCodes error -result {wrong # args: should be ".t item prevsibling item ?newPrevSibling?"}
162
163test item-11.2 {item prevsibling: no prevsibling} -body {
164    .t item prevsibling 1
165} -result {}
166
167test item-11.3 {item prevsibling} -body {
168    .t item prevsibling 3
169} -result {2}
170
171test item-12.1 {item remove: invalid item} -body {
172    .t item remove 999
173} -returnCodes error -result {item "999" doesn't exist}
174
175test item-12.2 {item remove} -body {
176    .t item remove 12
177} -result {}
178
179test item-13.1 {item complex: missing args} -constraints {
180    deprecated
181} -body {
182    .t item complex 8
183} -returnCodes error -result {wrong # args: should be ".t item complex item list ..."}
184
185test item-13.2 {item complex: only allowed if column style is defined} -constraints {
186    deprecated
187} -body {
188    .t item complex 8 {{e1 -text Hallo}}
189} -returnCodes error -result {column #0 doesn't exist}
190
191test item-13.3 {item complex: invalid list} -constraints {
192    deprecated
193} -body {
194    .t column create -tag column0
195    .t item style set 8 0 testStyle
196    .t item complex 8 {{e1 -text}}
197} -returnCodes error -result {wrong # args: should be "element option value ..."}
198
199test item-13.4 {item complex: element name not defined in style} -constraints {
200    deprecated
201} -body {
202    .t item complex 8 {{e1 -text Hallo}}
203} -returnCodes error -result {element "e1" doesn't exist}
204
205test item-13.5 {item complex: option not known in element} -constraints {
206    deprecated
207} -body {
208    .t item complex 8 {{eText -bitmap questhead}}
209} -returnCodes error -result {unknown option "-bitmap"}
210
211test item-13.6 {item complex: invalid option value in element} -constraints {
212    deprecated
213} -body {
214    .t item complex 8 {{eText -fill foo}}
215} -cleanup {
216    .t column delete column0
217} -returnCodes error -result {unknown color name "foo"}
218
219test item-14.1 {item element: missing command} -setup {
220    # in case the deprecated complex command is not run...
221    .t column create -tag column0
222    .t item style set 8 0 testStyle
223    .t item text 8 0 ""
224} -body {
225    .t item element
226} -returnCodes error -result {wrong # args: should be ".t item element command item column element ?arg ...?"}
227
228test item-14.2 {item element: invalid command} -body {
229    .t item element foo 8 column0 eText
230} -returnCodes error -result {bad command "foo": must be *} -match glob
231
232test item-14.3 {item element perstate: missing arg} -body {
233    .t item element perstate 8 column0 eText
234} -returnCodes error -result {wrong # args: should be ".t item element perstate item column element option ?stateList?"}
235
236test item-14.4 {item element perstate: without stateList} -body {
237    .t element configure eText -fill {red !selected blue {}}
238    .t item element perstate 8 column0 eText -fill
239} -result {red}
240
241test item-14.5 {item element perstate: without stateList} -body {
242    .t item element perstate 8 column0 eText -fill
243} -result {red}
244
245test item-14.6 {item element perstate: with stateList} -body {
246    .t item element perstate 8 column0 eText -fill {selected}
247} -result {blue}
248
249test item-14.7 {item element perstate: all items} -body {
250    .t item element perstate all column0 eText -fill {selected}
251} -returnCodes error -result {can't specify > 1 item for this command}
252
253test item-14.8 {item element perstate: several items} -body {
254    .t item element perstate {list {8 root}} column0 eText -fill {selected}
255} -returnCodes error -result {can't specify > 1 item for this command}
256
257test item-14.21 {item element cget: missing arg} -body {
258    .t item element cget 8 column0 eText
259} -returnCodes error -result {wrong # args: should be ".t item element cget item column element option"}
260
261test item-14.22 {item element cget: too many args} -body {
262    .t item element cget 8 a b c d
263} -returnCodes error -result {wrong # args: should be ".t item element cget item column element option"}
264
265test item-14.23 {item element cget: single item, get -fill} -body {
266    .t item element cget 8 column0 eText -fill
267} -result {}
268
269test item-14.24 {item element cget: all items, get -fill} -body {
270    .t item element cget all column0 eText -fill
271} -returnCodes error -result {can't specify > 1 item for this command}
272
273test item-14.25 {item element cget: multiple items, get -fill} -body {
274    .t item element cget {list {8 1 3}} column0 eText -fill
275} -returnCodes error -result {can't specify > 1 item for this command}
276
277test item-14.31 {item element configure: get all config info} -body {
278    .t item element configure 8 column0 eText
279} -result {{-data {} {} {} {}} {-datatype {} {} {} {}} *} -match glob
280
281test item-14.32 {item element configure: single item, set -fill} -body {
282    .t item element configure 8 column0 eText -fill yellow
283    .t item element cget 8 0 eText -fill
284} -result {yellow}
285
286test item-14.33 {item element configure: single item, get -fill} -body {
287    .t item element configure 8 column0 eText -fill
288} -result {-fill {} {} {} yellow}
289
290test item-14.34 {item element configure: all items, get -fill} -body {
291    .t item element configure all column0 eText -fill
292} -returnCodes error -result {can't specify > 1 item for this command}
293
294test item-14.35 {item element configure: several items, get -fill} -body {
295    .t item element configure {list {8 3}} column0 eText -fill
296} -returnCodes error -result {can't specify > 1 item for this command}
297
298test item-14.36 {item element configure: all items, set -fill} -body {
299    .t item style set all column0 testStyle
300    .t item element configure all column0 eText -fill orange
301    set res {}
302    foreach I [.t item id {range first last}] {
303	lappend res [.t item element cget $I column0 eText -fill]
304    }
305    set res
306} -result {orange orange orange orange orange orange orange orange orange}
307
308test item-14.37 {item element configure: single item, multiple elements} -body {
309    .t item element configure root column0 eText -fill blue +
310} -returnCodes error -result {missing element name after "+"}
311
312test item-14.38 {item element configure: single item, multiple elements} -body {
313    .t item element configure root column0 eText -fill blue + eBorder
314} -returnCodes error -result {missing option-value pair after element "eBorder"}
315
316test item-14.39 {item element configure: single item, multiple elements} -body {
317    .t item element configure root column0 eText -fill blue + eBorder -draw
318} -returnCodes error -result {missing option-value pair after element "eBorder"}
319
320test item-14.40 {item element configure: single item, multiple elements} -body {
321    .t item element configure root column0 eText -fill blue + eBorder -draw false
322    list [.t item element cget root column0 eText -fill] \
323	[.t item element cget root column0 eBorder -draw]
324} -result {blue false}
325
326test item-14.41 {item element configure: single item, multiple columns} -body {
327    .t item element configure root column0 eText -fill blue ,
328} -returnCodes error -result {missing column after ","}
329
330test item-14.42 {item element configure: single item, multiple columns} -body {
331    .t column create -tag column1
332    .t item style set all column1 testStyle
333    .t item element configure root column0 eText -fill blue , column1
334} -returnCodes error -result {missing element name after column "column1"}
335
336test item-14.43 {item element configure: single item, multiple columns} -body {
337    .t item element configure root column0 eText -fill blue , column1 eBorder
338} -returnCodes error -result {missing option-value pair after element "eBorder"}
339
340test item-14.44 {item element configure: single item, multiple columns} -body {
341    .t item element configure root column0 eText -fill blue , column1 eBorder -draw
342} -returnCodes error -result {missing option-value pair after element "eBorder"}
343
344test item-14.45 {item element configure: single item, multiple columns} -body {
345    .t item element configure root column0 eText -fill green , column1 eBorder -draw true
346    list [.t item element cget root column0 eText -fill] \
347	[.t item element cget root column1 eBorder -draw]
348} -result {green true}
349
350test item-14.46 {item element configure: multiple items, multiple columns/elements} -body {
351    .t item element configure {list {1 3}} column0 eText -fill green -text boo + \
352	eBorder -background red , column1 eBorder -draw true + eText -font {{times 12}}
353    set res {}
354    foreach I {1 3} {
355	lappend res [.t item element cget $I column0 eText -fill]
356	lappend res [.t item element cget $I column0 eText -text]
357	lappend res [.t item element cget $I column0 eBorder -background]
358	lappend res [.t item element cget $I column1 eBorder -draw]
359	lappend res [.t item element cget $I column1 eText -font]
360    }
361    set res
362} -result {green boo red true {{times 12}} green boo red true {{times 12}}}
363
364test item-14.50 {item element configure: cleanup} -body {
365    .t item style set all 0 ""
366    .t column delete all
367    .t column create
368    .t item style set 8 0 testStyle
369    .t item element configure 8 0 eText -fill yellow
370} -result {}
371
372test item-14.60 {item element cget: tail not allowed} -body {
373    .t item element cget root tail eText -fill
374} -returnCodes error -result {can't specify "tail" for this command}
375
376test item-14.61 {item element configure: tail not allowed} -body {
377    .t item element configure root tail eText -fill
378} -returnCodes error -result {can't specify "tail" for this command}
379
380test item-14.62 {item element perstate: tail not allowed} -body {
381    .t item element perstate root tail eText -fill
382} -returnCodes error -result {can't specify "tail" for this command}
383
384
385test item-15.1 {item style: missing args} -body {
386    .t item style
387} -returnCodes error -result {wrong # args: should be ".t item style command item ?arg ...?"}
388
389test item-15.2 {item style: invalid command} -body {
390    .t item style foo bar
391} -returnCodes error -result {bad command "foo": must be *} -match glob
392
393test item-15.3 {item style: invalid command} -body {
394    .t item style foo bar
395} -returnCodes error -result {bad command "foo": must be *} -match glob
396
397test item-15.4 {item style elements: missing args} -body {
398    .t item style elements 8
399} -returnCodes error -result {wrong # args: should be ".t item style elements item column"}
400
401test item-15.5 {item style elements: invalid item} -body {
402    .t item style elements 999
403} -returnCodes error -result {item "999" doesn't exist}
404
405test item-15.6 {item style elements: item without style} -body {
406    .t item style elements 1 0
407} -returnCodes error -result {item 1 column 0 has no style}
408
409test item-15.7 {item style elements} -body {
410    .t item style elements 8 0
411} -result {eText}
412
413test item-15.8 {item style map: missing args} -body {
414    .t item style map 8
415} -returnCodes error -result {wrong # args: should be ".t item style map item column style map"}
416
417test item-15.9 {item style map: invalid item} -body {
418    .t item style map 999
419} -returnCodes error -result {item "999" doesn't exist}
420
421test item-15.10 {item style map: item with unknown style} -body {
422    .t item style map 1 0 noStyle {foo bar}
423} -returnCodes error -result {style "noStyle" doesn't exist}
424
425test item-15.11 {item style map: odd elemented list} -body {
426    .t item style map 8 0 testStyle foo
427    .t item style elements 8 0
428} -returnCodes error -result {list must contain even number of elements}
429
430test item-15.12 {item style map: unknown element} -body {
431    .t style create testStyle2
432    .t item style map 8 0 testStyle2 {eText foo}
433    .t item style elements 8 0
434} -returnCodes error -result {element "foo" doesn't exist}
435
436test item-15.13 {item style map: element not in to-style} -body {
437    .t item style map 8 0 testStyle2 {eText eRect}
438} -returnCodes error -result {style testStyle2 does not use element eRect}
439
440test item-15.14 {item style map: element not in from-style} -body {
441    # .t style elements testStyle2 {eImage eRect}
442    .t item style map 8 0 testStyle2 {eRect eBorder}
443} -returnCodes error -result {style testStyle does not use element eRect}
444
445test item-15.15 {item style map: different element types} -body {
446    .t style elements testStyle2 {eImage eRect}
447    .t item style map 8 0 testStyle2 {eBorder eRect}
448} -returnCodes error -result {can't map element type border to rect}
449
450test item-15.16 {item style set: invalid item} -body {
451    .t item style set foo bar
452} -returnCodes error -result {item "foo" doesn't exist}
453
454test item-15.17 {item style set: without args returns all styles} -body {
455    .t item style set 2
456} -result {{}}
457
458test item-15.18 {item style set: without args returns style} -body {
459    .t item style set 2 0
460} -result {}
461
462test item-15.19 {item style set: without args returns style} -body {
463    .t item style set 8 0
464} -result {testStyle}
465
466test item-15.20 {item style set: single item, single column} -body {
467    .t item style set 8 0 testStyle2
468    .t item style set 8
469} -result {testStyle2}
470
471test item-15.21 {item style set: all items, single column} -body {
472    .t item style set all 0 testStyle2
473    set res {}
474    foreach I [.t item id {range 1 8}] {
475	lappend res [.t item style set $I]
476    }
477    set res
478} -result {testStyle2 testStyle2 testStyle2 testStyle2 testStyle2 testStyle2 testStyle2 testStyle2}
479
480test item-15.22 {item style set: list of items, single column} -body {
481    .t item style set {list {2 4 6 8}} 0 ""
482    set res {}
483    foreach I [.t item id {range 1 8}] {
484	lappend res [.t item style set $I]
485    }
486    set res
487} -result {testStyle2 {{}} testStyle2 {{}} testStyle2 {{}} testStyle2 {{}}}
488
489test item-15.23 {item style set: all items, multiple columns} -body {
490    .t column create
491    .t item style set all 0 testStyle 1 testStyle2
492    set res {}
493    foreach I [.t item id {range 1 8}] {
494	lappend res [.t item style set $I]
495    }
496    set res
497} -result {{testStyle testStyle2} {testStyle testStyle2} {testStyle testStyle2} {testStyle testStyle2} {testStyle testStyle2} {testStyle testStyle2} {testStyle testStyle2} {testStyle testStyle2}}
498
499test item-15.24 {item style set: list of items, multiple columns} -body {
500    .t item style set {list {2 4 6 8}} 0 testStyle2 1 ""
501    set res {}
502    foreach I [.t item id {range 1 8}] {
503	lappend res [.t item style set $I]
504    }
505    set res
506} -result {{testStyle testStyle2} {testStyle2 {}} {testStyle testStyle2} {testStyle2 {}} {testStyle testStyle2} {testStyle2 {}} {testStyle testStyle2} {testStyle2 {}}}
507
508test item-15.25 {item style set: all items, multiple columns} -body {
509    .t item style set all 1 "" 0 ""
510    set res {}
511    foreach I [.t item id {range 1 8}] {
512	lappend res [.t item style set $I]
513    }
514    .t column delete all
515    .t column create
516    set res
517} -result {{{} {}} {{} {}} {{} {}} {{} {}} {{} {}} {{} {}} {{} {}} {{} {}}}
518
519
520test item-15.30 {item style elements: tail not allowed} -body {
521    .t item style elements root tail
522} -returnCodes error -result {can't specify "tail" for this command}
523
524test item-15.31 {item style map: tail not allowed} -body {
525    .t item style map root tail testStyle2 {}
526} -returnCodes error -result {can't specify "tail" for this command}
527
528test item-15.32 {item style set: tail not allowed} -body {
529    .t item style set root tail
530} -returnCodes error -result {can't specify "tail" for this command}
531
532test item-15.33 {item style set: tail not allowed} -body {
533    .t item style set root tail testStyle2
534} -returnCodes error -result {can't specify "tail" for this command}
535
536
537test item-16.1 {item state: missing args} -body {
538    .t item state
539} -returnCodes error -result {wrong # args: should be ".t item state command item ?arg ...?"}
540
541test item-16.2 {item state: unknown command} -body {
542    .t item state foo bar
543} -returnCodes error -result {bad command "foo": must be *} -match glob
544
545test item-16.3 {item state get: unknown item} -body {
546    .t item state get 999
547} -returnCodes error -result {item "999" doesn't exist}
548
549test item-16.4 {item state get: too much arg} -body {
550    .t item state get 8 open enabled
551} -returnCodes error -result {wrong # args: should be ".t item state get item ?state?"}
552
553test item-16.5 {item state get: invalid arg} -body {
554    .t item state get 8 !open
555} -returnCodes error -result {can't specify '!' for this command}
556
557test item-16.6 {item state get: invalid arg} -body {
558    .t item state get 8 ~open
559} -returnCodes error -result {can't specify '~' for this command}
560
561test item-16.6 {item state get: unknown state} -body {
562    .t item state get 8 foo
563} -returnCodes error -result {unknown state "foo"}
564
565test item-16.7 {item state: list all set states} -body {
566    .t item state get 8
567} -result {open enabled}
568
569test item-16.8 {item state get: state not set} -body {
570    .t item state get 8 active
571} -result {0}
572
573test item-16.9 {item state get: state set} -body {
574    .t item state get 8 open
575} -result {1}
576
577test item-16.10 {item state get: user defined state not set} -body {
578    .t item state get 8 state0
579} -result {0}
580
581test item-16.11 {item state set: missing arg} -body {
582    .t item state set 8
583} -returnCodes error -result {wrong # args: should be ".t item state set item ?last? stateList"}
584
585test item-16.12 {item state: try to reset predefined state} -body {
586    .t item state set 8 open
587} -returnCodes error -result {can't specify state "open" for this command}
588
589test item-16.13 {item state: unknown states} -body {
590    .t item state set 8 {foo bar}
591} -returnCodes error -result {unknown state "foo"}
592
593test item-16.14 {item state: unknown state leaded by !} -body {
594    .t item state set 8 !foo
595} -returnCodes error -result {unknown state "foo"}
596
597test item-16.15 {item state: unknown state leaded by ~} -body {
598    .t item state set 8 ~bar
599} -returnCodes error -result {unknown state "bar"}
600
601test item-16.16 {item state: switch on states} -body {
602    .t item state set 8 state0
603    .t item state get 8
604} -result {open enabled state0}
605
606test item-16.17 {item state get: user defined state set} -body {
607    .t item state get 8 state0
608} -result {1}
609
610test item-16.18 {item state: toggle state} -body {
611    .t item state set 8 ~state0
612    .t item state get 8
613} -result {open enabled}
614
615test item-16.19 {item state: switch off states} -body {
616    .t item state set 8 !state0
617    .t item state get 8 state0
618} -result {0}
619
620test item-16.20 {item state: reset predefined state} -body {
621    .t item collapse 8
622    .t item state get 8
623} -result {enabled}
624
625test item-16.21 {item state: reset predefined state} -body {
626    .t item expand 8
627    .t item state get 8
628} -result {open enabled}
629
630test item-16.22 {item state: reset predefined state} -body {
631    .t item toggle 8
632    .t item state get 8 enabled
633} -result {1}
634
635test item-16.23 {item state: set range} -body {
636    .t item state set 1 8 state0
637    set res {}
638    foreach I [.t item id {range 1 8}] {
639	lappend res [.t item state get $I state0]
640    }
641    set res
642} -result {1 1 1 1 1 1 1 1}
643
644test item-16.24 {item state: set list} -body {
645    .t item state set {list {2 4 6 8}} !state0
646    set res {}
647    foreach I [.t item id {range 1 8}] {
648	lappend res [.t item state get $I state0]
649    }
650    set res
651} -result {1 0 1 0 1 0 1 0}
652
653test item-16.25 {item state: set all} -body {
654    .t item state set all ~state0
655    set res {}
656    foreach I [.t item id {range 1 8}] {
657	lappend res [.t item state get $I state0]
658    }
659    set res
660} -result {0 1 0 1 0 1 0 1}
661
662test item-16.26 {item state set: invalid range} -body {
663    set I [.t item create]
664    .t item state set $I 8 state0
665} -returnCodes error -result {item 13 and item 8 don't share a common ancestor}
666
667test item-16.40 {item state forcolumn: missing arg} -body {
668    .t item state forcolumn
669} -returnCodes error -result {wrong # args: should be ".t item state forcolumn item column ?stateList?"}
670
671test item-16.41 {item state forcolumn: missing arg} -body {
672    .t item state forcolumn 8
673} -returnCodes error -result {wrong # args: should be ".t item state forcolumn item column ?stateList?"}
674
675test item-16.42 {item state forcolumn: too many args} -body {
676    .t item state forcolumn a b c d
677} -returnCodes error -result {wrong # args: should be ".t item state forcolumn item column ?stateList?"}
678
679test item-16.43 {item state forcolumn: get for single item} -body {
680    .t item state forcolumn 8 0
681} -result {}
682
683test item-16.44 {item state forcolumn: get for all} -body {
684    .t item state forcolumn all 0
685} -returnCodes error -result {can't specify > 1 item for this command}
686
687test item-16.45 {item state forcolumn: set for single item} -body {
688    .t item state forcolumn 8 0 state0
689    .t item state forcolumn 8 0
690} -result {state0}
691
692test item-16.46 {item state forcolumn: set all} -body {
693    .t item state forcolumn all 0 state0
694    set res {}
695    foreach I [.t item id {range 1 8}] {
696	lappend res [.t item state forcolumn $I 0]
697    }
698    set res
699} -result {state0 state0 state0 state0 state0 state0 state0 state0}
700
701test item-16.47 {item state forcolumn: set list} -body {
702    .t item state forcolumn {list {2 4 6 8}} 0 !state0
703    set res {}
704    foreach I [.t item id {range 1 8}] {
705	lappend res [.t item state forcolumn $I 0]
706    }
707    set res
708} -result {state0 {} state0 {} state0 {} state0 {}}
709
710test item-16.50 {item state forcolumn: tail not allowed} -body {
711    .t item state forcolumn root tail
712} -returnCodes error -result {can't specify "tail" for this command}
713
714test item-16.51 {item state forcolumn: tail not allowed} -body {
715    .t item state forcolumn root tail foo
716} -returnCodes error -result {can't specify "tail" for this command}
717
718test item-17.1 {item sort: missing args} -body {
719    .t item sort
720} -returnCodes error -result {wrong # args: should be ".t item sort item ?option ...?"}
721
722test item-17.2 {item sort: invalid item} -body {
723    .t item sort foo
724} -returnCodes error -result {item "foo" doesn't exist}
725
726test item-17.3 {item sort: is all allowed?} -body {
727    .t item sort all
728} -returnCodes error -result {can't specify > 1 item for this command}
729
730test item-17.4 {item sort: invalid option} -body {
731    .t item sort root -foo
732} -returnCodes error -result {bad option "-foo": must be *} -match glob
733
734test item-17.5 {item sort: missing arg to an option} -body {
735    .t item sort root -first
736} -returnCodes error -result {missing value for "-first" option}
737
738test item-17.6 {item sort: invalid column} -body {
739    .t item sort root -column 3
740} -returnCodes error -result {column "3" doesn't exist}
741
742test item-17.7 {item sort: invalid column, second try} -body {
743    .t item sort root -column tail
744} -returnCodes error -result {can't specify "tail" for this command}
745
746test item-17.8 {item sort: sort needs style to find text} -body {
747    .t item sort root
748} -returnCodes error -result {item 1 column 0 has no style}
749
750proc listItems {t {i root}} {
751    set res {}
752    foreach c [$t item children $i] {
753	lappend res $c
754	eval lappend res [listItems $t $c]
755    }
756    return $res
757}
758
759test item-17.9 {item sort: set the texts in column 0 for all items} -body {
760    .t column create
761    .t style create   textStyle
762    .t style elements textStyle {eRect eBorder eText}
763    .t element create eTime text
764    .t style create   timeStyle
765    .t style elements timeStyle eTime
766    foreach i [listItems .t] {
767	.t item style set $i 0 textStyle
768	.t item style set $i 1 timeStyle
769	.t item text $i 0 [expr {$i+5}]
770    }
771    .t item text 8 0
772} -result {13}
773
774test item-17.10 {item sort: sort all by ascii} -body {
775    .t item sort root
776    listItems .t
777} -result {5 6 7 8 1 2 3 4}
778
779test item-17.11 {item sort: sort all decreasing by ascii} -body {
780    .t item sort root -decreasing
781    listItems .t
782} -result {1 2 3 4 8 5 6 7}
783
784test item-17.12 {item sort: sort all as integer} -body {
785    .t item sort root -integer
786    listItems .t
787} -result {1 2 3 4 5 6 7 8}
788
789test item-17.13 {item sort: for integers -dictionary works also} -body {
790    .t item sort root -dictionary
791    listItems .t
792} -result {1 2 3 4 5 6 7 8}
793
794test item-17.14 {item sort: sort all decreasing as integer} -body {
795    .t item sort root -integer -decreasing
796    listItems .t
797} -result {8 5 6 7 1 2 3 4}
798
799test item-17.15 {item sort: don't sort, only return sorted items} -body {
800    .t item lastchild root 5
801    list [.t item sort root -notreally] [listItems .t]
802} -result {{5 8 1} {8 1 2 3 4 5 6 7}}
803
804test item-17.16 {item sort: return integer sorted items} -body {
805    .t item sort root -notreally -integer
806} -result {1 5 8}
807
808test item-17.17 {item sort: return integer sorted items} -body {
809    .t item sort root -notreally -dictionary -decreasing
810} -result {8 5 1}
811
812test item-17.18 {item sort: two sort options, last wins (as in lsort)} -body {
813    .t item sort root -integer -ascii
814    listItems .t
815} -result {5 6 7 8 1 2 3 4}
816
817test item-17.19 {item sort: two order options, last wins (as in lsort)} -body {
818    .t item sort root -real -decreasing -increasing
819    listItems .t
820} -result {1 2 3 4 5 6 7 8}
821
822test item-17.20 {item sort: restrict to item of different parent} -body {
823    .t item sort root -first 2
824} -returnCodes error -result {item 2 is not a child of item 0}
825
826test item-17.21 {item sort: restrict to unknown item} -body {
827    .t item sort root -first foo
828} -returnCodes error -result {item "foo" doesn't exist}
829
830test item-17.22 {item sort: restricted sort} -body {
831    .t item sort root -first 5 -last 8 -decreasing
832    listItems .t
833} -result {1 2 3 4 8 5 6 7}
834
835test item-17.23 {item sort: restricted sort returned} -body {
836    .t item sort root -first 5 -last 8 -notreally
837} -result {5 8}
838
839test item-17.24 {item sort: order of restriction doesn't matter} -body {
840    .t item sort root -first 8 -last 5 -notreally
841} -result {5 8}
842
843test item-17.25 {item sort: very restricted sort returned} -body {
844    .t item sort root -first 5 -last 5 -notreally
845} -result {5}
846
847test item-17.26 {item sort -command: missing arg} -body {
848    .t item sort root -command
849} -returnCodes error -result {missing value for "-command" option}
850
851test item-17.27 {item sort -command: unknown command} -body {
852    .t item sort root -command foo
853} -returnCodes error -result {invalid command name "foo"}
854
855test item-17.28 {item sort -command: unknown command} -body {
856    .t item sort root -command #
857} -returnCodes error -result {invalid command name "#"}
858
859test item-17.29 {item sort -command: invalid return value} -body {
860    .t item sort root -command list
861} -returnCodes error -result {-command returned non-numeric result}
862
863proc myCompare {op item1 item2} {
864    switch -- $op {
865	1 - 0 - -1 {
866	    return $op
867	}
868	timespan-1 {
869	    regsub -all : [.t item text $item1 1] "" val1
870	    regsub -all : [.t item text $item2 1] "" val2
871	    return [expr {[string trimleft $val1 0]-[string trimleft $val2 0]}]
872	}
873	ascii {
874	    return [string compare [.t item text $item1 0] \
875				   [.t item text $item2 0]]
876	}
877	ascii-1 {
878	    return [string compare [.t item text $item1 1] \
879				   [.t item text $item2 1]]
880	}
881	default {
882	    return -code $op 0
883	}
884    }
885}
886
887test item-17.30 {item sort -command: too less arguments to proc call} -body {
888    .t item sort root -command myCompare
889} -returnCodes error -result {wrong # args: should be "myCompare op item1 item2"}
890
891test item-17.31 {item sort -command: always returning 0 is identity} -body {
892    set res [list [listItems .t]]
893    .t item sort root -command {myCompare 0}
894    lappend res [listItems .t]
895} -result {{1 2 3 4 8 5 6 7} {1 2 3 4 8 5 6 7}}
896
897test item-17.32 {item sort -command: returnCode break} -body {
898    list [catch {.t item sort root -command {myCompare break}} msg] $msg \
899	$errorInfo
900} -result {3 0 {0
901    (evaluating item sort -command)}}
902
903test item-17.33 {item sort -command: always returning 1 is identity?} -body {
904    set res [list [listItems .t]]
905    .t item sort root -command {myCompare 1}
906} -returnCodes error -result {buggy item sort -command detected}
907
908test item-17.34 {item sort -command: always returning -1 reverts?} -constraints {
909    knownBug
910} -body {
911    .t item sort root -command {myCompare -1}
912} -returnCodes error -result {buggy item sort -command detected}
913
914test item-17.35 {item sort -command: ascii} -body {
915    .t item sort root -command {myCompare ascii}
916    listItems .t
917} -result {5 6 7 8 1 2 3 4}
918
919test item-17.36 {item sort -command: reverse ascii} -body {
920    .t item sort root -command {myCompare ascii} -decreasing
921    listItems .t
922} -result {1 2 3 4 8 5 6 7}
923
924test item-17.37 {item sort: with timespans column} -body {
925    .t item text 1 1 "01:00"
926    .t item text 5 1 "10:00"
927    .t item text 8 1 "02:09:00"
928    .t item sort root -column 1
929    listItems .t
930} -result {1 2 3 4 8 5 6 7}
931
932test item-17.38 {item sort -command: ascii with timespans column} -body {
933    .t item sort root -command {myCompare ascii-1}
934    listItems .t
935} -result {1 2 3 4 8 5 6 7}
936
937test item-17.39 {item sort -command: timespan with timespans column} -body {
938    .t item sort root -command {myCompare timespan-1}
939    listItems .t
940} -result {1 2 3 4 5 6 7 8}
941
942test item-17.40 {item sort -command: reverse timespan with timespans} -body {
943    .t item sort root -command {myCompare timespan-1} -decreasing
944    listItems .t
945} -result {8 5 6 7 1 2 3 4}
946
947test item-17.41 {item sort -command: reverse timespan with timespans} -body {
948    .t item sort root -command {myCompare timespan-1} -decreasing -notreally
949} -result {8 5 1}
950
951test item-17.42 {item sort -element: missing arg} -body {
952    .t item sort root -element
953} -returnCodes error -result {missing value for "-element" option}
954
955test item-17.43 {item sort -element: invalid element} -body {
956    .t item sort root -element foo
957} -returnCodes error -result {element "foo" doesn't exist}
958
959test item-17.44 {item sort -element: no text element} -body {
960    .t item sort root -element eBorder
961} -returnCodes error -result {element eBorder is not of type "text"}
962
963test item-17.45 {item sort -element: element in wrong column} -body {
964    .t item sort root -column 1 -element eText -dictionary
965    listItems .t
966} -returnCodes error -result {style timeStyle does not use element eText}
967
968test item-17.46 {item sort -element: -colum defaults to 0} -body {
969    .t item sort root -element eTime
970    listItems .t
971} -returnCodes error -result {style textStyle does not use element eTime}
972
973test item-17.47 {item sort -element: element in columns} -body {
974    .t item sort root -column 1 -element eTime
975    listItems .t
976} -result {1 2 3 4 8 5 6 7} ;# same result as in 17.37
977
978test item-17.48 {item sort -element: useless for -command} -body {
979    .t item sort root -column 1 -element eTime -command {myCompare timespan-1}
980    listItems .t
981} -result {1 2 3 4 5 6 7 8} ;# same result as in 17.39
982
983test item-17.49 {item sort -command: no columns} -body {
984    while {![catch {.t column configure "order 0"}]} {
985	.t column delete "order 0"
986    }
987    .t item sort root
988} -returnCodes error -result {there are no columns}
989
990test item-18.1 {item enabled: too few args} -body {
991    .t item enabled
992} -returnCodes error -result {wrong # args: should be ".t item enabled item ?boolean?"}
993
994test item-18.2 {item enabled: too many args} -body {
995    .t item enabled a b c
996} -returnCodes error -result {wrong # args: should be ".t item enabled item ?boolean?"}
997
998test item-18.3 {item enabled: null item} -body {
999    .t item enabled 99
1000} -returnCodes error -result {item "99" doesn't exist}
1001
1002test item-18.4 {item enabled: single item get} -body {
1003    .t item enabled root
1004} -result {1}
1005
1006test item-18.5 {item enabled: single item set} -body {
1007    .t item enabled root false
1008    set res {}
1009    foreach I [.t item id {range first last}] {
1010	lappend res [.t item enabled $I]
1011    }
1012    set res
1013} -result {0 1 1 1 1 1 1 1 1}
1014
1015test item-18.6 {item enabled: all get} -body {
1016    .t item enabled all
1017} -returnCodes error -result {can't specify > 1 item for this command}
1018
1019test item-18.7 {item enabled: all set} -body {
1020    .t item enabled all false
1021    set res {}
1022    foreach I [.t item id {range first last}] {
1023	lappend res [.t item enabled $I]
1024    }
1025    set res
1026} -result {0 0 0 0 0 0 0 0 0}
1027
1028test item-18.8 {item enabled: multi get} -body {
1029    .t item enabled {list {2 4 7}}
1030} -returnCodes error -result {can't specify > 1 item for this command}
1031
1032test item-18.9 {item enabled: multi set} -body {
1033    .t item enabled {list {2 4 7}} true
1034    set res {}
1035    foreach I [.t item id {range first last}] {
1036	lappend res [.t item enabled $I]
1037    }
1038    set res
1039} -result {0 0 1 0 1 0 0 1 0}
1040
1041test item-19.1 {item text: too few args} -body {
1042    .t item text
1043} -returnCodes error -result {wrong # args: should be ".t item text item ?column? ?text? ?column text ...?"}
1044
1045test item-19.2 {item text: all items, get every column} -body {
1046    .t item text all
1047} -returnCodes error -result {can't specify > 1 item for this command}
1048
1049test item-19.3 {item text: all items, set first column} -body {
1050    .t column create
1051    .t item style set all first testStyle
1052    .t item text all first abc
1053    set res {}
1054    foreach I [.t item id {range first last}] {
1055	lappend res [.t item text $I first]
1056    }
1057    set res
1058} -result {abc abc abc abc abc abc abc abc abc}
1059
1060test item-19.4 {item text: all items, get first column} -body {
1061    .t item text all first
1062} -returnCodes error -result {can't specify > 1 item for this command}
1063
1064test item-19.5 {item text: several items, set first column} -body {
1065    .t item text {list {2 4 6 8}} first def
1066    set res {}
1067    foreach I [.t item id {range first last}] {
1068	lappend res [.t item text $I first]
1069    }
1070    set res
1071} -result {abc abc def abc def abc def abc def}
1072
1073test item-19.6 {item text: several items, get first column} -body {
1074    .t item text {list {2 4 6 8}} first
1075} -returnCodes error -result {can't specify > 1 item for this command}
1076
1077test item-19.10 {item text: tail not allowed} -body {
1078    .t item text root tail
1079} -returnCodes error -result {can't specify "tail" for this command}
1080
1081test item-19.11 {item text: tail not allowed} -body {
1082    .t item text root tail "hello"
1083} -returnCodes error -result {can't specify "tail" for this command}
1084
1085test item-20.1 {item tag: too few args} -body {
1086    .t item tag
1087} -returnCodes error -result {wrong # args: should be ".t item tag command ?arg arg ...?"}
1088
1089test item-20.2 {item tag add: too few args} -body {
1090    .t item tag add
1091} -returnCodes error -result {wrong # args: should be ".t item tag add item tagList"}
1092
1093test item-20.3 {item tag add: too many args} -body {
1094    .t item tag add a b c
1095} -returnCodes error -result {wrong # args: should be ".t item tag add item tagList"}
1096
1097test item-20.4 {item tag names: too few args} -body {
1098    .t item tag names
1099} -returnCodes error -result {wrong # args: should be ".t item tag names item"}
1100
1101test item-20.5 {item tag names: too many args} -body {
1102    .t item tag names a b
1103} -returnCodes error -result {wrong # args: should be ".t item tag names item"}
1104
1105test item-20.6 {item tag remove: too few args} -body {
1106    .t item tag remove
1107} -returnCodes error -result {wrong # args: should be ".t item tag remove item tagList"}
1108
1109test item-20.7 {item tag remove: too many args} -body {
1110    .t item tag remove a  b c
1111} -returnCodes error -result {wrong # args: should be ".t item tag remove item tagList"}
1112
1113test item-20.11 {item tag: add tags to all} -body {
1114    .t item delete all
1115    .t item create -count 9999 -parent root
1116    .t item tag add all {a b c}
1117    .t item tag expr all {c && a && b}
1118} -result {1}
1119
1120test item-20.12 {item tag: add duplicate tags} -body {
1121    .t item tag add all {c b a}
1122    lsort [.t item tag names all]
1123} -result {a b c}
1124
1125test item-20.13 {item tag: remove 1 tag from several items} -body {
1126    .t item tag remove {range 100 5000} b
1127    list [lsort [.t item tag names all]] [lsort [.t item tag names {range 100 5000}]]
1128} -result {{a b c} {a c}}
1129
1130test item-20.14 {item tag: remove 1 tag from all items} -body {
1131    .t item tag remove all b
1132    lsort [.t item tag names all]
1133} -result {a c}
1134
1135test item-20.15 {item tag: add tags to all (some dups)} -body {
1136    .t item tag add all {a e f b d h g}
1137    lsort [.t item tag names all]
1138} -result {a b c d e f g h}
1139
1140test item-20.16 {item tag: long expr} -body {
1141    llength [.t item id "tag {(a && e) && (f && b) && (d && h && g)}"]
1142} -result {10000}
1143
1144test item-20.17 {item tag: remove b from 100 items} -body {
1145    .t item tag remove {range 100 199} b
1146    llength [.t item id "tag !b"]
1147} -result {100}
1148
1149test item-20.18 {item tag: expr} -body {
1150    llength [.t item id "tag b"]
1151} -result {9900}
1152
1153test item-20.19 {item tag: remove e from 100 items, overlapping 50 of !b items} -body {
1154    .t item tag remove {range 150 249} e
1155    llength [.t item id "tag !e"]
1156} -result {100}
1157
1158test item-20.20 {item tag: expr} -body {
1159    llength [.t item id "tag {(!b || !e)}"]
1160} -result {150}
1161
1162test item-20.21 {item tag: expr} -body {
1163    llength [.t item id "tag b^e"]
1164} -result {100}
1165
1166test item-20.22 {item tag: expr} -body {
1167    .t item tag remove {tag !b||!e} {a c d f g h}
1168    llength [.t item id "tag !a"]
1169} -result {150}
1170
1171test item-20.23 {item tag: item create -tags} -body {
1172    .t item create -count 50 -tags {orphan50 x y z}
1173    llength [.t item id "tag x"]
1174} -result {50}
1175
1176test item-20.24 {item tag: item create -tags with dups} -body {
1177    .t item create -count 10 -tags {orphan10 x z x y z y}
1178    lsort [.t item tag names "tag orphan10"]
1179} -result {orphan10 x y z}
1180
1181test item-20.40 {item tag: [expr]} -body {
1182    .t item tag expr "tag orphan50" x
1183} -result {1}
1184
1185test item-20.41 {item tag: [expr]} -body {
1186    .t item tag expr "all tag orphan50" x&&y&&z
1187} -result {1}
1188
1189test item-20.42 {item tag: [expr]} -body {
1190    .t item tag expr "tag orphan50" a
1191} -result {0}
1192
1193test item-20.43 {item tag: [expr]} -body {
1194    .t item tag expr 100 e^b
1195} -cleanup {
1196    .t item delete all
1197} -result {1}
1198
1199test item-21.1 {item count: too many args} -body {
1200    .t item count a b
1201} -returnCodes error -result {wrong # args: should be ".t item count ?itemDesc?"}
1202
1203test item-21.2 {item count: no args, only root} -body {
1204    .t item count
1205} -result {1}
1206
1207test item-21.2 {item count: no args, many items} -setup {
1208    .t item create -count 50 -parent root
1209} -body {
1210    .t item count
1211} -result {51}
1212
1213test item-21.3 {item count: double-check with range} -body {
1214    expr {[.t item count] == [llength [.t item range first last]]}
1215} -result {1}
1216
1217test item-21.4 {item count: double-check with range} -body {
1218    expr {[.t item count] == [.t item count "range first last"]}
1219} -result {1}
1220
1221test item-21.5 {item count: all is same as no args} -body {
1222    expr {[.t item count] == [.t item count all]}
1223} -result {1}
1224
1225test item-21.6 {item count: depth test} -body {
1226    .t item count "depth 1"
1227} -result {50}
1228
1229test item-21.7 {item count: double-check with selection} -setup {
1230    .t selection add "range 10 20"
1231} -body {
1232     expr {[.t item count "state selected"] == [.t selection count]}
1233} -result {1}
1234
1235test item-22.1 {-button: default value} -setup {
1236    .t item delete all
1237    .t item create -tags foo
1238} -body {
1239    .t item cget foo -button
1240} -result {0}
1241
1242test item-22.2 {-button: default value} -body {
1243    .t item cget foo -button
1244} -result {0}
1245
1246test item-22.3 {-button: set true} -body {
1247    .t item conf foo -button true
1248    .t item cget foo -button
1249} -result {1}
1250
1251test item-22.4 {-button: set true} -body {
1252    .t item conf foo -button ON
1253    .t item cget foo -button
1254} -result {1}
1255
1256test item-22.5 {-button: set false} -body {
1257    .t item conf foo -button NO
1258    .t item cget foo -button
1259} -result {0}
1260
1261test item-22.6 {-button: set auto} -body {
1262    .t item conf foo -button auto
1263    .t item cget foo -button
1264} -result {auto}
1265
1266test item-22.7 {-button: set auto abbreviation} -body {
1267    .t item conf foo -button a
1268    .t item cget foo -button
1269} -result {auto}
1270
1271test item-23.1 {compare: missing args} -body {
1272    .t item compare
1273} -returnCodes error  -result {wrong # args: should be ".t item compare item1 op item2"}
1274
1275test item-23.2 {compare: unknown operator} -body {
1276    .t item compare root foo root
1277} -returnCodes error -result {bad comparison operator "foo": must be <, <=, ==, >=, >, or !=}
1278
1279test item-23.3 {compare: unknown item} -body {
1280    .t item compare root foo bar
1281} -returnCodes error -result {item "bar" doesn't exist}
1282
1283test item-23.4 {compare: same item} -body {
1284    set result {}
1285    foreach op {< <= == >= > !=} {
1286	lappend result [.t item compare root $op root]
1287    }
1288    set result
1289} -result {0 1 1 1 0 0}
1290
1291test item-23.5 {compare: different items} -setup {
1292    .t item delete all
1293    .t item create -tags item1 -parent root
1294    .t item create -tags item2 -parent root
1295} -body {
1296    set result {}
1297    foreach op {< <= == >= > !=} {
1298	lappend result [.t item compare item1 $op item2]
1299    }
1300    set result
1301} -result {1 1 0 0 0 1}
1302
1303test item-23.6 {compare: different items} -setup {
1304    .t item delete all
1305    .t item create -tags item1 -parent root
1306    .t item create -tags item2 -parent root
1307} -body {
1308    set result {}
1309    foreach op {< <= == >= > !=} {
1310	lappend result [.t item compare item2 $op item1]
1311    }
1312    set result
1313} -result {0 0 0 1 1 1}
1314
1315test item-23.7 {compare: uncommon ancestor, LT} -setup {
1316    .t item delete all
1317    .t item create -tags item1 ; # no parent
1318    .t item create -tags item2 ; # no parent
1319} -body {
1320    .t item compare item1 < item2
1321} -returnCodes error -result {item 1 and item 2 don't share a common ancestor}
1322
1323test item-23.8 {compare: uncommon ancestor, GT} -body {
1324    .t item compare item1 > item2
1325} -returnCodes error -result {item 1 and item 2 don't share a common ancestor}
1326
1327test item-23.9 {compare: uncommon ancestor, EQ or NE} -body {
1328    .t item compare item1 == item2
1329    .t item compare item1 != item2
1330} -result {1}
1331
1332test item-24.1 {buttonstate: missing args} -body {
1333    .t item buttonstate
1334} -returnCodes error -result {wrong # args: should be ".t item buttonstate item ?state?"}
1335
1336test item-24.2 {buttonstate: unknown item} -body {
1337    .t item buttonstate foo
1338} -returnCodes error -result {item "foo" doesn't exist}
1339
1340test item-24.3 {buttonstate: current state} -body {
1341    .t item buttonstate root
1342} -result {normal}
1343
1344test item-24.4 {buttonstate: unknown state} -body {
1345    .t item buttonstate root foo
1346} -returnCodes error -result {bad state "foo": must be active, normal, or pressed}
1347
1348test item-24.5 {buttonstate: set state} -body {
1349    .t item buttonstate root active
1350} -result {active}
1351
1352test item-25.1 {span: too few args} -setup {
1353    .t item delete all
1354    .t item create -parent root -tags item0
1355    .t column delete all
1356    .t column create -tags column0
1357    .t column create -tags column1
1358    .t column create -tags column2
1359    .t column create -tags column3
1360} -body {
1361    .t item span
1362} -returnCodes error -result {wrong # args: should be ".t item span item ?column? ?span? ?column span ...?"}
1363
1364test item-25.2 {span: unknown item} -body {
1365    .t item span foo
1366} -returnCodes error -result {item "foo" doesn't exist}
1367
1368test item-25.3 {span: multiple items no column not allowed} -body {
1369    .t item span all
1370} -returnCodes error -result {can't specify > 1 item for this command}
1371
1372test item-25.4 {span: single item, no column} -body {
1373    .t item span root
1374} -result {1 1 1 1}
1375
1376test item-25.5 {span: multiple items single column not allowed} -body {
1377    .t item span all column0
1378} -returnCodes error -result {can't specify > 1 item for this command}
1379
1380test item-25.6 {span: single item missing span} -body {
1381    .t item span root column0 1 column1
1382}  -returnCodes error -result {missing argument after column "column1"}
1383
1384test item-25.7 {span: multiple items missing span} -body {
1385    .t item span all column0 1 column1
1386}  -returnCodes error -result {missing argument after column "column1"}
1387
1388test item-25.8 {span: single item single column} -body {
1389    .t item span root column0
1390} -result {1}
1391
1392test item-25.9 {span: single item multiple columns} -body {
1393    .t item span root all 3
1394    .t item span root
1395} -result {3 3 3 3}
1396
1397test item-25.10 {span: multiple items multiple columns} -body {
1398    .t item span all all 2
1399    list [.t item span root] [.t item span item0]
1400} -result {{2 2 2 2} {2 2 2 2}}
1401
1402test item-99.1 {some needed cleanup} -body {
1403    destroy .t
1404} -result {}
1405
1406# cleanup
1407::tcltest::cleanupTests
1408return
1409