summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--tests/geometry.test170
-rw-r--r--tests/imgBmap.test460
-rw-r--r--tests/imgPPM.test210
-rw-r--r--tests/imgPhoto.test1412
-rw-r--r--tests/listbox.test2911
6 files changed, 3309 insertions, 1859 deletions
diff --git a/ChangeLog b/ChangeLog
index 03fe237..fdaf478 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,8 +2,13 @@
* tests/focus.test: Update to tcltest2
* tests/focusTcl.test:
+ * tests/geometry.test:
* tests/grab.test:
* tests/grid.test:
+ * tests/imgBmap.test:
+ * tests/imgPhoto.test:
+ * tests/imgPPM.test:
+ * tests/listbox.test:
* tests/safe.test:
* tests/tk.test:
* tests/util.test:
diff --git a/tests/geometry.test b/tests/geometry.test
index d005891..56aa3ad 100644
--- a/tests/geometry.test
+++ b/tests/geometry.test
@@ -7,11 +7,18 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: geometry.test,v 1.6 2004/05/23 17:34:48 dkf Exp $
+# RCS: @(#) $Id: geometry.test,v 1.7 2008/08/17 19:40:33 aniap Exp $
-package require tcltest 2.1
+proc getsize w {
+ regexp {(^[^+-]*)} [wm geometry $w] foo x
+ return $x
+}
+
+package require tcltest 2.2
eval tcltest::configure $argv
tcltest::loadTestedCommands
+namespace import -force tcltest::test
+
wm geometry . 300x300
raise .
@@ -25,15 +32,20 @@ button .b2 -text .b2
button .b3 -text .b3
button .f.f.b4 -text .b4
-test geometry-1.1 {Tk_ManageGeometry procedure} {
+test geometry-1.1 {Tk_ManageGeometry procedure} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
+ }
+} -body {
place .b1 -x 120 -y 80
update
list [winfo x .b1] [winfo y .b1]
-} {120 80}
-test geometry-1.2 {Tk_ManageGeometry procedure} {
- foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
- place forget $w
+} -result {120 80}
+test geometry-1.2 {Tk_ManageGeometry procedure} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
}
+} -body {
place .f -x 20 -y 30 -width 200 -height 200
place .b1 -in .f -x 40 -y 30
update
@@ -41,28 +53,37 @@ test geometry-1.2 {Tk_ManageGeometry procedure} {
place .f -x 30 -y 40
update
list [winfo x .b1] [winfo y .b1]
-} {0 0}
+} -result {0 0}
-test geometry-2.1 {Tk_GeometryRequest procedure} {
+
+test geometry-2.1 {Tk_GeometryRequest procedure} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
+ }
+ destroy .f2
+} -body {
frame .f2
set result [list [winfo reqwidth .f2] [winfo reqheight .f2]]
.f2 configure -width 150 -height 300
update
lappend result [winfo reqwidth .f2] [winfo reqheight .f2] \
- [winfo geom .f2]
+ [winfo geom .f2]
place .f2 -x 10 -y 20
update
lappend result [winfo geom .f2]
.f2 configure -width 100 -height 80
update
lappend result [winfo geom .f2]
-} {1 1 150 300 1x1+0+0 150x300+10+20 100x80+10+20}
-catch {destroy .f2}
+} -cleanup {
+ destroy .f2
+} -result {1 1 150 300 1x1+0+0 150x300+10+20 100x80+10+20}
+
-test geometry-3.1 {Tk_SetInternalBorder procedure} {
- foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
- place forget $w
+test geometry-3.1 {Tk_SetInternalBorder procedure} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
}
+} -body {
place .f -x 20 -y 30 -width 200 -height 200
place .b1 -in .f -x 50 -y 5
update
@@ -70,24 +91,28 @@ test geometry-3.1 {Tk_SetInternalBorder procedure} {
.f configure -bd 5
update
lappend x [winfo x .b1] [winfo y .b1]
-} {72 37 75 40}
-.f configure -bd 2
+} -cleanup {
+ .f configure -bd 2
+} -result {72 37 75 40}
-test geometry-4.1 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
- foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
- place forget $w
+
+test geometry-4.1 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
}
+} -body {
place .f -x 20 -y 30 -width 200 -height 200
place .f.f -x 15 -y 5 -width 150 -height 120
place .f.f.f -width 100 -height 80
place .b1 -in .f.f.f -x 50 -y 5
update
list [winfo x .b1] [winfo y .b1]
-} {91 46}
-test geometry-4.2 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
- foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
- place forget $w
+} -result {91 46}
+test geometry-4.2 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
}
+} -body {
place .f -x 20 -y 30 -width 200 -height 200
place .f.f -x 15 -y 5 -width 150 -height 120
place .f.f.f -width 100 -height 80
@@ -98,12 +123,13 @@ test geometry-4.2 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
place .f -x 30 -y 25
update
list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
- [winfo x .b3] [winfo y .b3]
-} {101 41 61 61 101 61}
-test geometry-4.3 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
- foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
- place forget $w
+ [winfo x .b3] [winfo y .b3]
+} -result {101 41 61 61 101 61}
+test geometry-4.3 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
}
+} -body {
place .f -x 20 -y 30 -width 200 -height 200
place .f.f -x 15 -y 5 -width 150 -height 120
place .f.f.f -width 100 -height 80
@@ -116,12 +142,13 @@ test geometry-4.3 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
place .f.f -x 10 -y 25
update
list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
- [winfo x .b3] [winfo y .b3]
-} {0 0 46 86 86 86}
-test geometry-4.4 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
- foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
- place forget $w
+ [winfo x .b3] [winfo y .b3]
+} -result {0 0 46 86 86 86}
+test geometry-4.4 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
}
+} -body {
place .f -x 20 -y 30 -width 200 -height 200
place .f.f -x 15 -y 5 -width 150 -height 120
place .f.f.f -width 100 -height 80
@@ -134,12 +161,13 @@ test geometry-4.4 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
place .f.f.f -x 2 -y 3
update
list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
- [winfo x .b3] [winfo y .b3]
-} {93 49 0 0 93 69}
-test geometry-4.5 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
- foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
- place forget $w
+ [winfo x .b3] [winfo y .b3]
+} -result {93 49 0 0 93 69}
+test geometry-4.5 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
}
+} -body {
place .f -x 20 -y 30 -width 200 -height 200
place .f.f -x 15 -y 5 -width 150 -height 120
place .f.f.f -width 100 -height 80
@@ -152,11 +180,15 @@ test geometry-4.5 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
place .f.f.f -x 2 -y 3
update
list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
- [winfo x .b3] [winfo y .b3]
-} {93 49 53 69 0 0}
-test geometry-4.6 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
+ [winfo x .b3] [winfo y .b3]
+} -result {93 49 53 69 0 0}
+test geometry-4.6 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
+ }
+} -body {
foreach w {.f .f.f .f.f.f .b1 .b2 .b3 .f.f.b4} {
- place forget $w
+ place forget $w
}
place .f -x 20 -y 30 -width 200 -height 200
place .f.f -x 15 -y 5 -width 150 -height 120
@@ -167,11 +199,12 @@ test geometry-4.6 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
place .f -x 25 -y 35
update
list [winfo x .f.f.b4] [winfo y .f.f.b4] [winfo x .b2] [winfo y .b2]
-} {54 9 56 71}
-test geometry-4.7 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
- foreach w {.f .f.f .f.f.f .b1 .b2 .b3 .f.f.b4} {
- place forget $w
+} -result {54 9 56 71}
+test geometry-4.7 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
}
+} -body {
bind .b1 <Configure> {lappend x configure}
place .f -x 20 -y 30 -width 200 -height 200
place .f.f -x 15 -y 5 -width 150 -height 120
@@ -186,13 +219,15 @@ test geometry-4.7 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
place .f -x 30 -y 40
place .f.f -x 10 -y 0
update
+ return $x
+} -cleanup {
bind .b1 <Configure> {}
- set x
-} {init configure |}
-test geometry-4.8 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
- foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
- place forget $w
+} -result {init configure |}
+test geometry-4.8 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
}
+} -body {
place .f -x 20 -y 30 -width 200 -height 200
place .f.f -x 15 -y 5 -width 150 -height 120
place .f.f.f -width 100 -height 80
@@ -206,13 +241,14 @@ test geometry-4.8 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
place .f -x 30 -y 25
update
list [winfo x .b1] [winfo y .b1] [winfo ismapped .b1] \
- [winfo x .b2] [winfo y .b2] [winfo ismapped .b2] \
- [winfo x .b3] [winfo y .b3] [winfo ismapped .b3]
-} {91 46 0 51 66 0 91 66 0}
-test geometry-4.9 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
- foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
- place forget $w
+ [winfo x .b2] [winfo y .b2] [winfo ismapped .b2] \
+ [winfo x .b3] [winfo y .b3] [winfo ismapped .b3]
+} -result {91 46 0 51 66 0 91 66 0}
+test geometry-4.9 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
}
+} -body {
place .f -x 20 -y 30 -width 200 -height 200
place .f.f -x 15 -y 5 -width 150 -height 120
place .f.f.f -width 100 -height 80
@@ -225,14 +261,18 @@ test geometry-4.9 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
place .f.f -x 15 -y 5 -width 150 -height 120
update
lappend result [winfo ismapped .b1]
-} {1 0 1}
-test geometry-4.10 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
+} -result {1 0 1}
+test geometry-4.10 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
+ foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
+ place forget $w
+ }
+ destroy .t
+} -body {
toplevel .t
wm geometry .t +0+0
tkwait visibility .t
update
- frame .t.f
- pack .t.f
+ pack [frame .t.f]
button .t.quit -text Quit -command exit
pack .t.quit -in .t.f
wm iconify .t
@@ -242,10 +282,12 @@ test geometry-4.10 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} {
wm deiconify .t
update
winfo ismapped .t.quit
-} {1}
+} -cleanup {
+ destroy .t
+} -result {1}
-catch {destroy .t}
# cleanup
cleanupTests
return
+
diff --git a/tests/imgBmap.test b/tests/imgBmap.test
index ffb8e29..87dc4ae 100644
--- a/tests/imgBmap.test
+++ b/tests/imgBmap.test
@@ -7,9 +7,10 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: imgBmap.test,v 1.7 2008/07/23 23:24:25 nijtmans Exp $
+# RCS: @(#) $Id: imgBmap.test,v 1.8 2008/08/17 19:40:33 aniap Exp $
-package require tcltest 2.1
+package require tcltest 2.2
+namespace import ::tcltest::*
eval tcltest::configure $argv
tcltest::loadTestedCommands
@@ -34,122 +35,153 @@ makeFile $data1 foo.bm
makeFile $data2 foo2.bm
eval image delete [image names]
-canvas .c
-pack .c
-update
-image create bitmap i1
-.c create image 200 100 -image i1
+#canvas .c
+#pack .c
+#update
+#image create bitmap i1
+#.c create image 200 100 -image i1
update
proc bgerror msg {
global errMsg
set errMsg $msg
}
-test imageBmap-1.1 {options for bitmap images} {
+
+test imageBmap-1.1 {options for bitmap images} -body {
image create bitmap i1 -background #123456
lindex [i1 configure -background] 4
-} {#123456}
-test imageBmap-1.2 {options for bitmap images} {
+} -cleanup {
+ image delete i1
+} -result {#123456}
+test imageBmap-1.2 {options for bitmap images} -setup {
+ destroy .c
+ pack [canvas .c]
+ update
+} -body {
set errMsg {}
image create bitmap i1 -background lousy
+ .c create image 200 100 -image i1
update
list $errMsg $errorInfo
-} {{unknown color name "lousy"} {unknown color name "lousy"
+} -cleanup {
+ image delete i1
+ destroy .c
+} -result {{unknown color name "lousy"} {unknown color name "lousy"
(while configuring image "i1")}}
-test imageBmap-1.3 {options for bitmap images} {
+test imageBmap-1.3 {options for bitmap images} -body {
image create bitmap i1 -data $data1
lindex [i1 configure -data] 4
-} $data1
-test imageBmap-1.4 {options for bitmap images} {
- list [catch {image create bitmap i1 -data bogus} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-1.5 {options for bitmap images} {
+} -result $data1
+test imageBmap-1.4 {options for bitmap images} -body {
+ image create bitmap i1 -data bogus
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-1.5 {options for bitmap images} -body {
image create bitmap i1 -file foo.bm
lindex [i1 configure -file] 4
-} foo.bm
-test imageBmap-1.6 {options for bitmap images} {
+} -result foo.bm
+test imageBmap-1.6 {options for bitmap images} -body {
list [catch {image create bitmap i1 -file bogus} msg] [string tolower $msg]
-} {1 {couldn't read bitmap file "bogus": no such file or directory}}
-test imageBmap-1.7 {options for bitmap images} {
+} -result {1 {couldn't read bitmap file "bogus": no such file or directory}}
+test imageBmap-1.7 {options for bitmap images} -body {
image create bitmap i1 -foreground #00ff00
lindex [i1 configure -foreground] 4
-} {#00ff00}
-test imageBmap-1.8 {options for bitmap images} {
+} -cleanup {
+ image delete i1
+} -result {#00ff00}
+test imageBmap-1.8 {options for bitmap images} -setup {
+ destroy .c
+ pack [canvas .c]
+ update
+} -body {
set errMsg {}
image create bitmap i1 -foreground bad_color
+ .c create image 200 100 -image i1
update
list $errMsg $errorInfo
-} {{unknown color name "bad_color"} {unknown color name "bad_color"
+} -cleanup {
+ destroy .c
+ image delete i1
+} -result {{unknown color name "bad_color"} {unknown color name "bad_color"
(while configuring image "i1")}}
-test imageBmap-1.9 {options for bitmap images} {
+test imageBmap-1.9 {options for bitmap images} -body {
image create bitmap i1 -data $data1 -maskdata $data2
lindex [i1 configure -maskdata] 4
-} $data2
-test imageBmap-1.10 {options for bitmap images} {
- list [catch {image create bitmap i1 -data $data1 -maskdata bogus} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-1.11 {options for bitmap images} {
+} -result $data2
+test imageBmap-1.10 {options for bitmap images} -body {
+ image create bitmap i1 -data $data1 -maskdata bogus
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-1.11 {options for bitmap images} -body {
image create bitmap i1 -file foo.bm -maskfile foo2.bm
lindex [i1 configure -maskfile] 4
-} foo2.bm
-test imageBmap-1.12 {options for bitmap images} {
+} -result foo2.bm
+test imageBmap-1.12 {options for bitmap images} -body {
list [catch {image create bitmap i1 -data $data1 -maskfile bogus} msg] \
[string tolower $msg]
-} {1 {couldn't read bitmap file "bogus": no such file or directory}}
+} -result {1 {couldn't read bitmap file "bogus": no such file or directory}}
rename bgerror {}
-test imageBmap-2.1 {ImgBmapCreate procedure} {
+
+test imageBmap-2.1 {ImgBmapCreate procedure} -setup {
+ eval image delete [image names]
+} -body {
eval image delete [image names]
- .c delete all
list [catch {image create bitmap -gorp dum} msg] $msg [image names]
-} {1 {unknown option "-gorp"} {}}
-test imageBmap-2.2 {ImgBmapCreate procedure} {
+} -result {1 {unknown option "-gorp"} {}}
+test imageBmap-2.2 {ImgBmapCreate procedure} -setup {
eval image delete [image names]
- .c delete all
+} -body {
image create bitmap image1
list [info commands image1] [image names] \
[image width image1] [image height image1] \
[lindex [image1 configure -foreground] 4] \
[lindex [image1 configure -background] 4]
-} {image1 image1 0 0 #000000 {}}
+} -cleanup {
+ image delete image1
+} -result {image1 image1 0 0 #000000 {}}
-test imageBmap-3.1 {ImgBmapConfigureMaster procedure, memory de-allocation} {
+
+test imageBmap-3.1 {ImgBmapConfigureMaster procedure, memory de-allocation} -body {
image create bitmap i1 -data $data1
i1 configure -data $data1
-} {}
-test imageBmap-3.2 {ImgBmapConfigureMaster procedure} {
+} -cleanup {
+ image delete i1
+} -result {}
+test imageBmap-3.2 {ImgBmapConfigureMaster procedure} -body {
image create bitmap i1 -data $data1
list [catch {i1 configure -data bogus} msg] $msg [image width i1] \
[image height i1]
-} {1 {format error in bitmap data} 16 16}
-test imageBmap-3.3 {ImgBmapConfigureMaster procedure, memory de-allocation} {
+} -result {1 {format error in bitmap data} 16 16}
+test imageBmap-3.3 {ImgBmapConfigureMaster procedure, memory de-allocation} -body {
image create bitmap i1 -data $data1 -maskdata $data2
i1 configure -maskdata $data2
-} {}
-test imageBmap-3.4 {ImgBmapConfigureMaster procedure} {
+} -cleanup {
+ image delete i1
+} -result {}
+test imageBmap-3.4 {ImgBmapConfigureMaster procedure} -body {
image create bitmap i1
- list [catch {i1 configure -maskdata $data2} msg] $msg
-} {1 {can't have mask without bitmap}}
-test imageBmap-3.5 {ImgBmapConfigureMaster procedure} {
- list [catch {image create bitmap i1 -data $data1 -maskdata {
+ i1 configure -maskdata $data2
+} -returnCodes error -result {can't have mask without bitmap}
+test imageBmap-3.5 {ImgBmapConfigureMaster procedure} -body {
+ image create bitmap i1 -data $data1 -maskdata {
#define foo_width 8
#define foo_height 16
static char foo_bits[] = {
0xff, 0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0xff, 0xff, 0xff, 0xff, 0x81, 0x81};
}
- } msg] $msg
-} {1 {bitmap and mask have different sizes}}
-test imageBmap-3.6 {ImgBmapConfigureMaster procedure} {
- list [catch {image create bitmap i1 -data $data1 -maskdata {
+} -returnCodes error -result {bitmap and mask have different sizes}
+test imageBmap-3.6 {ImgBmapConfigureMaster procedure} -body {
+ image create bitmap i1 -data $data1 -maskdata {
#define foo_width 16
#define foo_height 8
static char foo_bits[] = {
0xff, 0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0xff, 0xff, 0xff, 0xff, 0x81, 0x81};
}
- } msg] $msg
-} {1 {bitmap and mask have different sizes}}
-test imageBmap-3.7 {ImgBmapConfigureMaster procedure} {
+} -returnCodes error -result {bitmap and mask have different sizes}
+test imageBmap-3.7 {ImgBmapConfigureMaster procedure} -setup {
+ destroy .c
+ pack [canvas .c]
+} -body {
image create bitmap i1 -data $data1
.c create image 100 100 -image i1 -tags i1.1 -anchor nw
.c create image 200 100 -image i1 -tags i1.2 -anchor nw
@@ -165,63 +197,71 @@ test imageBmap-3.7 {ImgBmapConfigureMaster procedure} {
}
update
list [image width i1] [image height i1] [.c bbox i1.1] [.c bbox i1.2]
-} {15 14 {100 100 115 114} {200 100 215 114}}
+} -cleanup {
+ image delete i1
+ destroy .c
+} -result {15 14 {100 100 115 114} {200 100 215 114}}
+
-test imageBmap-4.1 {ImgBmapConfigureInstance procedure: check error handling} {
+test imageBmap-4.1 {ImgBmapConfigureInstance procedure: check error handling} -setup {
+ destroy .c
+ pack [canvas .c]
+ update
+} -body {
proc bgerror args {}
- .c delete all
image create bitmap i1 -file foo.bm
.c create image 100 100 -image i1
update
i1 configure -foreground bogus
update
-} {}
+} -cleanup {
+ image delete i1
+ destroy .c
+} -result {}
-test imageBmap-5.1 {GetBitmapData procedure} {
+
+test imageBmap-5.1 {GetBitmapData procedure} -body {
list [catch {image create bitmap -file ~bad_user/a/b} msg] \
[string tolower $msg]
-} {1 {user "bad_user" doesn't exist}}
-test imageBmap-5.2 {GetBitmapData procedure} {
+} -result {1 {user "bad_user" doesn't exist}}
+test imageBmap-5.2 {GetBitmapData procedure} -body {
list [catch {image create bitmap -file bad_name} msg] [string tolower $msg]
-} {1 {couldn't read bitmap file "bad_name": no such file or directory}}
-test imageBmap-5.3 {GetBitmapData procedure} {
+} -result {1 {couldn't read bitmap file "bad_name": no such file or directory}}
+test imageBmap-5.3 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap -data { }} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.4 {GetBitmapData procedure} {
+ image create bitmap -data { }
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.4 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap -data {#define foo2_width}} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.5 {GetBitmapData procedure} {
+ image create bitmap -data {#define foo2_width}
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.5 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap -data {#define foo2_width gorp}} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.6 {GetBitmapData procedure} {
+ image create bitmap -data {#define foo2_width gorp}
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.6 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap -data {#define foo2_width 1.4}} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.7 {GetBitmapData procedure} {
+
+ image create bitmap -data {#define foo2_width 1.4}
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.7 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap -data {#define foo2_height}} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.8 {GetBitmapData procedure} {
+
+ image create bitmap -data {#define foo2_height}
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.8 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap -data {#define foo2_height gorp}} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.9 {GetBitmapData procedure} {
+
+ image create bitmap -data {#define foo2_height gorp}
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.9 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap -data {#define foo2_height 1.4}} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.10 {GetBitmapData procedure} {
+
+ image create bitmap -data {#define foo2_height 1.4}
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.10 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
+
image create bitmap i1 -data {
#define foo2_height 14
#define foo2_width 15 xx _widtg 18 xwidth 18 _heighz 18 xheight 18
@@ -232,10 +272,12 @@ test imageBmap-5.10 {GetBitmapData procedure} {
0xff, 0xff};
}
list [image width i1] [image height i1]
-} {15 14}
-test imageBmap-5.11 {GetBitmapData procedure} {
+} -cleanup {
+ image delete i1
+} -result {15 14}
+test imageBmap-5.11 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
+
image create bitmap i1 -data {
_height 14 _width 15
char {
@@ -245,11 +287,13 @@ test imageBmap-5.11 {GetBitmapData procedure} {
0xff, 0xff}
}
list [image width i1] [image height i1]
-} {15 14}
-test imageBmap-5.12 {GetBitmapData procedure} {
+} -cleanup {
+ image delete i1
+} -result {15 14}
+test imageBmap-5.12 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap i1 -data {
+
+ image create bitmap i1 -data {
#define foo2_height 14
#define foo2_width 15
static short foo2_bits[] = {
@@ -257,12 +301,12 @@ test imageBmap-5.12 {GetBitmapData procedure} {
0xff, 0x81, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81,
0xff, 0x81, 0xff, 0x81, 0xff, 0x81, 0xff, 0x81, 0xff, 0x81,
0xff, 0xff};
- }} msg] $msg
-} {1 {format error in bitmap data; looks like it's an obsolete X10 bitmap file}}
-test imageBmap-5.13 {GetBitmapData procedure} {
+ }
+} -returnCodes error -result {format error in bitmap data; looks like it's an obsolete X10 bitmap file}
+test imageBmap-5.13 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap i1 -data {
+
+ image create bitmap i1 -data {
#define foo2_height 16
#define foo2_width 16
static char foo2_bits[] =
@@ -270,28 +314,28 @@ test imageBmap-5.13 {GetBitmapData procedure} {
0xff, 0x81, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81,
0xff, 0x81, 0xff, 0x81, 0xff, 0x81, 0xff, 0x81, 0xff, 0x81,
0xff, 0xff;
- }} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.14 {GetBitmapData procedure} {
+ }
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.14 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap i1 -data {
+
+ image create bitmap i1 -data {
#define foo2_width 16
static char foo2_bits[] = {
- 0xff, 0xff, 0xff, }}} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.15 {GetBitmapData procedure} {
+ 0xff, 0xff, 0xff, }}
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.15 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap i1 -data {
+
+ image create bitmap i1 -data {
#define foo2_height 16
static char foo2_bits[] = {
- 0xff, 0xff, 0xff, }}} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.16 {GetBitmapData procedure} {
+ 0xff, 0xff, 0xff, }}
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.16 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap i1 -data {
+
+ image create bitmap i1 -data {
#define foo2_height 16
#define foo2_width 16
static char foo2_bits[] = {
@@ -299,12 +343,12 @@ test imageBmap-5.16 {GetBitmapData procedure} {
0xff, 0x81, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81,
0xff, 0x81, 0xff, 0x81, 0xff, 0x81, 0xff, 0x81, 0xff, 0x81,
0xff, foo};
- }} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-5.17 {GetBitmapData procedure} {
+ }
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-5.17 {GetBitmapData procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap i1 -data "
+
+ image create bitmap i1 -data "
#define foo2_height 16
#define foo2_width 16
static char foo2_bits[] = \{
@@ -312,67 +356,69 @@ test imageBmap-5.17 {GetBitmapData procedure} {
0xff, 0x81, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81,
0xff, 0x81, 0xff, 0x81, 0xff, 0x81, 0xff, 0x81, 0xff, 0x81,
0xff
- "} msg] $msg
-} {1 {format error in bitmap data}}
+ "
+} -returnCodes error -result {format error in bitmap data}
-test imageBmap-6.1 {NextBitmapWord procedure} {
+
+test imageBmap-6.1 {NextBitmapWord procedure} -body {
eval image delete [image names]
- .c delete all
- list [catch {image create bitmap i1 -data {1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890}} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-6.2 {NextBitmapWord procedure} {
+ image create bitmap i1 -data {1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890}
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-6.2 {NextBitmapWord procedure} -body {
eval image delete [image names]
- .c delete all
makeFile {1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890} foo3.bm
- list [catch {image create bitmap i1 -file foo3.bm} msg] $msg
-} {1 {format error in bitmap data}}
-test imageBmap-6.3 {NextBitmapWord procedure} {
+ image create bitmap i1 -file foo3.bm
+} -returnCodes error -result {format error in bitmap data}
+test imageBmap-6.3 {NextBitmapWord procedure} -body {
eval image delete [image names]
- .c delete all
makeFile { } foo3.bm
- list [catch {image create bitmap i1 -file foo3.bm} msg] $msg
-} {1 {format error in bitmap data}}
+ image create bitmap i1 -file foo3.bm
+} -returnCodes error -result {format error in bitmap data}
removeFile foo3.bm
+
eval image delete [image names]
-.c delete all
+# Image used in 7.* tests
image create bitmap i1
-test imageBmap-7.1 {ImgBmapCmd procedure} {
- list [catch {i1} msg] $msg
-} {1 {wrong # args: should be "i1 option ?arg ...?"}}
-test imageBmap-7.2 {ImgBmapCmd procedure, "cget" option} {
- list [catch {i1 cget} msg] $msg
-} {1 {wrong # args: should be "i1 cget option"}}
-test imageBmap-7.3 {ImgBmapCmd procedure, "cget" option} {
- list [catch {i1 cget a b} msg] $msg
-} {1 {wrong # args: should be "i1 cget option"}}
-test imageBmap-7.4 {ImgBmapCmd procedure, "cget" option} {
+test imageBmap-7.1 {ImgBmapCmd procedure} -body {
+ i1
+} -returnCodes error -result {wrong # args: should be "i1 option ?arg ...?"}
+test imageBmap-7.2 {ImgBmapCmd procedure, "cget" option} -body {
+ i1 cget
+} -returnCodes error -result {wrong # args: should be "i1 cget option"}
+test imageBmap-7.3 {ImgBmapCmd procedure, "cget" option} -body {
+ i1 cget a b
+} -returnCodes error -result {wrong # args: should be "i1 cget option"}
+test imageBmap-7.4 {ImgBmapCmd procedure, "cget" option} -body {
i1 co -foreground #123456
i1 cget -foreground
-} {#123456}
-test imageBmap-7.5 {ImgBmapCmd procedure, "cget" option} {
- list [catch {i1 cget -stupid} msg] $msg
-} {1 {unknown option "-stupid"}}
-test imageBmap-7.6 {ImgBmapCmd procedure} {
+} -result {#123456}
+test imageBmap-7.5 {ImgBmapCmd procedure, "cget" option} -body {
+ i1 cget -stupid
+} -returnCodes error -result {unknown option "-stupid"}
+test imageBmap-7.6 {ImgBmapCmd procedure} -body {
llength [i1 configure]
-} {6}
-test imageBmap-7.7 {ImgBmapCmd procedure} {
+} -result {6}
+test imageBmap-7.7 {ImgBmapCmd procedure} -body {
i1 co -foreground #001122
i1 configure -foreground
-} {-foreground {} {} #000000 #001122}
-test imageBmap-7.8 {ImgBmapCmd procedure} {
- list [catch {i1 configure -gorp} msg] $msg
-} {1 {unknown option "-gorp"}}
-test imageBmap-7.9 {ImgBmapCmd procedure} {
- list [catch {i1 configure -foreground #221100 -background} msg] $msg
-} {1 {value for "-background" missing}}
-test imageBmap-7.10 {ImgBmapCmd procedure} {
- list [catch {i1 gorp} msg] $msg
-} {1 {bad option "gorp": must be cget or configure}}
-
-test imageBmap-8.1 {ImgBmapGet/Free procedures, shared instances} {
- eval image delete [image names]
- .c delete all
+} -result {-foreground {} {} #000000 #001122}
+test imageBmap-7.8 {ImgBmapCmd procedure} -body {
+ i1 configure -gorp
+} -returnCodes error -result {unknown option "-gorp"}
+test imageBmap-7.9 {ImgBmapCmd procedure} -body {
+ i1 configure -foreground #221100 -background
+} -returnCodes error -result {value for "-background" missing}
+test imageBmap-7.10 {ImgBmapCmd procedure} -body {
+ i1 gorp
+} -returnCodes error -result {bad option "gorp": must be cget or configure}
+
+
+test imageBmap-8.1 {ImgBmapGet/Free procedures, shared instances} -setup {
+ destroy .c
+ pack [canvas .c]
+ update
+} -body {
image create bitmap i1 -data $data1
.c create image 50 100 -image i1 -tags i1.1
.c create image 150 100 -image i1 -tags i1.2
@@ -388,18 +434,31 @@ test imageBmap-8.1 {ImgBmapGet/Free procedures, shared instances} {
i1 configure -background black
update
image delete i1
-} {}
+} -cleanup {
+ destroy .c
+} -result {}
+
-test imageBmap-9.1 {ImgBmapDisplay procedure, nothing to display} {
+test imageBmap-9.1 {ImgBmapDisplay procedure, nothing to display} -setup {
+ destroy .c
+ pack [canvas .c]
+ update
+} -body {
proc bgerror args {}
eval image delete [image names]
- .c delete all
image create bitmap i1 -data $data1
.c create image 50 100 -image i1 -tags i1.1
i1 configure -data {}
update
-} {}
-test imageBmap-9.2 {ImgBmapDisplay procedure, nothing to display} {
+} -cleanup {
+ image delete i1
+ destroy .c
+} -result {}
+test imageBmap-9.2 {ImgBmapDisplay procedure, nothing to display} -setup {
+ destroy .c
+ pack [canvas .c]
+ update
+} -body {
proc bgerror args {}
eval image delete [image names]
.c delete all
@@ -407,24 +466,36 @@ test imageBmap-9.2 {ImgBmapDisplay procedure, nothing to display} {
.c create image 50 100 -image i1 -tags i1.1
i1 configure -foreground bogus
update
-} {}
+} -cleanup {
+ image delete i1
+ destroy .c
+} -result {}
if {[info exists bgerror]} {
rename bgerror {}
}
-test imageBmap-10.1 {ImgBmapFree procedure, resource freeing} {
+
+test imageBmap-10.1 {ImgBmapFree procedure, resource freeing} -setup {
+ destroy .c
+ pack [canvas .c]
+ update
+} -body {
eval image delete [image names]
- .c delete all
image create bitmap i1 -data $data1 -maskdata $data2 -foreground #112233 \
-background #445566
.c create image 100 100 -image i1
update
.c delete all
image delete i1
-} {}
-test imageBmap-10.2 {ImgBmapFree procedures, unlinking} {
+} -cleanup {
+ destroy .c
+} -result {}
+test imageBmap-10.2 {ImgBmapFree procedures, unlinking} -setup {
+ destroy .c
+ pack [canvas .c]
+ update
+} -body {
eval image delete [image names]
- .c delete all
image create bitmap i1 -data $data1 -maskdata $data2 -foreground #112233 \
-background #445566
.c create image 100 100 -image i1
@@ -440,32 +511,37 @@ test imageBmap-10.2 {ImgBmapFree procedures, unlinking} {
destroy .b1
update
.c delete all
-} {}
+} -cleanup {
+ image delete i1
+ deleteWindows
+} -result {}
+
-test imageBmap-11.1 {ImgBmapDelete procedure} {
+test imageBmap-11.1 {ImgBmapDelete procedure} -body {
image create bitmap i2 -file foo.bm -maskfile foo2.bm
image delete i2
info command i2
-} {}
-test imageBmap-11.2 {ImgBmapDelete procedure} {
+} -result {}
+test imageBmap-11.2 {ImgBmapDelete procedure} -body {
image create bitmap i2 -file foo.bm -maskfile foo2.bm
rename i2 newi2
set x [list [info command i2] [info command new*] [newi2 cget -file]]
image delete i2
lappend x [info command new*]
-} {{} newi2 foo.bm {}}
+} -result {{} newi2 foo.bm {}}
-test imageBmap-12.1 {ImgBmapCmdDeletedProc procedure} {
+
+test imageBmap-12.1 {ImgBmapCmdDeletedProc procedure} -body {
image create bitmap i2 -file foo.bm -maskfile foo2.bm
rename i2 {}
list [lsearch -exact [image names] i2] [catch {i2 foo} msg] $msg
-} {-1 1 {invalid command name "i2"}}
+} -result {-1 1 {invalid command name "i2"}}
removeFile foo.bm
removeFile foo2.bm
-destroy .c
eval image delete [image names]
# cleanup
cleanupTests
return
+
diff --git a/tests/imgPPM.test b/tests/imgPPM.test
index 7805280..4e33843 100644
--- a/tests/imgPPM.test
+++ b/tests/imgPPM.test
@@ -6,9 +6,10 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: imgPPM.test,v 1.10 2007/12/13 15:27:54 dgp Exp $
+# RCS: @(#) $Id: imgPPM.test,v 1.11 2008/08/17 19:40:33 aniap Exp $
-package require tcltest 2.1
+package require tcltest 2.2
+namespace import ::tcltest::*
eval tcltest::configure $argv
tcltest::loadTestedCommands
@@ -23,141 +24,145 @@ proc put {file data} {
close $f
}
-test imgPPM-1.1 {FileReadPPM procedure} {
+test imgPPM-1.1 {FileReadPPM procedure} -body {
put test.ppm "P6\n0 256\n255\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
-test imgPPM-1.2 {FileReadPPM procedure} {
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {PPM image file "test.ppm" has dimension(s) <= 0}
+test imgPPM-1.2 {FileReadPPM procedure} -body {
put test.ppm "P6\n-2 256\n255\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
-test imgPPM-1.3 {FileReadPPM procedure} {
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {PPM image file "test.ppm" has dimension(s) <= 0}
+test imgPPM-1.3 {FileReadPPM procedure} -body {
put test.ppm "P6\n10 0\n255\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
-test imgPPM-1.4 {FileReadPPM procedure} {
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {PPM image file "test.ppm" has dimension(s) <= 0}
+test imgPPM-1.4 {FileReadPPM procedure} -body {
put test.ppm "P6\n10 -2\n255\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
-test imgPPM-1.5 {FileReadPPM procedure} {
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {PPM image file "test.ppm" has dimension(s) <= 0}
+test imgPPM-1.5 {FileReadPPM procedure} -body {
put test.ppm "P6\n10 20\n256\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {PPM image file "test.ppm" has bad maximum intensity value 256}}
-test imgPPM-1.6 {FileReadPPM procedure} {
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {PPM image file "test.ppm" has bad maximum intensity value 256}
+test imgPPM-1.6 {FileReadPPM procedure} -body {
put test.ppm "P6\n10 20\n0\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {PPM image file "test.ppm" has bad maximum intensity value 0}}
-test imgPPM-1.7 {FileReadPPM procedure} {
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {PPM image file "test.ppm" has bad maximum intensity value 0}
+test imgPPM-1.7 {FileReadPPM procedure} -body {
put test.ppm "P6\n10 10\n255\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {error reading PPM image file "test.ppm": not enough data}}
-test imgPPM-1.8 {FileReadPPM procedure} {
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {error reading PPM image file "test.ppm": not enough data}
+test imgPPM-1.8 {FileReadPPM procedure} -body {
put test.ppm "P6\n5 4\n255\n01234567890123456789012345678901234567890123456789012345678"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {error reading PPM image file "test.ppm": not enough data}}
-test imgPPM-1.9 {FileReadPPM procedure} {
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {error reading PPM image file "test.ppm": not enough data}
+test imgPPM-1.9 {FileReadPPM procedure} -body {
put test.ppm "P6\n5 4\n150\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg \
- [image width p1] [image height p1]
-} {0 p1 5 4}
+ list [image create photo p1 -file test.ppm] \
+ [image width p1] [image height p1]
+} -returnCodes ok -result {p1 5 4}
-catch {image delete p1}
-put test.ppm "P6\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
-image create photo p1 -file test.ppm
-test imgPPM-2.1 {FileWritePPM procedure} {
+
+test imgPPM-2.1 {FileWritePPM procedure} -setup {
+ catch {image delete p1}
+} -body {
+ put test.ppm "P6\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
+ image create photo p1 -file test.ppm
list [catch {p1 write not_a_dir/bar/baz/gorp} msg] [string tolower $msg] \
- [string tolower $errorCode]
-} {1 {couldn't open "not_a_dir/bar/baz/gorp": no such file or directory} {posix enoent {no such file or directory}}}
-test imgPPM-2.2 {FileWritePPM procedure} {
+ [string tolower $errorCode]
+} -cleanup {
+ image delete p1
+} -result {1 {couldn't open "not_a_dir/bar/baz/gorp": no such file or directory} {posix enoent {no such file or directory}}}
+
+test imgPPM-2.2 {FileWritePPM procedure} -setup {
+ catch {image delete p1}
catch {unset data}
+} -body {
+ put test.ppm "P6\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
+ image create photo p1 -file test.ppm
p1 write -format ppm test.ppm
set fd [open test.ppm]
set data [read $fd]
close $fd
set data
-} {P6
+} -cleanup {
+ image delete p1
+} -result {P6
5 4
255
012345678901234567890123456789012345678901234567890123456789}
-test imgPPM-3.1 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
+
+test imgPPM-3.1 {ReadPPMFileHeader procedure} -body {
put test.ppm "# \n#\n#\nP6\n#\n##\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {0 p1}
-test imgPPM-3.2 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -cleanup {
+ image delete p1
+} -returnCodes ok -result p1
+test imgPPM-3.2 {ReadPPMFileHeader procedure} -body {
put test.ppm "P6\n5\n 4 255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {0 p1}
-test imgPPM-3.3 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -cleanup {
+ image delete p1
+} -returnCodes ok -result p1
+test imgPPM-3.3 {ReadPPMFileHeader procedure} -body {
put test.ppm "P6\n# asdfasdf\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {0 p1}
-test imgPPM-3.4 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -cleanup {
+ image delete p1
+} -returnCodes ok -result p1
+test imgPPM-3.4 {ReadPPMFileHeader procedure} -body {
put test.ppm "P6 \n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {0 p1}
-test imgPPM-3.5 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -cleanup {
+ image delete p1
+} -returnCodes ok -result p1
+test imgPPM-3.5 {ReadPPMFileHeader procedure} -body {
put test.ppm "P5\n5 4\n255\n01234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {0 p1}
-test imgPPM-3.6 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -cleanup {
+ image delete p1
+} -returnCodes ok -result p1
+test imgPPM-3.6 {ReadPPMFileHeader procedure} -body {
put test.ppm "P3\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {couldn't recognize data in image file "test.ppm"}}
-test imgPPM-3.7 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
+test imgPPM-3.7 {ReadPPMFileHeader procedure} -body {
put test.ppm "P6x\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {couldn't recognize data in image file "test.ppm"}}
-test imgPPM-3.8 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
+test imgPPM-3.8 {ReadPPMFileHeader procedure} -body {
put test.ppm "P6\nxy5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {couldn't recognize data in image file "test.ppm"}}
-test imgPPM-3.9 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
+test imgPPM-3.9 {ReadPPMFileHeader procedure} -body {
put test.ppm "P6\n5\n255\n!012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {couldn't recognize data in image file "test.ppm"}}
-test imgPPM-3.10 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
+test imgPPM-3.10 {ReadPPMFileHeader procedure} -body {
put test.ppm "P6\n5 4\nzz255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {couldn't recognize data in image file "test.ppm"}}
-test imgPPM-3.11 {ReadPPMFileHeader procedure, empty file} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
+test imgPPM-3.11 {ReadPPMFileHeader procedure, empty file} -body {
put test.ppm " "
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {couldn't recognize data in image file "test.ppm"}}
-test imgPPM-3.12 {ReadPPMFileHeader procedure, file ends too soon} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
+test imgPPM-3.12 {ReadPPMFileHeader procedure, file ends too soon} -body {
put test.ppm "P6\n566"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {couldn't recognize data in image file "test.ppm"}}
-test imgPPM-3.13 {ReadPPMFileHeader procedure, file ends too soon} {
- catch {image delete p1}
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
+test imgPPM-3.13 {ReadPPMFileHeader procedure, file ends too soon} -body {
put test.ppm "P6\n566\n#asdf"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
-} {1 {couldn't recognize data in image file "test.ppm"}}
+ image create photo p1 -file test.ppm
+} -returnCodes error -result {couldn't recognize data in image file "test.ppm"}
-test imgPPM-4.1 {StringReadPPM procedure, data too short [Bug 1822391]} \
- -setup {
- image create photo I -width 1103 -height 997
- } \
- -cleanup {
- image delete I
- } \
- -body {
- I put "P5\n1103 997\n255\n"
- } \
- -returnCodes error \
- -result {truncated PPM data}
+
+test imgPPM-4.1 {StringReadPPM procedure, data too short [Bug 1822391]} -body {
+ image create photo I -width 1103 -height 997
+ I put "P5\n1103 997\n255\n"
+} -cleanup {
+ image delete I
+} -returnCodes error -result {truncated PPM data}
eval image delete [image names]
@@ -165,3 +170,4 @@ eval image delete [image names]
catch {file delete test.ppm}
cleanupTests
return
+
diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test
index d1f64b5..d2884d2 100644
--- a/tests/imgPhoto.test
+++ b/tests/imgPhoto.test
@@ -9,480 +9,874 @@
#
# Author: Paul Mackerras (paulus@cs.anu.edu.au)
#
-# RCS: @(#) $Id: imgPhoto.test,v 1.30 2008/07/23 23:24:25 nijtmans Exp $
+# RCS: @(#) $Id: imgPhoto.test,v 1.31 2008/08/17 19:40:33 aniap Exp $
-package require tcltest 2.1
+package require tcltest 2.2
+namespace import ::tcltest::*
eval tcltest::configure $argv
tcltest::loadTestedCommands
-eval image delete [image names]
-
-canvas .c
-pack .c
-update
+# Used for 4.65 - 4.73 tests
+# Now for some heftier testing, checking that setting and resetting of
+# pixels' transparency status doesn't "leak" with any one-off errors.
+proc checkImgTrans {img width height} {
+ set result {}
+ for {set x 0} {$x<$width} {incr x} {
+ for {set y 0} {$y<$height} {incr y} {
+ if {[$img transparency get $x $y]} {
+ lappend result $x $y
+ }
+ }
+ }
+ return $result
+}
+eval image delete [image names]
set README [makeFile {
-README -- Tk test suite design document.
+ README -- Tk test suite design document.
} README-imgPhoto]
+
# find the teapot.ppm file for use in these tests
set teapotPhotoFile [file join [file dirname [info script]] teapot.ppm]
testConstraint hasTeapotPhoto [file exists $teapotPhotoFile]
-test imgPhoto-1.1 {options for photo images} {
- image create photo p1 -width 79 -height 83
- list [lindex [p1 configure -width] 4] [lindex [p1 configure -height] 4] \
- [image width p1] [image height p1]
-} {79 83 79 83}
-test imgPhoto-1.2 {options for photo images} {
- list [catch {image create photo p1 -file no.such.file} err] \
- [string tolower $err]
-} {1 {couldn't open "no.such.file": no such file or directory}}
-test imgPhoto-1.3 {options for photo images} hasTeapotPhoto {
- list [catch {image create photo p1 -file $teapotPhotoFile \
- -format no.such.format} err] $err
-} {1 {image file format "no.such.format" is not supported}}
-test imgPhoto-1.4 {options for photo images} hasTeapotPhoto {
- image create photo p1 -file $teapotPhotoFile
- list [image width p1] [image height p1]
-} {256 256}
-test imgPhoto-1.5 {options for photo images} hasTeapotPhoto {
- image create photo p1 -file $teapotPhotoFile \
+test imgPhoto-1.1 {options for photo images} -body {
+ image create photo photo1 -width 79 -height 83
+ list [photo1 cget -width] [photo1 cget -height] \
+ [image width photo1] [image height photo1]
+} -cleanup {
+ image delete photo1
+} -result {79 83 79 83}
+test imgPhoto-1.2 {options for photo images} -body {
+ list [catch {image create photo photo1 -file no.such.file} err] \
+ [string tolower $err]
+} -result {1 {couldn't open "no.such.file": no such file or directory}}
+test imgPhoto-1.3 {options for photo images} -constraints hasTeapotPhoto -body {
+ image create photo photo1 -file $teapotPhotoFile -format no.such.format
+} -returnCodes error -result {image file format "no.such.format" is not supported}
+test imgPhoto-1.4 {options for photo images} -constraints hasTeapotPhoto -body {
+ image create photo photo1 -file $teapotPhotoFile
+ list [image width photo1] [image height photo1]
+} -cleanup {
+ image delete photo1
+} -result {256 256}
+test imgPhoto-1.5 {options for photo images} -constraints hasTeapotPhoto -body {
+ image create photo photo1 -file $teapotPhotoFile \
-format ppm -width 79 -height 83
- list [image width p1] [image height p1] \
- [lindex [p1 configure -file] 4] [lindex [p1 configure -format] 4]
-} [list 79 83 $teapotPhotoFile ppm]
-test imgPhoto-1.6 {options for photo images} {
- image create photo p1 -palette 2/2/2 -gamma 2.2
- list [format %.1f [lindex [p1 configure -gamma] 4]] \
- [lindex [p1 configure -palette] 4]
-} {2.2 2/2/2}
-test imgPhoto-1.7 {options for photo images} {
- list [catch {image create photo p1 -file $README} err] $err
-} [subst {1 {couldn't recognize data in image file "$README"}}]
-test imgPhoto-1.8 {options for photo images} {
- list [catch {image create photo -blah blah} err] $err
-} {1 {unknown option "-blah"}}
-test imgPhoto-1.9 {options for photo images - error case} {
- list [catch {image create photo -format} err] $err
-} {1 {value for "-format" missing}}
-test imgPhoto-1.10 {options for photo images - error case} {
- list [catch {image create photo -data} err] $err
-} {1 {value for "-data" missing}}
-test imgPhoto-1.11 {options for photo images - error case} {
- list [catch {image create photo p1 -format} err] $err
-} {1 {value for "-format" missing}}
-
-test imgPhoto-2.1 {ImgPhotoCreate procedure} {
+ list [image width photo1] [image height photo1] [photo1 cget -file] [photo1 cget -format]
+} -cleanup {
+ image delete photo1
+} -result [list 79 83 $teapotPhotoFile ppm]
+test imgPhoto-1.6 {options for photo images} -body {
+ image create photo photo1 -palette 2/2/2 -gamma 2.2
+ list [format %.1f [photo1 cget -gamma]] [photo1 cget -palette]
+} -cleanup {
+ image delete photo1
+} -result {2.2 2/2/2}
+test imgPhoto-1.7 {options for photo images} -body {
+ image create photo photo1 -file $README
+} -returnCodes error -result [subst {couldn't recognize data in image file "$README"}]
+test imgPhoto-1.8 {options for photo images} -body {
+ image create photo -blah blah
+} -returnCodes error -result {unknown option "-blah"}
+test imgPhoto-1.9 {options for photo images - error case} -body {
+ image create photo -format
+} -returnCodes error -result {value for "-format" missing}
+test imgPhoto-1.10 {options for photo images - error case} -body {
+ image create photo -data
+} -returnCodes error -result {value for "-data" missing}
+test imgPhoto-1.11 {options for photo images - error case} -body {
+ image create photo photo1 -format
+} -returnCodes error -result {value for "-format" missing}
+
+
+test imgPhoto-2.1 {ImgPhotoCreate procedure} -body {
eval image delete [image names]
catch {image create photo -blah blah}
image names
-} {}
-test imgPhoto-2.2 {ImgPhotoCreate procedure} {
+} -result {}
+test imgPhoto-2.2 {ImgPhotoCreate procedure} -body {
eval image delete [image names]
image create photo image1
list [info commands image1] [image names] \
[image width image1] [image height image1]
-} {image1 image1 0 0}
+} -cleanup {
+ image delete image1
+} -result {image1 image1 0 0}
# test imgPhoto-2.3 {ImgPhotoCreate procedure: creation failure} {
-# image create photo p1
-# image create photo p2 -width 10 -height 10
-# catch {image create photo p2 -file bogus.img} msg
-# p1 copy p2
+# image create photo photo1
+# image create photo photo2 -width 10 -height 10
+# catch {image create photo photo2 -file bogus.img} msg
+# photo1 copy photo2
# set msg
# } {couldn't open "bogus.img": no such file or directory}
-test imgPhoto-3.1 {ImgPhotoConfigureMaster procedure} hasTeapotPhoto {
- image create photo p1 -file $teapotPhotoFile
- p1 configure -file $teapotPhotoFile
-} {}
-test imgPhoto-3.2 {ImgPhotoConfigureMaster procedure} hasTeapotPhoto {
- image create photo p1 -file $teapotPhotoFile
- list [catch {p1 configure -file bogus} err] [string tolower $err] \
- [image width p1] [image height p1]
-} {1 {couldn't open "bogus": no such file or directory} 256 256}
-test imgPhoto-3.3 {ImgPhotoConfigureMaster procedure} hasTeapotPhoto {
- image create photo p1
- .c create image 10 10 -image p1 -tags p1.1 -anchor nw
- .c create image 300 10 -image p1 -tags p1.2 -anchor nw
+
+test imgPhoto-3.1 {ImgPhotoConfigureMaster procedure} -constraints {
+ hasTeapotPhoto
+} -body {
+ image create photo photo1 -file $teapotPhotoFile
+ photo1 configure -file $teapotPhotoFile
+} -cleanup {
+ image delete photo1
+} -result {}
+test imgPhoto-3.2 {ImgPhotoConfigureMaster procedure} -constraints {
+ hasTeapotPhoto
+} -body {
+ image create photo photo1 -file $teapotPhotoFile
+ list [catch {photo1 configure -file bogus} err] [string tolower $err] \
+ [image width photo1] [image height photo1]
+} -cleanup {
+ image delete photo1
+} -result {1 {couldn't open "bogus": no such file or directory} 256 256}
+test imgPhoto-3.3 {ImgPhotoConfigureMaster procedure} -constraints {
+ hasTeapotPhoto
+} -setup {
+ destroy .c
+ pack [canvas .c]
+ update
+} -body {
+ image create photo photo1
+ .c create image 10 10 -image photo1 -tags photo1.1 -anchor nw
+ .c create image 300 10 -image photo1 -tags photo1.2 -anchor nw
update
- p1 configure -file $teapotPhotoFile
+ photo1 configure -file $teapotPhotoFile
update
- list [image width p1] [image height p1] [.c bbox p1.1] [.c bbox p1.2]
-} {256 256 {10 10 266 266} {300 10 556 266}}
+ list [image width photo1] [image height photo1] [.c bbox photo1.1] [.c bbox photo1.2]
+} -cleanup {
+ destroy .c
+ image delete photo1
+} -result {256 256 {10 10 266 266} {300 10 556 266}}
+
+
+test imgPhoto-4.1 {ImgPhotoCmd procedure} -setup {
+ image create photo photo1
+} -body {
+ photo1
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 option ?arg ...?"}
+test imgPhoto-4.2 {ImgPhotoCmd procedure} -setup {
+ image create photo photo1
+} -body {
+ photo1 blah
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {bad option "blah": must be blank, cget, configure, copy, data, get, put, read, redither, transparency, or write}
+test imgPhoto-4.3 {ImgPhotoCmd procedure: blank option} -setup {
+ image create photo photo1
+} -body {
+ photo1 blank
+ photo1 blank x
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 blank"}
+test imgPhoto-4.4 {ImgPhotoCmd procedure: cget option} -setup {
+ image create photo photo1
+} -body {
+ photo1 cget
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 cget option"}
+test imgPhoto-4.5 {ImgPhotoCmd procedure: cget option} -setup {
+ image create photo photo2 -width 25 -height 30
+} -body {
+ list [photo2 cget -width] [photo2 cget -height]
+} -cleanup {
+ image delete photo2
+} -result {25 30}
+test imgPhoto-4.6 {ImgPhotoCmd procedure: configure option} -setup {
+ image create photo photo1
+} -body {
+ llength [photo1 configure]
+} -cleanup {
+ image delete photo1
+} -result {7}
+test imgPhoto-4.7 {ImgPhotoCmd procedure: configure option} -setup {
+ image create photo photo1
+} -body {
+ photo1 conf -palette 3/4/2
+ photo1 configure -palette
+} -cleanup {
+ image delete photo1
+} -result {-palette {} {} {} 3/4/2}
+test imgPhoto-4.8 {ImgPhotoCmd procedure: configure option} -setup {
+ image create photo photo1
+} -body {
+ photo1 configure -blah
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {unknown option "-blah"}
+test imgPhoto-4.9 {ImgPhotoCmd procedure: configure option} -setup {
+ image create photo photo1
+} -body {
+ photo1 configure -palette {} -gamma
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {value for "-gamma" missing}
+test imgPhoto-4.10 {ImgPhotoCmd procedure: copy option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+ image create photo photo2 -width 25 -height 30
+} -body {
+ image create photo photo2 -file $teapotPhotoFile
+ photo1 configure -width 0 -height 0 -palette {} -gamma 1
+ photo1 copy photo2
+ list [image width photo1] [image height photo1] [photo1 get 100 100]
+} -cleanup {
+ image delete photo1 photo2
+} -result {256 256 {169 117 90}}
+test imgPhoto-4.11 {ImgPhotoCmd procedure: copy option} -setup {
+ image create photo photo1
+} -body {
+ photo1 copy
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 copy source-image ?-compositingrule rule? ?-from x1 y1 x2 y2? ?-to x1 y1 x2 y2? ?-zoom x y? ?-subsample x y?"}
+test imgPhoto-4.12 {ImgPhotoCmd procedure: copy option} -setup {
+ image create photo photo1
+} -body {
+ photo1 copy blah
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {image "blah" doesn't exist or is not a photo image}
+test imgPhoto-4.13 {ImgPhotoCmd procedure: copy option} -setup {
+ image create photo photo1
+ image create photo photo2
+} -body {
+ photo1 copy photo2 -blah
+} -cleanup {
+ image delete photo1 photo2
+} -returnCodes error -result {unrecognized option "-blah": must be -compositingrule, -from, -shrink, -subsample, -to, or -zoom}
+test imgPhoto-4.14 {ImgPhotoCmd procedure: copy option} -setup {
+ image create photo photo1
+ image create photo photo2
+} -body {
+ photo1 copy photo2 -from -to
+} -cleanup {
+ image delete photo1 photo2
+} -returnCodes error -result {the "-from" option requires one to four integer values}
+test imgPhoto-4.15 {ImgPhotoCmd procedure: copy option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+ image create photo photo2 -file $teapotPhotoFile
+} -body {
+ photo1 copy photo2
+ photo1 copy photo2 -from 0 70 60 120 -shrink
+ list [image width photo1] [image height photo1] [photo1 get 20 10]
+} -cleanup {
+ image delete photo1 photo2
+} -result {60 50 {215 154 120}}
+test imgPhoto-4.16 {ImgPhotoCmd procedure: copy option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+ image create photo photo2 -file $teapotPhotoFile
+} -body {
+ photo1 copy photo2 -from 60 120 0 70 -to 20 50
+ list [image width photo1] [image height photo1] [photo1 get 40 80]
+} -cleanup {
+ image delete photo1 photo2
+} -result {80 100 {19 92 192}}
+test imgPhoto-4.17 {ImgPhotoCmd procedure: copy option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+ image create photo photo2 -file $teapotPhotoFile
+} -body {
+ photo1 copy photo2 -from 0 120 60 70 -to 0 0 100 100
+ list [image width photo1] [image height photo1] [photo1 get 80 60]
+} -cleanup {
+ image delete photo1 photo2
+} -result {100 100 {215 154 120}}
+test imgPhoto-4.18 {ImgPhotoCmd procedure: copy option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+ image create photo photo2 -file $teapotPhotoFile
+} -body {
+ photo1 copy photo2 -from 60 70 0 120 -zoom 2
+ list [image width photo1] [image height photo1] [photo1 get 100 50]
+} -cleanup {
+ image delete photo1 photo2
+} -result {120 100 {169 99 47}}
+test imgPhoto-4.19 {ImgPhotoCmd procedure: copy option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+ image create photo photo2 -file $teapotPhotoFile
+} -body {
+ photo1 copy photo2 -from 0 70 60 120 -zoom 2
+ list [image width photo1] [image height photo1] [photo1 get 100 50]
+} -cleanup {
+ image delete photo1 photo2
+} -result {120 100 {169 99 47}}
+test imgPhoto-4.20 {ImgPhotoCmd procedure: copy option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+ image create photo photo2 -file $teapotPhotoFile
+} -body {
+ photo1 copy photo2 -from 20 20 200 180 -subsample 2 -shrink
+ list [image width photo1] [image height photo1] [photo1 get 50 30]
+} -cleanup {
+ image delete photo1 photo2
+} -result {90 80 {207 146 112}}
+test imgPhoto-4.21 {ImgPhotoCmd procedure: copy option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+ image create photo photo2 -file $teapotPhotoFile
+} -body {
+ photo1 copy photo2
+ set result [list [image width photo1] [image height photo1]]
+ photo1 conf -width 49 -height 51
+ lappend result [image width photo1] [image height photo1]
+ photo1 copy photo2
+ lappend result [image width photo1] [image height photo1]
+ photo1 copy photo2 -from 0 0 10 10 -shrink
+ lappend result [image width photo1] [image height photo1]
+ photo1 conf -width 0
+ photo1 copy photo2 -from 0 0 10 10 -shrink
+ lappend result [image width photo1] [image height photo1]
+ photo1 conf -height 0
+ photo1 copy photo2 -from 0 0 10 10 -shrink
+ lappend result [image width photo1] [image height photo1]
+} -cleanup {
+ image delete photo1 photo2
+} -result {256 256 49 51 49 51 49 51 10 51 10 10}
+test imgPhoto-4.22 {ImgPhotoCmd procedure: get option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+} -body {
+ photo1 read $teapotPhotoFile
+ list [photo1 get 100 100] [photo1 get 150 100] [photo1 get 100 150]
+} -cleanup {
+ image delete photo1
+} -result {{169 117 90} {172 115 84} {35 35 35}}
+test imgPhoto-4.23 {ImgPhotoCmd procedure: get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 get 256 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {photo1 get: coordinates out of range}
+test imgPhoto-4.24 {ImgPhotoCmd procedure: get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 get 0 -1
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {photo1 get: coordinates out of range}
+test imgPhoto-4.25 {ImgPhotoCmd procedure: get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 get
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 get x y"}
+test imgPhoto-4.26 {ImgPhotoCmd procedure: put option} -setup {
+ image create photo photo1
+} -body {
+ photo1 put
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 put data ?-option value ...?"}
+test imgPhoto-4.27 {ImgPhotoCmd procedure: put option} -setup {
+ image create photo photo1
+} -body {
+ photo1 put {{white} {white white}}
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {all elements of color list must have the same number of elements}
+test imgPhoto-4.28 {ImgPhotoCmd procedure: put option} -setup {
+ image create photo photo1
+} -body {
+ photo1 put {{blahgle}}
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {can't parse color "blahgle"}
+test imgPhoto-4.29 {ImgPhotoCmd procedure: put option} -setup {
+ image create photo photo1
+} -body {
+ photo1 put -to 10 10 20 20 {{white}}
+ photo1 get 19 19
+} -cleanup {
+ image delete photo1
+} -result {255 255 255}
+test imgPhoto-4.30 {ImgPhotoCmd procedure: read option} -setup {
+ image create photo photo1
+} -body {
+ photo1 read
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 read fileName ?-option value ...?"}
+test imgPhoto-4.31 {ImgPhotoCmd procedure: read option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+} -body {
+ photo1 read $teapotPhotoFile -zoom 2
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {unrecognized option "-zoom": must be -format, -from, -shrink, or -to}
+test imgPhoto-4.32 {ImgPhotoCmd procedure: read option} -setup {
+ image create photo photo1
+} -body {
+ list [catch {photo1 read bogus} err] [string tolower $err]
+} -cleanup {
+ image delete photo1
+} -result {1 {couldn't open "bogus": no such file or directory}}
+test imgPhoto-4.33 {ImgPhotoCmd procedure: read option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+} -body {
+ photo1 read $teapotPhotoFile -format bogus
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {image file format "bogus" is not supported}
+test imgPhoto-4.34 {ImgPhotoCmd procedure: read option} -setup {
+ image create photo photo1
+} -body {
+ photo1 read $README
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result [subst {couldn't recognize data in image file "$README"}]
+test imgPhoto-4.35 {ImgPhotoCmd procedure: read option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+} -body {
+ photo1 read $teapotPhotoFile
+ list [image width photo1] [image height photo1] [photo1 get 120 120]
+} -cleanup {
+ image delete photo1
+} -result {256 256 {161 109 82}}
+test imgPhoto-4.36 {ImgPhotoCmd procedure: read option} -constraints {
+ hasTeapotPhoto
+} -setup {
+ image create photo photo1
+} -body {
+ photo1 read $teapotPhotoFile -from 0 70 60 120 -to 10 10 -shrink
+ list [image width photo1] [image height photo1] [photo1 get 29 19]
+} -cleanup {
+ image delete photo1
+} -result {70 60 {244 180 144}}
+test imgPhoto-4.37 {ImgPhotoCmd procedure: redither option} -setup {
+ image create photo photo1
+} -body {
+ photo1 redither
+ photo1 redither x
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 redither"}
+test imgPhoto-4.38 {ImgPhotoCmd procedure: write option} -setup {
+ image create photo photo1
+} -body {
+ photo1 write
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 write fileName ?-option value ...?"}
+test imgPhoto-4.39 {ImgPhotoCmd procedure: write option} -setup {
+ image create photo photo1
+} -body {
+ photo1 write teapot.tmp -format bogus
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {image file format "bogus" is unknown}
+
+test imgPhoto-4.40 {ImgPhotoCmd procedure: transparency option} -setup {
+ image create photo photo1
+} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 transparency option ?arg ...?"}
+test imgPhoto-4.41 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency get
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 transparency get x y"}
+test imgPhoto-4.42 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency get 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 transparency get x y"}
+test imgPhoto-4.43 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency get 0 0 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 transparency get x y"}
+test imgPhoto-4.44 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency get bogus 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {expected integer but got "bogus"}
+test imgPhoto-4.45 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency get 0 bogus
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {expected integer but got "bogus"}
+test imgPhoto-4.46 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 put white
+ photo1 transparency get 0 0
+} -cleanup {
+ image delete photo1
+} -result 0
+test imgPhoto-4.47 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency get 1 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {photo1 transparency get: coordinates out of range}
+test imgPhoto-4.48 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency get -1 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {photo1 transparency get: coordinates out of range}
+test imgPhoto-4.49 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency get 0 1
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {photo1 transparency get: coordinates out of range}
+test imgPhoto-4.50 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency get 0 -1
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {photo1 transparency get: coordinates out of range}
+test imgPhoto-4.51 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 put white
+ photo1 blank
+ photo1 transparency get 0 0
+} -cleanup {
+ image delete photo1
+} -result 1
+test imgPhoto-4.52 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 transparency set x y boolean"}
+test imgPhoto-4.53 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 transparency set x y boolean"}
+test imgPhoto-4.54 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set 0 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 transparency set x y boolean"}
+test imgPhoto-4.55 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set 0 0 0 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {wrong # args: should be "photo1 transparency set x y boolean"}
+test imgPhoto-4.56 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set bogus 0 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {expected integer but got "bogus"}
+test imgPhoto-4.57 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set 0 bogus 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {expected integer but got "bogus"}
+test imgPhoto-4.58 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set 0 0 bogus
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {expected boolean value but got "bogus"}
+test imgPhoto-4.59 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set 1 0 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {photo1 transparency set: coordinates out of range}
+test imgPhoto-4.60 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set -1 0 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {photo1 transparency set: coordinates out of range}
+test imgPhoto-4.61 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set 0 1 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {photo1 transparency set: coordinates out of range}
+test imgPhoto-4.62 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 transparency set 0 -1 0
+} -cleanup {
+ image delete photo1
+} -returnCodes error -result {photo1 transparency set: coordinates out of range}
+test imgPhoto-4.63 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 put white
+ photo1 transparency set 0 0 false
+ photo1 transparency get 0 0
+} -cleanup {
+ image delete photo1
+} -result 0
+test imgPhoto-4.64 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ photo1 put white
+ photo1 transparency set 0 0 true
+ photo1 transparency get 0 0
+} -cleanup {
+ image delete photo1
+} -result 1
-eval image delete [image names]
-image create photo p1
-.c create image 10 10 -image p1
-update
-
-test imgPhoto-4.1 {ImgPhotoCmd procedure} {
- list [catch {p1} err] $err
-} {1 {wrong # args: should be "p1 option ?arg ...?"}}
-test imgPhoto-4.2 {ImgPhotoCmd procedure} {
- list [catch {p1 blah} err] $err
-} {1 {bad option "blah": must be blank, cget, configure, copy, data, get, put, read, redither, transparency, or write}}
-test imgPhoto-4.3 {ImgPhotoCmd procedure: blank option} {
- p1 blank
- list [catch {p1 blank x} err] $err
-} {1 {wrong # args: should be "p1 blank"}}
-test imgPhoto-4.4 {ImgPhotoCmd procedure: cget option} {
- list [catch {p1 cget} msg] $msg
-} {1 {wrong # args: should be "p1 cget option"}}
-test imgPhoto-4.5 {ImgPhotoCmd procedure: cget option} {
- image create photo p2 -width 25 -height 30
- list [p2 cget -width] [p2 cget -height]
-} {25 30}
-test imgPhoto-4.6 {ImgPhotoCmd procedure: configure option} {
- llength [p1 configure]
-} {7}
-test imgPhoto-4.7 {ImgPhotoCmd procedure: configure option} {
- p1 conf -palette 3/4/2
- p1 configure -palette
-} {-palette {} {} {} 3/4/2}
-test imgPhoto-4.8 {ImgPhotoCmd procedure: configure option} {
- list [catch {p1 configure -blah} msg] $msg
-} {1 {unknown option "-blah"}}
-test imgPhoto-4.9 {ImgPhotoCmd procedure: configure option} {
- list [catch {p1 configure -palette {} -gamma} msg] $msg
-} {1 {value for "-gamma" missing}}
-test imgPhoto-4.10 {ImgPhotoCmd procedure: copy option} hasTeapotPhoto {
- image create photo p2 -file $teapotPhotoFile
- p1 configure -width 0 -height 0 -palette {} -gamma 1
- p1 copy p2
- list [image width p1] [image height p1] [p1 get 100 100]
-} {256 256 {169 117 90}}
-test imgPhoto-4.11 {ImgPhotoCmd procedure: copy option} {
- list [catch {p1 copy} msg] $msg
-} {1 {wrong # args: should be "p1 copy source-image ?-compositingrule rule? ?-from x1 y1 x2 y2? ?-to x1 y1 x2 y2? ?-zoom x y? ?-subsample x y?"}}
-test imgPhoto-4.12 {ImgPhotoCmd procedure: copy option} {
- list [catch {p1 copy blah} msg] $msg
-} {1 {image "blah" doesn't exist or is not a photo image}}
-test imgPhoto-4.13 {ImgPhotoCmd procedure: copy option} {
- list [catch {p1 copy p2 -blah} msg] $msg
-} {1 {unrecognized option "-blah": must be -compositingrule, -from, -shrink, -subsample, -to, or -zoom}}
-test imgPhoto-4.14 {ImgPhotoCmd procedure: copy option} {
- list [catch {p1 copy p2 -from -to} msg] $msg
-} {1 {the "-from" option requires one to four integer values}}
-test imgPhoto-4.15 {ImgPhotoCmd procedure: copy option} {
- p1 copy p2
- p1 copy p2 -from 0 70 60 120 -shrink
- list [image width p1] [image height p1] [p1 get 20 10]
-} {60 50 {215 154 120}}
-test imgPhoto-4.16 {ImgPhotoCmd procedure: copy option} {
- p1 copy p2 -from 60 120 0 70 -to 20 50
- list [image width p1] [image height p1] [p1 get 40 80]
-} {80 100 {19 92 192}}
-test imgPhoto-4.17 {ImgPhotoCmd procedure: copy option} {
- p1 copy p2 -from 0 120 60 70 -to 0 0 100 100
- list [image width p1] [image height p1] [p1 get 80 60]
-} {100 100 {215 154 120}}
-test imgPhoto-4.18 {ImgPhotoCmd procedure: copy option} {
- p1 copy p2 -from 60 70 0 120 -zoom 2
- list [image width p1] [image height p1] [p1 get 100 50]
-} {120 100 {169 99 47}}
-test imgPhoto-4.19 {ImgPhotoCmd procedure: copy option} {
- p1 copy p2 -from 0 70 60 120
- list [image width p1] [image height p1] [p1 get 100 50]
-} {120 100 {169 99 47}}
-test imgPhoto-4.20 {ImgPhotoCmd procedure: copy option} {
- p1 copy p2 -from 20 20 200 180 -subsample 2 -shrink
- list [image width p1] [image height p1] [p1 get 50 30]
-} {90 80 {207 146 112}}
-test imgPhoto-4.21 {ImgPhotoCmd procedure: copy option} {
- p1 copy p2
- set result [list [image width p1] [image height p1]]
- p1 conf -width 49 -height 51
- lappend result [image width p1] [image height p1]
- p1 copy p2
- lappend result [image width p1] [image height p1]
- p1 copy p2 -from 0 0 10 10 -shrink
- lappend result [image width p1] [image height p1]
- p1 conf -width 0
- p1 copy p2 -from 0 0 10 10 -shrink
- lappend result [image width p1] [image height p1]
- p1 conf -height 0
- p1 copy p2 -from 0 0 10 10 -shrink
- lappend result [image width p1] [image height p1]
-} {256 256 49 51 49 51 49 51 10 51 10 10}
-test imgPhoto-4.22 {ImgPhotoCmd procedure: get option} hasTeapotPhoto {
- p1 read $teapotPhotoFile
- list [p1 get 100 100] [p1 get 150 100] [p1 get 100 150]
-} {{169 117 90} {172 115 84} {35 35 35}}
-test imgPhoto-4.23 {ImgPhotoCmd procedure: get option} {
- list [catch {p1 get 256 0} err] $err
-} {1 {p1 get: coordinates out of range}}
-test imgPhoto-4.24 {ImgPhotoCmd procedure: get option} {
- list [catch {p1 get 0 -1} err] $err
-} {1 {p1 get: coordinates out of range}}
-test imgPhoto-4.25 {ImgPhotoCmd procedure: get option} {
- list [catch {p1 get} err] $err
-} {1 {wrong # args: should be "p1 get x y"}}
-test imgPhoto-4.26 {ImgPhotoCmd procedure: put option} {
- list [catch {p1 put} err] $err
-} {1 {wrong # args: should be "p1 put data ?-option value ...?"}}
-test imgPhoto-4.27 {ImgPhotoCmd procedure: put option} {
- list [catch {p1 put {{white} {white white}}} err] $err
-} {1 {all elements of color list must have the same number of elements}}
-test imgPhoto-4.28 {ImgPhotoCmd procedure: put option} {
- list [catch {p1 put {{blahgle}}} err] $err
-} {1 {can't parse color "blahgle"}}
-test imgPhoto-4.29 {ImgPhotoCmd procedure: put option} {
- p1 put -to 10 10 20 20 {{white}}
- p1 get 19 19
-} {255 255 255}
-test imgPhoto-4.30 {ImgPhotoCmd procedure: read option} {
- list [catch {p1 read} err] $err
-} {1 {wrong # args: should be "p1 read fileName ?-option value ...?"}}
-test imgPhoto-4.31 {ImgPhotoCmd procedure: read option} hasTeapotPhoto {
- list [catch {p1 read $teapotPhotoFile -zoom 2} err] $err
-} {1 {unrecognized option "-zoom": must be -format, -from, -shrink, or -to}}
-test imgPhoto-4.32 {ImgPhotoCmd procedure: read option} {
- list [catch {p1 read bogus} err] [string tolower $err]
-} {1 {couldn't open "bogus": no such file or directory}}
-test imgPhoto-4.33 {ImgPhotoCmd procedure: read option} hasTeapotPhoto {
- list [catch {p1 read $teapotPhotoFile -format bogus} err] $err
-} {1 {image file format "bogus" is not supported}}
-test imgPhoto-4.34 {ImgPhotoCmd procedure: read option} {
- list [catch {p1 read $README} err] $err
-} [subst {1 {couldn't recognize data in image file "$README"}}]
-test imgPhoto-4.35 {ImgPhotoCmd procedure: read option} hasTeapotPhoto {
- p1 read $teapotPhotoFile
- list [image width p1] [image height p1] [p1 get 120 120]
-} {256 256 {161 109 82}}
-test imgPhoto-4.36 {ImgPhotoCmd procedure: read option} hasTeapotPhoto {
- p1 read $teapotPhotoFile -from 0 70 60 120 -to 10 10 -shrink
- list [image width p1] [image height p1] [p1 get 29 19]
-} {70 60 {244 180 144}}
-test imgPhoto-4.37 {ImgPhotoCmd procedure: redither option} {
- p1 redither
- list [catch {p1 redither x} err] $err
-} {1 {wrong # args: should be "p1 redither"}}
-test imgPhoto-4.38 {ImgPhotoCmd procedure: write option} {
- list [catch {p1 write} err] $err
-} {1 {wrong # args: should be "p1 write fileName ?-option value ...?"}}
-test imgPhoto-4.39 {ImgPhotoCmd procedure: write option} {
- list [catch {p1 write teapot.tmp -format bogus} err] $err
-} {1 {image file format "bogus" is unknown}}
-eval image delete [image names]
-image create photo p1
-test imgPhoto-4.40 {ImgPhotoCmd procedure: transparency option} {
- list [catch {p1 transparency} err] $err
-} {1 {wrong # args: should be "p1 transparency option ?arg ...?"}}
-test imgPhoto-4.41 {ImgPhotoCmd procedure: transparency get option} {
- list [catch {p1 transparency get} err] $err
-} {1 {wrong # args: should be "p1 transparency get x y"}}
-test imgPhoto-4.42 {ImgPhotoCmd procedure: transparency get option} {
- list [catch {p1 transparency get 0} err] $err
-} {1 {wrong # args: should be "p1 transparency get x y"}}
-test imgPhoto-4.43 {ImgPhotoCmd procedure: transparency get option} {
- list [catch {p1 transparency get 0 0 0} err] $err
-} {1 {wrong # args: should be "p1 transparency get x y"}}
-test imgPhoto-4.44 {ImgPhotoCmd procedure: transparency get option} {
- list [catch {p1 transparency get bogus 0} err] $err
-} {1 {expected integer but got "bogus"}}
-test imgPhoto-4.45 {ImgPhotoCmd procedure: transparency get option} {
- list [catch {p1 transparency get 0 bogus} err] $err
-} {1 {expected integer but got "bogus"}}
-test imgPhoto-4.46 {ImgPhotoCmd procedure: transparency get option} {
- p1 put white
- p1 transparency get 0 0
-} 0
-test imgPhoto-4.47 {ImgPhotoCmd procedure: transparency get option} {
- list [catch {p1 transparency get 1 0} err] $err
-} {1 {p1 transparency get: coordinates out of range}}
-test imgPhoto-4.48 {ImgPhotoCmd procedure: transparency get option} {
- list [catch {p1 transparency get -1 0} err] $err
-} {1 {p1 transparency get: coordinates out of range}}
-test imgPhoto-4.49 {ImgPhotoCmd procedure: transparency get option} {
- list [catch {p1 transparency get 0 1} err] $err
-} {1 {p1 transparency get: coordinates out of range}}
-test imgPhoto-4.50 {ImgPhotoCmd procedure: transparency get option} {
- list [catch {p1 transparency get 0 -1} err] $err
-} {1 {p1 transparency get: coordinates out of range}}
-test imgPhoto-4.51 {ImgPhotoCmd procedure: transparency get option} {
- p1 blank
- p1 transparency get 0 0
-} 1
-test imgPhoto-4.52 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set} err] $err
-} {1 {wrong # args: should be "p1 transparency set x y boolean"}}
-test imgPhoto-4.53 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set 0} err] $err
-} {1 {wrong # args: should be "p1 transparency set x y boolean"}}
-test imgPhoto-4.54 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set 0 0} err] $err
-} {1 {wrong # args: should be "p1 transparency set x y boolean"}}
-test imgPhoto-4.55 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set 0 0 0 0} err] $err
-} {1 {wrong # args: should be "p1 transparency set x y boolean"}}
-test imgPhoto-4.56 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set bogus 0 0} err] $err
-} {1 {expected integer but got "bogus"}}
-test imgPhoto-4.57 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set 0 bogus 0} err] $err
-} {1 {expected integer but got "bogus"}}
-test imgPhoto-4.58 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set 0 0 bogus} err] $err
-} {1 {expected boolean value but got "bogus"}}
-test imgPhoto-4.59 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set 1 0 0} err] $err
-} {1 {p1 transparency set: coordinates out of range}}
-test imgPhoto-4.60 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set -1 0 0} err] $err
-} {1 {p1 transparency set: coordinates out of range}}
-test imgPhoto-4.61 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set 0 1 0} err] $err
-} {1 {p1 transparency set: coordinates out of range}}
-test imgPhoto-4.62 {ImgPhotoCmd procedure: transparency set option} {
- list [catch {p1 transparency set 0 -1 0} err] $err
-} {1 {p1 transparency set: coordinates out of range}}
-test imgPhoto-4.63 {ImgPhotoCmd procedure: transparency set option} {
- p1 transparency set 0 0 false
- p1 transparency get 0 0
-} 0
-test imgPhoto-4.64 {ImgPhotoCmd procedure: transparency set option} {
- p1 transparency set 0 0 true
- p1 transparency get 0 0
-} 1
# Now for some heftier testing, checking that setting and resetting of
# pixels' transparency status doesn't "leak" with any one-off errors.
-proc checkImgTrans {img width height} {
- set result {}
- for {set x 0} {$x<$width} {incr x} {
- for {set y 0} {$y<$height} {incr y} {
- if {[$img transparency get $x $y]} {
- lappend result $x $y
- }
- }
- }
- return $result
-}
-test imgPhoto-4.65 {ImgPhotoCmd procedure: transparency get option} {
- p1 put white -to 0 0 3 3
- checkImgTrans p1 3 3
-} {}
-test imgPhoto-4.66 {ImgPhotoCmd procedure: transparency get option} {
- p1 blank
- checkImgTrans p1 3 3
-} {0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2}
-proc checkImgTransLoopSetReset {img width height} {
- set result {}
- for {set x 0} {$x<$width} {incr x} {
- for {set y 0} {$y<$height} {incr y} {
- $img put white -to 0 0 3 3
- $img transparency set $x $y 1
- set result [concat $result [checkImgTrans $img $width $height]]
- lappend result ,
- $img transparency set $x $y 0
- set result [concat $result [checkImgTrans $img $width $height]]
- lappend result .
- }
+test imgPhoto-4.65 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 put white -to 0 0 3 3
+ checkImgTrans photo1 3 3
+} -cleanup {
+ image delete photo1
+} -result {}
+test imgPhoto-4.66 {ImgPhotoCmd procedure: transparency get option} -setup {
+ image create photo photo1
+} -body {
+ photo1 put white -to 0 0 3 3
+ photo1 blank
+ checkImgTrans photo1 3 3
+v -result {0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2}
+
+test imgPhoto-4.67 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ proc checkImgTransLoopSetReset {img width height} {
+ set result {}
+ for {set x 0} {$x<$width} {incr x} {
+ for {set y 0} {$y<$height} {incr y} {
+ $img put white -to 0 0 3 3
+ $img transparency set $x $y 1
+ set result [concat $result [checkImgTrans $img $width $height]]
+ lappend result ,
+ $img transparency set $x $y 0
+ set result [concat $result [checkImgTrans $img $width $height]]
+ lappend result .
+ }
+ }
+ return $result
}
- return $result
-}
-test imgPhoto-4.67 {ImgPhotoCmd procedure: transparency set option} {
- checkImgTransLoopSetReset p1 3 3
-} {0 0 , . 0 1 , . 0 2 , . 1 0 , . 1 1 , . 1 2 , . 2 0 , . 2 1 , . 2 2 , .}
-proc checkImgTransLoopResetSet {img width height} {
- set result {}
- for {set x 0} {$x<$width} {incr x} {
- for {set y 0} {$y<$height} {incr y} {
- $img blank
- $img transparency set $x $y 0
- set result [concat $result [checkImgTrans $img $width $height]]
- lappend result ,
- $img transparency set $x $y 1
- set result [concat $result [checkImgTrans $img $width $height]]
- lappend result .
- }
+
+ photo1 put white -to 0 0 3 3
+ checkImgTransLoopSetReset photo1 3 3
+} -cleanup {
+ rename checkImgTransLoopSetReset {}
+ image delete photo1
+} -result {0 0 , . 0 1 , . 0 2 , . 1 0 , . 1 1 , . 1 2 , . 2 0 , . 2 1 , . 2 2 , .}
+
+test imgPhoto-4.68 {ImgPhotoCmd procedure: transparency set option} -setup {
+ image create photo photo1
+} -body {
+ proc checkImgTransLoopResetSet {img width height} {
+ set result {}
+ for {set x 0} {$x<$width} {incr x} {
+ for {set y 0} {$y<$height} {incr y} {
+ $img blank
+ $img transparency set $x $y 0
+ set result [concat $result [checkImgTrans $img $width $height]]
+ lappend result ,
+ $img transparency set $x $y 1
+ set result [concat $result [checkImgTrans $img $width $height]]
+ lappend result .
+ }
+ }
+ return $result
}
- return $result
-}
-test imgPhoto-4.67a {ImgPhotoCmd procedure: transparency set option} {
- checkImgTransLoopResetSet p1 3 3
-} {0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 2 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 .}
-catch {rename checkImgTransLoopSetReset {}}
-catch {rename checkImgTransLoopResetSet {}}
-# Test the compositing rules for copying images
-image create photo p1 -width 3 -height 3
-image create photo p2 -width 2 -height 2
-test imgPhoto-4.68 {ImgPhotoCmd procedure: copy with -compositingrule} {
- list [catch {p1 copy p2 -to 1 1 -compositingrule} msg] $msg
-} {1 {the "-compositingrule" option requires a value}}
-test imgPhoto-4.69 {ImgPhotoCmd procedure: copy with -compositingrule} {
- list [catch {p1 copy p2 -to 1 1 -compositingrule BAD} msg] $msg
-} {1 {bad compositing rule "BAD": must be overlay or set}}
-test imgPhoto-4.70 {ImgPhotoCmd procedure: copy with -compositingrule} {
+
+ photo1 put white -to 0 0 3 3
+ checkImgTransLoopResetSet photo1 3 3
+} -cleanup {
+ catch {rename checkImgTransLoopResetSet {}}
+ image delete photo1
+} -result {0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 2 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 .}
+
+test imgPhoto-4.69 {ImgPhotoCmd procedure: copy with -compositingrule} -setup {
+ # Test the compositing rules for copying images
+ image create photo photo1 -width 3 -height 3
+ image create photo photo2 -width 2 -height 2
+} -body {
+ photo1 copy photo2 -to 1 1 -compositingrule
+} -cleanup {
+ image delete photo1 photo2
+} -returnCodes error -result {the "-compositingrule" option requires a value}
+test imgPhoto-4.70 {ImgPhotoCmd procedure: copy with -compositingrule} -setup {
+ # Test the compositing rules for copying images
+ image create photo photo1 -width 3 -height 3
+ image create photo photo2 -width 2 -height 2
+} -body {
+ photo1 copy photo2 -to 1 1 -compositingrule BAD
+} -cleanup {
+ image delete photo1 photo2
+} -returnCodes error -result {bad compositing rule "BAD": must be overlay or set}
+test imgPhoto-4.71 {ImgPhotoCmd procedure: copy with -compositingrule} -setup {
+ # Test the compositing rules for copying images
+ image create photo photo1 -width 3 -height 3
+ image create photo photo2 -width 2 -height 2
+} -body {
# Tests default compositing rule
- p1 blank
- p2 blank
- p1 put white -to 0 0 2 2
- p2 put white -to 0 0 2 2
- p2 transparency set 0 0 true
- p1 copy p2 -to 1 1
- checkImgTrans p1 3 3
-} {0 2 2 0}
-test imgPhoto-4.71 {ImgPhotoCmd procedure: copy with -compositingrule} {
- p1 blank
- p2 blank
- p1 put white -to 0 0 2 2
- p2 put white -to 0 0 2 2
- p2 transparency set 0 0 true
- p1 copy p2 -to 1 1 -compositingrule overlay
- checkImgTrans p1 3 3
-} {0 2 2 0}
-test imgPhoto-4.72 {ImgPhotoCmd procedure: copy with -compositingrule} {
- p1 blank
- p2 blank
- p1 put white -to 0 0 2 2
- p2 put white -to 0 0 2 2
- p2 transparency set 0 0 true
- p1 copy p2 -to 1 1 -compositingrule set
- checkImgTrans p1 3 3
-} {0 2 1 1 2 0}
-catch {rename checkImgTrans {}}
+ photo1 blank
+ photo2 blank
+ photo1 put white -to 0 0 2 2
+ photo2 put white -to 0 0 2 2
+ photo2 transparency set 0 0 true
+ photo1 copy photo2 -to 1 1
+ checkImgTrans photo1 3 3
+} -cleanup {
+ image delete photo1 photo2
+} -result {0 2 2 0}
+test imgPhoto-4.72 {ImgPhotoCmd procedure: copy with -compositingrule} -setup {
+ # Test the compositing rules for copying images
+ image create photo photo1 -width 3 -height 3
+ image create photo photo2 -width 2 -height 2
+} -body {
+ photo1 blank
+ photo2 blank
+ photo1 put white -to 0 0 2 2
+ photo2 put white -to 0 0 2 2
+ photo2 transparency set 0 0 true
+ photo1 copy photo2 -to 1 1 -compositingrule overlay
+ checkImgTrans photo1 3 3
+} -cleanup {
+ image delete photo1 photo2
+} -result {0 2 2 0}
+test imgPhoto-4.73 {ImgPhotoCmd procedure: copy with -compositingrule} -setup {
+ # Test the compositing rules for copying images
+ image create photo photo1 -width 3 -height 3
+ image create photo photo2 -width 2 -height 2
+} -body {
+ photo1 blank
+ photo2 blank
+ photo1 put white -to 0 0 2 2
+ photo2 put white -to 0 0 2 2
+ photo2 transparency set 0 0 true
+ photo1 copy photo2 -to 1 1 -compositingrule set
+ checkImgTrans photo1 3 3
+} -cleanup {
+ image delete photo1 photo2
+} -result {0 2 1 1 2 0}
+
-test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} hasTeapotPhoto {
+test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} -constraints {
+ hasTeapotPhoto
+} -setup {
+ destroy .c
+ pack [canvas .c]
eval image delete [image names]
- .c delete all
- image create photo p1 -file $teapotPhotoFile
- .c create image 0 0 -image p1 -tags p1.1
- .c create image 256 0 -image p1 -tags p1.2
- .c create image 0 256 -image p1 -tags p1.3
+} -body {
+ image create photo photo1 -file $teapotPhotoFile
+ .c create image 0 0 -image photo1 -tags photo1.1
+ .c create image 256 0 -image photo1 -tags photo1.2
+ .c create image 0 256 -image photo1 -tags photo1.3
update
.c delete i1.1
- p1 configure -width 1
+ photo1 configure -width 1
update
.c delete i1.2
- p1 configure -height 1
+ photo1 configure -height 1
update
- image delete p1
-} {}
+ image delete photo1
+} -cleanup {
+ destroy .c
+} -result {}
-test imgPhoto-6.1 {ImgPhotoDisplay procedure, blank display} {
- .c delete all
- image create photo p1 -width 10 -height 10
- p1 blank
- .c create image 10 10 -image p1
+
+test imgPhoto-6.1 {ImgPhotoDisplay procedure, blank display} } -setup {
+ destroy .c
+ pack [canvas .c]
+ eval image delete [image names]
+} -body {
+ image create photo photo1 -width 10 -height 10
+ photo1 blank
+ .c create image 10 10 -image photo1
update
-} {}
+} -cleanup {
+ destroy .c
+ image delete photo1
+} -result {}
-test imgPhoto-7.1 {ImgPhotoFree procedure, resource freeing} hasTeapotPhoto {
+
+test imgPhoto-7.1 {ImgPhotoFree procedure, resource freeing} -constraints {
+ hasTeapotPhoto
+} -setup {
+ destroy .c
+ pack [canvas .c]
eval image delete [image names]
- .c delete all
- image create photo p1 -file $teapotPhotoFile
- .c create image 0 0 -image p1 -anchor nw
+} -body {
+ image create photo photo1 -file $teapotPhotoFile
+ .c create image 0 0 -image photo1 -anchor nw
update
.c delete all
- image delete p1
-} {}
-test imgPhoto-7.2 {ImgPhotoFree procedures, unlinking} hasTeapotPhoto {
- image create photo p1 -file $teapotPhotoFile
- .c create image 10 10 -image p1 -anchor nw
- button .b1 -image p1
- button .b2 -image p1
- button .b3 -image p1
+ image delete photo1
+} -cleanup {
+ destroy .c
+} -result {}
+test imgPhoto-7.2 {ImgPhotoFree procedures, unlinking} -constraints {
+ hasTeapotPhoto
+} -setup {
+ deleteWindows
+ eval image delete [image names]
+} -body {
+ image create photo photo1 -file $teapotPhotoFile
+ pack [canvas .c]
+ .c create image 10 10 -image photo1 -anchor nw
+ button .b1 -image photo1
+ button .b2 -image photo1
+ button .b3 -image photo1
pack .b1 .b2 .b3
update
destroy .b2
@@ -492,12 +886,20 @@ test imgPhoto-7.2 {ImgPhotoFree procedures, unlinking} hasTeapotPhoto {
destroy .b1
update
.c delete all
-} {}
-test imgPhoto-7.3 {ImgPhotoFree procedures, multiple visuals} hasTeapotPhoto {
- image create photo p1 -file $teapotPhotoFile
- button .b1 -image p1
+} -cleanup {
+ destroy .c
+ image delete photo1
+} -result {}
+test imgPhoto-7.3 {ImgPhotoFree procedures, multiple visuals} -constraints {
+ hasTeapotPhoto
+} -setup {
+ deleteWindows
+ eval image delete [image names]
+} -body {
+ image create photo photo1 -file $teapotPhotoFile
+ button .b1 -image photo1
frame .f -visual best
- button .f.b2 -image p1
+ button .f.b2 -image photo1
pack .f.b2
pack .b1 .f
update
@@ -506,58 +908,74 @@ test imgPhoto-7.3 {ImgPhotoFree procedures, multiple visuals} hasTeapotPhoto {
.f.b2 configure -image {}
update
destroy .f
- image delete p1
-} {}
-
-test imgPhoto-8.1 {ImgPhotoDelete procedure} hasTeapotPhoto {
- image create photo p2 -file $teapotPhotoFile
- image delete p2
-} {}
-test imagePhoto-8.2 {ImgPhotoDelete procedure} hasTeapotPhoto {
- image create photo p2 -file $teapotPhotoFile
- rename p2 newp2
- set x [list [info command p2] [info command new*] [newp2 cget -file]]
- image delete p2
+ image delete photo1
+} -result {}
+
+
+test imgPhoto-8.1 {ImgPhotoDelete procedure} -constraints hasTeapotPhoto -body {
+ image create photo photo2 -file $teapotPhotoFile
+ image delete photo2
+} -result {}
+test imgPhoto-8.2 {ImgPhotoDelete procedure} -constraints {
+ hasTeapotPhoto
+} -body {
+ image create photo photo2 -file $teapotPhotoFile
+ rename photo2 newphoto2
+ set x [list [info command photo2] [info command new*] [newphoto2 cget -file]]
+ image delete photo2
append x [info command new*]
-} [list {} newp2 $teapotPhotoFile]
-test imagePhoto-8.3 {ImgPhotoDelete procedure, name cleanup} {
- image create photo p1
- image create photo p2 -width 10 -height 10
- image delete p2
- list [catch {p1 copy p2} msg] $msg
-} {1 {image "p2" doesn't exist or is not a photo image}}
-
-test imagePhoto-9.1 {ImgPhotoCmdDeletedProc procedure} hasTeapotPhoto {
- image create photo p2 -file $teapotPhotoFile
- rename p2 {}
- list [lsearch -exact [image names] p2] [catch {p2 foo} msg] $msg
-} {-1 1 {invalid command name "p2"}}
-
-test imgPhoto-10.1 {Tk_ImgPhotoPutBlock procedure} {
+} -result [list {} newphoto2 $teapotPhotoFile]
+test imgPhoto-8.3 {ImgPhotoDelete procedure, name cleanup} -body {
+ image create photo photo1
+ image create photo photo2 -width 10 -height 10
+ image delete photo2
+ photo1 copy photo2
+} -cleanup {
eval image delete [image names]
- image create photo p1
- p1 put {{#ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000}} -to 0 0
- p1 put {{#00ff00 #00ff00}} -to 2 0
- list [p1 get 2 0] [p1 get 3 0] [p1 get 4 0]
-} {{0 255 0} {0 255 0} {255 0 0}}
+} -returnCodes error -result {image "photo2" doesn't exist or is not a photo image}
+
+
+test imgPhoto-9.1 {ImgPhotoCmdDeletedProc procedure} -constraints {
+ hasTeapotPhoto
+} -body {
+ image create photo photo2 -file $teapotPhotoFile
+ rename photo2 {}
+ list [lsearch -exact [image names] photo2] [catch {photo2 foo} msg] $msg
+} -result {-1 1 {invalid command name "photo2"}}
-test imgPhoto-11.1 {Tk_FindPhoto} {
+
+test imgPhoto-10.1 {Tk_ImgPhotoPutBlock procedure} -setup {
+ eval image delete [image names]
+} -body {
+ image create photo photo1
+ photo1 put {{#ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000}} -to 0 0
+ photo1 put {{#00ff00 #00ff00}} -to 2 0
+ list [photo1 get 2 0] [photo1 get 3 0] [photo1 get 4 0]
+} -result {{0 255 0} {0 255 0} {255 0 0}}
+
+
+test imgPhoto-11.1 {Tk_FindPhoto} -setup {
eval image delete [image names]
+} -body {
image create bitmap i1
- image create photo p1
- list [catch {p1 copy i1} msg] $msg
-} {1 {image "i1" doesn't exist or is not a photo image}}
+ image create photo photo1
+ photo1 copy i1
+} -cleanup {
+ eval image delete [image names]
+} -returnCodes error -result {image "i1" doesn't exist or is not a photo image}
-test imgPhoto-12.1 {Tk_PhotoPutZoomedBlock} hasTeapotPhoto {
+
+test imgPhoto-12.1 {Tk_PhotoPutZoomedBlock} -constraints hasTeapotPhoto -body {
image create photo p3 -file $teapotPhotoFile
set result [list [p3 get 50 50] [p3 get 100 100]]
p3 copy p3 -zoom 2
lappend result [image width p3] [image height p3] [p3 get 100 100]
image delete p3
set result
-} {{19 92 192} {169 117 90} 512 512 {19 92 192}}
+} -result {{19 92 192} {169 117 90} 512 512 {19 92 192}}
+
-test imgPhoto-13.1 {check separation of images in different interpreters} {
+test imgPhoto-13.1 {check separation of images in different interpreters} -body {
image delete {*}[image names]
set data {
R0lGODlhQgBkAPUAANbWxs7Wxs7OxsbOxsbGxsbGvb3Gvca9vcDAwL21vbW1vbW1tbWtta2t
@@ -599,9 +1017,10 @@ test imgPhoto-13.1 {check separation of images in different interpreters} {
unset data
interp delete x1
interp delete x2
-} {}
+} -result {}
-test imgPhoto-14.1 {GIF writes work correctly} {
+
+test imgPhoto-14.1 {GIF writes work correctly} -body {
set data "R0lGODlhYwA5APcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgAysnGy8hKzM
hASs3MTcjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@@ -632,14 +1051,12 @@ hciva9/Ovbv37+BzBgEEADs=
removeFile imgPhoto-14.1.gif
$photo write $filename -format gif
set photo2 [image create photo -file $filename]
- set result [string equal [$photo data] [$photo2 data]]
+ string equal [$photo data] [$photo2 data]
+} -cleanup {
image delete $photo $photo2
catch {file delete -force $filename}
- set result
-} 1
-test imgPhoto-14.2 {GIF -index handler buffer sizing} -setup {
- set i [image create photo]
-} -body {
+} -result 1
+test imgPhoto-14.2 {GIF -index handler buffer sizing} -body {
# Bug 1458234 makes this crash when trying to access buffers of the
# wrong size, caused when the initial frame is not the largest frame.
set data {
@@ -648,16 +1065,19 @@ test imgPhoto-14.2 {GIF -index handler buffer sizing} -setup {
LAMAAwAaABoAAAI0jH+gq+gfmFzQzUsr3gBybn1gIm5kaUaoubbuC8fyTNel
Ohv1CSO533u8KrgbUfc5Ci/EAgA7
}
+ set i [image create photo]
+
$i configure -data $data -format {gif -index 2}
} -cleanup {
image delete $i
} -returnCodes error -result {no image data for this index}
-test imgPhoto-14.3 {GIF -index interleaving and small frames} -setup {
- set i [image create photo]
-} -body {
+
+test imgPhoto-14.3 {GIF -index interleaving and small frames} -body {
# Interleaved GIFs used to crash us when a smaller subsequent frame
# was accessed.
+ set i [image create photo]
+
$i configure -format {GIF -index 1} -data {
R0lGODdhAQAFAPAAAP8AAAAAACwAAAAAAQAFAEACAoRdACwAAAAAAQAEAEACAoRRADs=
}
@@ -665,10 +1085,9 @@ test imgPhoto-14.3 {GIF -index interleaving and small frames} -setup {
image delete $i
}
-test imgPhoto-14.4 {GIF buffer overflow} -setup {
- set i [image create photo]
-} -body {
+test imgPhoto-14.4 {GIF buffer overflow} -body {
# This crashes Tk up to 8.4.17 and 8.5.0
+ set i [image create photo]
$i configure -data {
R0lGODlhCgAKAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/
AP//AAAA//8A/wD//////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@@ -694,25 +1113,30 @@ test imgPhoto-14.4 {GIF buffer overflow} -setup {
image delete $i
} -returnCodes error -result {malformed image}
-test imgPhoto-15.1 {photo images can fail to allocate memory gracefully} \
- {nonPortable} {
+
+test imgPhoto-15.1 {photo images can fail to allocate memory gracefully} -constraints {
+ nonPortable
+} -body {
# This is not portable to very large machines with more around
# 3GB of free memory available...
- list [catch {image create photo -width 32000 -height 32000} msg] $msg
-} {1 {not enough free memory for image buffer}}
+ image create photo -width 32000 -height 32000
+} -returnCodes error -result {not enough free memory for image buffer}
+
-test imgPhoto-16.1 {copying to self doesn't access freed memory} {
+test imgPhoto-16.1 {copying to self doesn't access freed memory} -body {
# Bug 877950 makes this crash when trying to copy out of a deallocated area
set i [image create photo]
$i put red -to 0 0 1000 1000
$i copy $i -from 0 0 1000 1000 -to 500 0
image delete $i
-} {}
+} -result {}
-destroy .c
+catch {rename checkImgTrans {}}
eval image delete [image names]
# cleanup
removeFile README-imgPhoto
cleanupTests
return
+
+
diff --git a/tests/listbox.test b/tests/listbox.test
index a6ba719..bb6a00f 100644
--- a/tests/listbox.test
+++ b/tests/listbox.test
@@ -6,11 +6,12 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: listbox.test,v 1.31 2008/07/26 13:32:44 patthoyts Exp $
+# RCS: @(#) $Id: listbox.test,v 1.32 2008/08/17 19:40:33 aniap Exp $
-package require tcltest 2.1
+package require tcltest 2.2
eval tcltest::configure $argv
tcltest::loadTestedCommands
+namespace import -force tcltest::test
set fixed {Courier -12}
@@ -41,7 +42,7 @@ proc resetGridInfo {} {
# to partially visible lines.
proc mkPartial {{w .partial}} {
- catch {destroy $w}
+ destroy $w
toplevel $w
wm geometry $w +0+0
listbox $w.l -width 30 -height 5
@@ -61,128 +62,332 @@ option add *Listbox.borderWidth 2
option add *Listbox.highlightThickness 2
option add *Listbox.font {Helvetica -12 bold}
+# Listbox used in 3.* configuration options tests
listbox .l
pack .l
update
resetGridInfo
-set i 1
-
-foreach test {
- {-activestyle under underline foo {bad activestyle "foo": must be dotbox, none, or underline}}
- {-background #ff0000 #ff0000 non-existent
- {unknown color name "non-existent"}}
- {-bd 4 4 badValue {bad screen distance "badValue"}}
- {-bg #ff0000 #ff0000 non-existent {unknown color name "non-existent"}}
- {-borderwidth 1.3 1 badValue {bad screen distance "badValue"}}
- {-cursor arrow arrow badValue {bad cursor spec "badValue"}}
- {-disabledforeground #110022 #110022 bogus {unknown color name "bogus"}}
- {-exportselection yes 1 xyzzy {expected boolean value but got "xyzzy"}}
- {-fg #110022 #110022 bogus {unknown color name "bogus"}}
- {-font {Helvetica 12} {Helvetica 12} {} {font "" doesn't exist}}
- {-foreground #110022 #110022 bogus {unknown color name "bogus"}}
- {-height 30 30 20p {expected integer but got "20p"}}
- {-highlightbackground #112233 #112233 ugly {unknown color name "ugly"}}
- {-highlightcolor #123456 #123456 bogus {unknown color name "bogus"}}
- {-highlightthickness 6 6 bogus {bad screen distance "bogus"}}
- {-highlightthickness -2 0 {} {}}
- {-relief groove groove 1.5 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}}
- {-selectbackground #110022 #110022 bogus {unknown color name "bogus"}}
- {-selectborderwidth 1.3 1 badValue {bad screen distance "badValue"}}
- {-selectforeground #654321 #654321 bogus {unknown color name "bogus"}}
- {-selectmode string string {} {}}
- {-setgrid false 0 lousy {expected boolean value but got "lousy"}}
- {-state disabled disabled foo {bad state "foo": must be disabled or normal}}
- {-takefocus "any string" "any string" {} {}}
- {-width 45 45 3p {expected integer but got "3p"}}
- {-xscrollcommand {Some command} {Some command} {} {}}
- {-yscrollcommand {Another command} {Another command} {} {}}
- {-listvar testVariable testVariable {} {}}
-} {
- set name [lindex $test 0]
- test listbox-1.$i {configuration options} {
- .l configure $name [lindex $test 1]
- list [lindex [.l configure $name] 4] [.l cget $name]
- } [list [lindex $test 2] [lindex $test 2]]
- incr i
- if {[lindex $test 3] != ""} {
- test listbox-1.$i {configuration options} {
- list [catch {.l configure $name [lindex $test 3]} msg] $msg
- } [list 1 [lindex $test 4]]
- }
- .l configure $name [lindex [.l configure $name] 3]
- incr i
-}
+test listbox-1.1 {configuration options} -body {
+ .l configure -activestyle under
+ list [lindex [.l configure -activestyle] 4] [.l cget -activestyle]
+} -cleanup {
+ .l configure -activestyle [lindex [.l configure -activestyle] 3]
+} -result {underline underline}
+test listbox-1.2 {configuration options} -body {
+ .l configure -activestyle foo
+} -returnCodes error -result {bad activestyle "foo": must be dotbox, none, or underline}
+test listbox-1.3 {configuration options} -body {
+ .l configure -background #ff0000
+ list [lindex [.l configure -background] 4] [.l cget -background]
+} -cleanup {
+ .l configure -background [lindex [.l configure -background] 3]
+} -result {{#ff0000} #ff0000}
+test listbox-1.4 {configuration options} -body {
+ .l configure -background non-existent
+} -returnCodes error -result {unknown color name "non-existent"}
+test listbox-1.5 {configuration options} -body {
+ .l configure -bd 4
+ list [lindex [.l configure -bd] 4] [.l cget -bd]
+} -cleanup {
+ .l configure -bd [lindex [.l configure -bd] 3]
+} -result {4 4}
+test listbox-1.6 {configuration options} -body {
+ .l configure -bd badValue
+} -returnCodes error -result {bad screen distance "badValue"}
+test listbox-1.7 {configuration options} -body {
+ .l configure -bg #ff0000
+ list [lindex [.l configure -bg] 4] [.l cget -bg]
+} -cleanup {
+ .l configure -bg [lindex [.l configure -bg] 3]
+} -result {{#ff0000} #ff0000}
+test listbox-1.8 {configuration options} -body {
+ .l configure -bg non-existent
+} -returnCodes error -result {unknown color name "non-existent"}
+test listbox-1.9 {configuration options} -body {
+ .l configure -borderwidth 1.3
+ list [lindex [.l configure -borderwidth] 4] [.l cget -borderwidth]
+} -cleanup {
+ .l configure -borderwidth [lindex [.l configure -borderwidth] 3]
+} -result {1 1}
+test listbox-1.10 {configuration options} -body {
+ .l configure -borderwidth badValue
+} -returnCodes error -result {bad screen distance "badValue"}
+test listbox-1.11 {configuration options} -body {
+ .l configure -cursor arrow
+ list [lindex [.l configure -cursor] 4] [.l cget -cursor]
+} -cleanup {
+ .l configure -cursor [lindex [.l configure -cursor] 3]
+} -result {arrow arrow}
+test listbox-1.12 {configuration options} -body {
+ .l configure -cursor badValue
+} -returnCodes error -result {bad cursor spec "badValue"}
+test listbox-1.13 {configuration options} -body {
+ .l configure -disabledforeground #110022
+ list [lindex [.l configure -disabledforeground] 4] [.l cget -disabledforeground]
+} -cleanup {
+ .l configure -disabledforeground [lindex [.l configure -disabledforeground] 3]
+} -result {{#110022} #110022}
+test listbox-1.14 {configuration options} -body {
+ .l configure -disabledforeground bogus
+} -returnCodes error -result {unknown color name "bogus"}
+test listbox-1.15 {configuration options} -body {
+ .l configure -exportselection yes
+ list [lindex [.l configure -exportselection] 4] [.l cget -exportselection]
+} -cleanup {
+ .l configure -exportselection [lindex [.l configure -exportselection] 3]
+} -result {1 1}
+test listbox-1.16 {configuration options} -body {
+ .l configure -exportselection xyzzy
+} -returnCodes error -result {expected boolean value but got "xyzzy"}
+test listbox-1.17 {configuration options} -body {
+ .l configure -fg #110022
+ list [lindex [.l configure -fg] 4] [.l cget -fg]
+} -cleanup {
+ .l configure -fg [lindex [.l configure -fg] 3]
+} -result {{#110022} #110022}
+test listbox-1.18 {configuration options} -body {
+ .l configure -fg bogus
+} -returnCodes error -result {unknown color name "bogus"}
+test listbox-1.19 {configuration options} -body {
+ .l configure -font {Helvetica 12}
+ list [lindex [.l configure -font] 4] [.l cget -font]
+} -cleanup {
+ .l configure -font [lindex [.l configure -font] 3]
+} -result {{Helvetica 12} {Helvetica 12}}
+test listbox-1.21 {configuration options} -body {
+ .l configure -foreground #110022
+ list [lindex [.l configure -foreground] 4] [.l cget -foreground]
+} -cleanup {
+ .l configure -foreground [lindex [.l configure -foreground] 3]
+} -result {{#110022} #110022}
+test listbox-1.22 {configuration options} -body {
+ .l configure -foreground bogus
+} -returnCodes error -result {unknown color name "bogus"}
+test listbox-1.23 {configuration options} -body {
+ .l configure -height 30
+ list [lindex [.l configure -height] 4] [.l cget -height]
+} -cleanup {
+ .l configure -height [lindex [.l configure -height] 3]
+} -result {30 30}
+test listbox-1.24 {configuration options} -body {
+ .l configure -height 20p
+} -returnCodes error -result {expected integer but got "20p"}
+test listbox-1.25 {configuration options} -body {
+ .l configure -highlightbackground #112233
+ list [lindex [.l configure -highlightbackground] 4] [.l cget -highlightbackground]
+} -cleanup {
+ .l configure -highlightbackground [lindex [.l configure -highlightbackground] 3]
+} -result {{#112233} #112233}
+test listbox-1.26 {configuration options} -body {
+ .l configure -highlightbackground ugly
+} -returnCodes error -result {unknown color name "ugly"}
+test listbox-1.27 {configuration options} -body {
+ .l configure -highlightcolor #123456
+ list [lindex [.l configure -highlightcolor] 4] [.l cget -highlightcolor]
+} -cleanup {
+ .l configure -highlightcolor [lindex [.l configure -highlightcolor] 3]
+} -result {{#123456} #123456}
+test listbox-1.28 {configuration options} -body {
+ .l configure -highlightcolor bogus
+} -returnCodes error -result {unknown color name "bogus"}
+test listbox-1.29 {configuration options} -body {
+ .l configure -highlightthickness 6
+ list [lindex [.l configure -highlightthickness] 4] [.l cget -highlightthickness]
+} -cleanup {
+ .l configure -highlightthickness [lindex [.l configure -highlightthickness] 3]
+} -result {6 6}
+test listbox-1.30 {configuration options} -body {
+ .l configure -highlightthickness bogus
+} -returnCodes error -result {bad screen distance "bogus"}
+test listbox-1.31 {configuration options} -body {
+ .l configure -highlightthickness -2
+ list [lindex [.l configure -highlightthickness] 4] [.l cget -highlightthickness]
+} -cleanup {
+ .l configure -highlightthickness [lindex [.l configure -highlightthickness] 3]
+} -result {0 0}
+test listbox-1.33 {configuration options} -body {
+ .l configure -relief groove
+ list [lindex [.l configure -relief] 4] [.l cget -relief]
+} -cleanup {
+ .l configure -relief [lindex [.l configure -relief] 3]
+} -result {groove groove}
+test listbox-1.34 {configuration options} -body {
+ .l configure -relief 1.5
+} -returnCodes error -result {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}
+test listbox-1.35 {configuration options} -body {
+ .l configure -selectbackground #110022
+ list [lindex [.l configure -selectbackground] 4] [.l cget -selectbackground]
+} -cleanup {
+ .l configure -selectbackground [lindex [.l configure -selectbackground] 3]
+} -result {{#110022} #110022}
+test listbox-1.36 {configuration options} -body {
+ .l configure -selectbackground bogus
+} -returnCodes error -result {unknown color name "bogus"}
+test listbox-1.37 {configuration options} -body {
+ .l configure -selectborderwidth 1.3
+ list [lindex [.l configure -selectborderwidth] 4] [.l cget -selectborderwidth]
+} -cleanup {
+ .l configure -selectborderwidth [lindex [.l configure -selectborderwidth] 3]
+} -result {1 1}
+test listbox-1.38 {configuration options} -body {
+ .l configure -selectborderwidth badValue
+} -returnCodes error -result {bad screen distance "badValue"}
+test listbox-1.39 {configuration options} -body {
+ .l configure -selectforeground #654321
+ list [lindex [.l configure -selectforeground] 4] [.l cget -selectforeground]
+} -cleanup {
+ .l configure -selectforeground [lindex [.l configure -selectforeground] 3]
+} -result {{#654321} #654321}
+test listbox-1.40 {configuration options} -body {
+ .l configure -selectforeground bogus
+} -returnCodes error -result {unknown color name "bogus"}
+test listbox-1.41 {configuration options} -body {
+ .l configure -selectmode string
+ list [lindex [.l configure -selectmode] 4] [.l cget -selectmode]
+} -cleanup {
+ .l configure -selectmode [lindex [.l configure -selectmode] 3]
+} -result {string string}
+test listbox-1.43 {configuration options} -body {
+ .l configure -setgrid false
+ list [lindex [.l configure -setgrid] 4] [.l cget -setgrid]
+} -cleanup {
+ .l configure -setgrid [lindex [.l configure -setgrid] 3]
+} -result {0 0}
+test listbox-1.44 {configuration options} -body {
+ .l configure -setgrid lousy
+} -returnCodes error -result {expected boolean value but got "lousy"}
+test listbox-1.45 {configuration options} -body {
+ .l configure -state disabled
+ list [lindex [.l configure -state] 4] [.l cget -state]
+} -cleanup {
+ .l configure -state [lindex [.l configure -state] 3]
+} -result {disabled disabled}
+test listbox-1.46 {configuration options} -body {
+ .l configure -state foo
+} -returnCodes error -result {bad state "foo": must be disabled or normal}
+test listbox-1.47 {configuration options} -body {
+ .l configure -takefocus {any string}
+ list [lindex [.l configure -takefocus] 4] [.l cget -takefocus]
+} -cleanup {
+ .l configure -takefocus [lindex [.l configure -takefocus] 3]
+} -result {{any string} {any string}}
+test listbox-1.49 {configuration options} -body {
+ .l configure -width 45
+ list [lindex [.l configure -width] 4] [.l cget -width]
+} -cleanup {
+ .l configure -width [lindex [.l configure -width] 3]
+} -result {45 45}
+test listbox-1.50 {configuration options} -body {
+ .l configure -width 3p
+} -returnCodes error -result {expected integer but got "3p"}
+test listbox-1.51 {configuration options} -body {
+ .l configure -xscrollcommand {Some command}
+ list [lindex [.l configure -xscrollcommand] 4] [.l cget -xscrollcommand]
+} -cleanup {
+ .l configure -xscrollcommand [lindex [.l configure -xscrollcommand] 3]
+} -result {{Some command} {Some command}}
+test listbox-1.53 {configuration options} -body {
+ .l configure -yscrollcommand {Another command}
+ list [lindex [.l configure -yscrollcommand] 4] [.l cget -yscrollcommand]
+} -cleanup {
+ .l configure -yscrollcommand [lindex [.l configure -yscrollcommand] 3]
+} -result {{Another command} {Another command}}
+test listbox-1.55 {configuration options} -body {
+ .l configure -listvar testVariable
+ list [lindex [.l configure -listvar] 4] [.l cget -listvar]
+} -cleanup {
+ .l configure -listvar [lindex [.l configure -listvar] 3]
+} -result {testVariable testVariable}
+
-test listbox-2.1 {Tk_ListboxCmd procedure} {
- list [catch {listbox} msg] $msg
-} {1 {wrong # args: should be "listbox pathName ?-option value ...?"}}
-test listbox-2.2 {Tk_ListboxCmd procedure} {
- list [catch {listbox gorp} msg] $msg
-} {1 {bad window path name "gorp"}}
-test listbox-2.3 {Tk_ListboxCmd procedure} {
- catch {destroy .l}
+test listbox-2.1 {Tk_ListboxCmd procedure} -body {
+ listbox
+} -returnCodes error -result {wrong # args: should be "listbox pathName ?-option value ...?"}
+test listbox-2.2 {Tk_ListboxCmd procedure} -body {
+ listbox gorp
+} -returnCodes error -result {bad window path name "gorp"}
+test listbox-2.3 {Tk_ListboxCmd procedure} -setup {
+ destroy .l
+} -body {
listbox .l
list [winfo exists .l] [winfo class .l] [info commands .l]
-} {1 Listbox .l}
-test listbox-2.4 {Tk_ListboxCmd procedure} {
- catch {destroy .l}
- list [catch {listbox .l -gorp foo} msg] $msg [winfo exists .l] \
- [info commands .l]
-} {1 {unknown option "-gorp"} 0 {}}
-test listbox-2.5 {Tk_ListboxCmd procedure} {
- catch {destroy .l}
+} -result {1 Listbox .l}
+test listbox-2.4 {Tk_ListboxCmd procedure} -setup {
+ destroy .l
+} -body {
+ listbox .l -gorp foo
+} -cleanup {
+ destroy .l
+} -returnCodes error -result {unknown option "-gorp"}
+test listbox-2.5 {Tk_ListboxCmd procedure} -setup {
+ destroy .l
+} -body {
+ catch {listbox .l -gorp foo}
+ list [winfo exists .l] [info commands .l]
+} -cleanup {
+ destroy .l
+} -result {0 {}}
+test listbox-2.6 {Tk_ListboxCmd procedure} -setup {
+ destroy .l
+} -body {
listbox .l
-} {.l}
+} -cleanup {
+ destroy .l
+} -result {.l}
+
-catch {destroy .l}
+# Listbox used in 3.1 -3.115 tests
+destroy .l
listbox .l -width 20 -height 5 -bd 4 -highlightthickness 1 -selectborderwidth 2
pack .l
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11 el12 el13 el14 \
el15 el16 el17
update
-test listbox-3.1 {ListboxWidgetCmd procedure} {
- list [catch .l msg] $msg
-} {1 {wrong # args: should be ".l option ?arg ...?"}}
-test listbox-3.2 {ListboxWidgetCmd procedure, "activate" option} {
- list [catch {.l activate} msg] $msg
-} {1 {wrong # args: should be ".l activate index"}}
-test listbox-3.3 {ListboxWidgetCmd procedure, "activate" option} {
- list [catch {.l activate a b} msg] $msg
-} {1 {wrong # args: should be ".l activate index"}}
-test listbox-3.4 {ListboxWidgetCmd procedure, "activate" option} {
- list [catch {.l activate fooey} msg] $msg
-} {1 {bad listbox index "fooey": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.5 {ListboxWidgetCmd procedure, "activate" option} {
+test listbox-3.1 {ListboxWidgetCmd procedure} -body {
+ .l
+} -returnCodes error -result {wrong # args: should be ".l option ?arg ...?"}
+test listbox-3.2 {ListboxWidgetCmd procedure, "activate" option} -body {
+ .l activate
+} -returnCodes error -result {wrong # args: should be ".l activate index"}
+test listbox-3.3 {ListboxWidgetCmd procedure, "activate" option} -body {
+ .l activate a b
+} -returnCodes error -result {wrong # args: should be ".l activate index"}
+test listbox-3.4 {ListboxWidgetCmd procedure, "activate" option} -body {
+ .l activate fooey
+} -returnCodes error -result {bad listbox index "fooey": must be active, anchor, end, @x,y, or a number}
+test listbox-3.5 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate 3
.l index active
-} 3
-test listbox-3.6 {ListboxWidgetCmd procedure, "activate" option} {
+} -result 3
+test listbox-3.6 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate -1
.l index active
-} {0}
-test listbox-3.7 {ListboxWidgetCmd procedure, "activate" option} {
+} -result {0}
+test listbox-3.7 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate 30
.l index active
-} {17}
-test listbox-3.8 {ListboxWidgetCmd procedure, "activate" option} {
+} -result {17}
+test listbox-3.8 {ListboxWidgetCmd procedure, "activate" option} -body {
.l activate end
.l index active
-} {17}
-test listbox-3.9 {ListboxWidgetCmd procedure, "bbox" option} {
- list [catch {.l bbox} msg] $msg
-} {1 {wrong # args: should be ".l bbox index"}}
-test listbox-3.10 {ListboxWidgetCmd procedure, "bbox" option} {
- list [catch {.l bbox a b} msg] $msg
-} {1 {wrong # args: should be ".l bbox index"}}
-test listbox-3.11 {ListboxWidgetCmd procedure, "bbox" option} {
- list [catch {.l bbox fooey} msg] $msg
-} {1 {bad listbox index "fooey": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.12 {ListboxWidgetCmd procedure, "bbox" option} {
+} -result {17}
+test listbox-3.9 {ListboxWidgetCmd procedure, "bbox" option} -body {
+ .l bbox
+} -returnCodes error -result {wrong # args: should be ".l bbox index"}
+test listbox-3.10 {ListboxWidgetCmd procedure, "bbox" option} -body {
+ .l bbox a b
+} -returnCodes error -result {wrong # args: should be ".l bbox index"}
+test listbox-3.11 {ListboxWidgetCmd procedure, "bbox" option} -body {
+ .l bbox fooey
+} -returnCodes error -result {bad listbox index "fooey": must be active, anchor, end, @x,y, or a number}
+test listbox-3.12 {ListboxWidgetCmd procedure, "bbox" option} -body {
.l yview 3
update
list [.l bbox 2] [.l bbox 8]
-} {{} {}}
-test listbox-3.13 {ListboxWidgetCmd procedure, "bbox" option} {
+} -result {{} {}}
+test listbox-3.13 {ListboxWidgetCmd procedure, "bbox" option} -cleanup {
+ destroy .l2
+} -body {
# Used to generate a core dump before a bug was fixed (the last
# element would be on-screen if it existed, but it doesn't exist).
@@ -191,25 +396,36 @@ test listbox-3.13 {ListboxWidgetCmd procedure, "bbox" option} {
tkwait visibility .l2
set x [.l2 bbox 0]
destroy .l2
- set x
-} {}
-test listbox-3.14 {ListboxWidgetCmd procedure, "bbox" option} {fonts} {
+ return $x
+} -cleanup {
+ destroy .l2
+} -result {}
+test listbox-3.14 {ListboxWidgetCmd procedure, "bbox" option} -constraints {
+ fonts
+} -body {
.l yview 3
update
list [.l bbox 3] [.l bbox 4]
-} {{7 7 17 14} {7 26 17 14}}
-test listbox-3.15 {ListboxWidgetCmd procedure, "bbox" option} {fonts} {
+} -result {{7 7 17 14} {7 26 17 14}}
+test listbox-3.15 {ListboxWidgetCmd procedure, "bbox" option} -constraints {
+ fonts
+} -body {
.l yview 0
update
list [.l bbox -1] [.l bbox 0]
-} {{} {7 7 17 14}}
-test listbox-3.16 {ListboxWidgetCmd procedure, "bbox" option} {fonts} {
+} -result {{} {7 7 17 14}}
+test listbox-3.16 {ListboxWidgetCmd procedure, "bbox" option} -constraints {
+ fonts
+} -body {
.l yview end
update
list [.l bbox 17] [.l bbox end] [.l bbox 18]
-} {{7 83 24 14} {7 83 24 14} {}}
-test listbox-3.17 {ListboxWidgetCmd procedure, "bbox" option} {fonts} {
- catch {destroy .t}
+} -result {{7 83 24 14} {7 83 24 14} {}}
+test listbox-3.17 {ListboxWidgetCmd procedure, "bbox" option} -constraints {
+ fonts
+} -setup {
+ destroy .t
+} -body {
toplevel .t
wm geom .t +0+0
listbox .t.l -width 10 -height 5
@@ -218,255 +434,307 @@ test listbox-3.17 {ListboxWidgetCmd procedure, "bbox" option} {fonts} {
update
.t.l xview moveto .2
.t.l bbox 2
-} {-72 39 393 14}
-test listbox-3.18 {ListboxWidgetCmd procedure, "bbox" option, partial last line} {fonts} {
+} -cleanup {
+ destroy .t
+} -result {-72 39 393 14}
+test listbox-3.18 {ListboxWidgetCmd procedure, "bbox" option, partial last line} -constraints {
+ fonts
+} -body {
mkPartial
list [.partial.l bbox 3] [.partial.l bbox 4]
-} {{5 56 24 14} {5 73 23 14}}
-test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} {
- list [catch {.l cget} msg] $msg
-} {1 {wrong # args: should be ".l cget option"}}
-test listbox-3.20 {ListboxWidgetCmd procedure, "cget" option} {
- list [catch {.l cget a b} msg] $msg
-} {1 {wrong # args: should be ".l cget option"}}
-test listbox-3.21 {ListboxWidgetCmd procedure, "cget" option} {
- list [catch {.l cget -gorp} msg] $msg
-} {1 {unknown option "-gorp"}}
-test listbox-3.22 {ListboxWidgetCmd procedure, "cget" option} {
+} -result {{5 56 24 14} {5 73 23 14}}
+test listbox-3.19 {ListboxWidgetCmd procedure, "cget" option} -body {
+ .l cget
+} -returnCodes error -result {wrong # args: should be ".l cget option"}
+test listbox-3.20 {ListboxWidgetCmd procedure, "cget" option} -body {
+ .l cget a b
+} -returnCodes error -result {wrong # args: should be ".l cget option"}
+test listbox-3.21 {ListboxWidgetCmd procedure, "cget" option} -body {
+ .l cget -gorp
+} -returnCodes error -result {unknown option "-gorp"}
+test listbox-3.22 {ListboxWidgetCmd procedure, "cget" option} -body {
.l cget -setgrid
-} {0}
-test listbox-3.23 {ListboxWidgetCmd procedure, "configure" option} {
+} -result {0}
+test listbox-3.23 {ListboxWidgetCmd procedure, "configure" option} -body {
llength [.l configure]
-} {27}
-test listbox-3.24 {ListboxWidgetCmd procedure, "configure" option} {
- list [catch {.l configure -gorp} msg] $msg
-} {1 {unknown option "-gorp"}}
-test listbox-3.25 {ListboxWidgetCmd procedure, "configure" option} {
+} -result {27}
+test listbox-3.24 {ListboxWidgetCmd procedure, "configure" option} -body {
+ .l configure -gorp
+} -returnCodes error -result {unknown option "-gorp"}
+test listbox-3.25 {ListboxWidgetCmd procedure, "configure" option} -body {
.l configure -setgrid
-} {-setgrid setGrid SetGrid 0 0}
-test listbox-3.26 {ListboxWidgetCmd procedure, "configure" option} {
- list [catch {.l configure -gorp is_messy} msg] $msg
-} {1 {unknown option "-gorp"}}
-test listbox-3.27 {ListboxWidgetCmd procedure, "configure" option} {
+} -result {-setgrid setGrid SetGrid 0 0}
+test listbox-3.26 {ListboxWidgetCmd procedure, "configure" option} -body {
+ .l configure -gorp is_messy
+} -returnCodes error -result {unknown option "-gorp"}
+test listbox-3.27 {ListboxWidgetCmd procedure, "configure" option} -body {
set oldbd [.l cget -bd]
set oldht [.l cget -highlightthickness]
.l configure -bd 3 -highlightthickness 0
set x "[.l cget -bd] [.l cget -highlightthickness]"
.l configure -bd $oldbd -highlightthickness $oldht
- set x
-} {3 0}
-test listbox-3.28 {ListboxWidgetCmd procedure, "curselection" option} {
- list [catch {.l curselection a} msg] $msg
-} {1 {wrong # args: should be ".l curselection"}}
-test listbox-3.29 {ListboxWidgetCmd procedure, "curselection" option} {
+ return $x
+} -result {3 0}
+test listbox-3.28 {ListboxWidgetCmd procedure, "curselection" option} -body {
+ .l curselection a
+} -returnCodes error -result {wrong # args: should be ".l curselection"}
+test listbox-3.29 {ListboxWidgetCmd procedure, "curselection" option} -body {
.l selection clear 0 end
.l selection set 3 6
.l selection set 9
.l curselection
-} {3 4 5 6 9}
-test listbox-3.30 {ListboxWidgetCmd procedure, "delete" option} {
- list [catch {.l delete} msg] $msg
-} {1 {wrong # args: should be ".l delete firstIndex ?lastIndex?"}}
-test listbox-3.31 {ListboxWidgetCmd procedure, "delete" option} {
- list [catch {.l delete a b c} msg] $msg
-} {1 {wrong # args: should be ".l delete firstIndex ?lastIndex?"}}
-test listbox-3.32 {ListboxWidgetCmd procedure, "delete" option} {
- list [catch {.l delete badIndex} msg] $msg
-} {1 {bad listbox index "badIndex": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.33 {ListboxWidgetCmd procedure, "delete" option} {
- list [catch {.l delete 2 123ab} msg] $msg
-} {1 {bad listbox index "123ab": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.34 {ListboxWidgetCmd procedure, "delete" option} {
- catch {destroy .l2}
+} -result {3 4 5 6 9}
+test listbox-3.30 {ListboxWidgetCmd procedure, "delete" option} -body {
+ .l delete
+} -returnCodes error -result {wrong # args: should be ".l delete firstIndex ?lastIndex?"}
+test listbox-3.31 {ListboxWidgetCmd procedure, "delete" option} -body {
+ .l delete a b c
+} -returnCodes error -result {wrong # args: should be ".l delete firstIndex ?lastIndex?"}
+test listbox-3.32 {ListboxWidgetCmd procedure, "delete" option} -body {
+ .l delete badIndex
+} -returnCodes error -result {bad listbox index "badIndex": must be active, anchor, end, @x,y, or a number}
+test listbox-3.33 {ListboxWidgetCmd procedure, "delete" option} -body {
+ .l delete 2 123ab
+} -returnCodes error -result {bad listbox index "123ab": must be active, anchor, end, @x,y, or a number}
+test listbox-3.34 {ListboxWidgetCmd procedure, "delete" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete 3
list [.l2 get 2] [.l2 get 3] [.l2 index end]
-} {el2 el4 7}
-test listbox-3.35 {ListboxWidgetCmd procedure, "delete" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {el2 el4 7}
+test listbox-3.35 {ListboxWidgetCmd procedure, "delete" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete 2 4
list [.l2 get 1] [.l2 get 2] [.l2 index end]
-} {el1 el5 5}
-test listbox-3.36 {ListboxWidgetCmd procedure, "delete" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {el1 el5 5}
+test listbox-3.36 {ListboxWidgetCmd procedure, "delete" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete -3 2
.l2 get 0 end
-} {el3 el4 el5 el6 el7}
-test listbox-3.37 {ListboxWidgetCmd procedure, "delete" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {el3 el4 el5 el6 el7}
+test listbox-3.37 {ListboxWidgetCmd procedure, "delete" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete -3 -1
.l2 get 0 end
-} {el0 el1 el2 el3 el4 el5 el6 el7}
-test listbox-3.38 {ListboxWidgetCmd procedure, "delete" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {el0 el1 el2 el3 el4 el5 el6 el7}
+test listbox-3.38 {ListboxWidgetCmd procedure, "delete" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete 2 end
.l2 get 0 end
-} {el0 el1}
-test listbox-3.39 {ListboxWidgetCmd procedure, "delete" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {el0 el1}
+test listbox-3.39 {ListboxWidgetCmd procedure, "delete" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete 5 20
.l2 get 0 end
-} {el0 el1 el2 el3 el4}
-test listbox-3.40 {ListboxWidgetCmd procedure, "delete" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {el0 el1 el2 el3 el4}
+test listbox-3.40 {ListboxWidgetCmd procedure, "delete" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete end 20
.l2 get 0 end
-} {el0 el1 el2 el3 el4 el5 el6}
-test listbox-3.41 {ListboxWidgetCmd procedure, "delete" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {el0 el1 el2 el3 el4 el5 el6}
+test listbox-3.41 {ListboxWidgetCmd procedure, "delete" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
.l2 delete 8 20
.l2 get 0 end
-} {el0 el1 el2 el3 el4 el5 el6 el7}
-test listbox-3.42 {ListboxWidgetCmd procedure, "get" option} {
- list [catch {.l get} msg] $msg
-} {1 {wrong # args: should be ".l get firstIndex ?lastIndex?"}}
-test listbox-3.43 {ListboxWidgetCmd procedure, "get" option} {
- list [catch {.l get a b c} msg] $msg
-} {1 {wrong # args: should be ".l get firstIndex ?lastIndex?"}}
-test listbox-3.44 {ListboxWidgetCmd procedure, "get" option} {
- list [catch {.l get 2.4} msg] $msg
-} {1 {bad listbox index "2.4": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.45 {ListboxWidgetCmd procedure, "get" option} {
- list [catch {.l get end bogus} msg] $msg
-} {1 {bad listbox index "bogus": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.46 {ListboxWidgetCmd procedure, "get" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {el0 el1 el2 el3 el4 el5 el6 el7}
+test listbox-3.42 {ListboxWidgetCmd procedure, "get" option} -body {
+ .l get
+} -returnCodes error -result {wrong # args: should be ".l get firstIndex ?lastIndex?"}
+test listbox-3.43 {ListboxWidgetCmd procedure, "get" option} -body {
+ .l get a b c
+} -returnCodes error -result {wrong # args: should be ".l get firstIndex ?lastIndex?"}
+test listbox-3.44 {ListboxWidgetCmd procedure, "get" option} -body {
+ .l get 2.4
+} -returnCodes error -result {bad listbox index "2.4": must be active, anchor, end, @x,y, or a number}
+test listbox-3.45 {ListboxWidgetCmd procedure, "get" option} -body {
+ .l get end bogus
+} -returnCodes error -result {bad listbox index "bogus": must be active, anchor, end, @x,y, or a number}
+test listbox-3.46 {ListboxWidgetCmd procedure, "get" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 el3 el4 el5 el6 el7
list [.l2 get 0] [.l2 get 3] [.l2 get end]
-} {el0 el3 el7}
-test listbox-3.47 {ListboxWidgetCmd procedure, "get" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {el0 el3 el7}
+test listbox-3.47 {ListboxWidgetCmd procedure, "get" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
list [.l2 get 0] [.l2 get end]
-} {{} {}}
-test listbox-3.48 {ListboxWidgetCmd procedure, "get" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {{} {}}
+test listbox-3.48 {ListboxWidgetCmd procedure, "get" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 el0 el1 el2 "two words" el4 el5 el6 el7
.l2 get 3 end
-} {{two words} el4 el5 el6 el7}
-test listbox-3.49 {ListboxWidgetCmd procedure, "get" option} {
+} -cleanup {
+ destroy .l2
+} -result {{two words} el4 el5 el6 el7}
+test listbox-3.49 {ListboxWidgetCmd procedure, "get" option} -body {
.l get -1
-} {}
-test listbox-3.50 {ListboxWidgetCmd procedure, "get" option} {
+} -result {}
+test listbox-3.50 {ListboxWidgetCmd procedure, "get" option} -body {
.l get -2 -1
-} {}
-test listbox-3.51 {ListboxWidgetCmd procedure, "get" option} {
+} -result {}
+test listbox-3.51 {ListboxWidgetCmd procedure, "get" option} -body {
.l get -2 3
-} {el0 el1 el2 el3}
-test listbox-3.52 {ListboxWidgetCmd procedure, "get" option} {
+} -result {el0 el1 el2 el3}
+test listbox-3.52 {ListboxWidgetCmd procedure, "get" option} -body {
.l get 12 end
-} {el12 el13 el14 el15 el16 el17}
-test listbox-3.53 {ListboxWidgetCmd procedure, "get" option} {
+} -result {el12 el13 el14 el15 el16 el17}
+test listbox-3.53 {ListboxWidgetCmd procedure, "get" option} -body {
.l get 12 20
-} {el12 el13 el14 el15 el16 el17}
-test listbox-3.54 {ListboxWidgetCmd procedure, "get" option} {
+} -result {el12 el13 el14 el15 el16 el17}
+test listbox-3.54 {ListboxWidgetCmd procedure, "get" option} -body {
.l get end
-} {el17}
-test listbox-3.55 {ListboxWidgetCmd procedure, "get" option} {
+} -result {el17}
+test listbox-3.55 {ListboxWidgetCmd procedure, "get" option} -body {
.l get 30
-} {}
-test listbox-3.56 {ListboxWidgetCmd procedure, "get" option} {
+} -result {}
+test listbox-3.56 {ListboxWidgetCmd procedure, "get" option} -body {
.l get 30 35
-} {}
-test listbox-3.57 {ListboxWidgetCmd procedure, "index" option} {
- list [catch {.l index} msg] $msg
-} {1 {wrong # args: should be ".l index index"}}
-test listbox-3.58 {ListboxWidgetCmd procedure, "index" option} {
- list [catch {.l index a b} msg] $msg
-} {1 {wrong # args: should be ".l index index"}}
-test listbox-3.59 {ListboxWidgetCmd procedure, "index" option} {
- list [catch {.l index @} msg] $msg
-} {1 {bad listbox index "@": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.60 {ListboxWidgetCmd procedure, "index" option} {
+} -result {}
+test listbox-3.57 {ListboxWidgetCmd procedure, "index" option} -body {
+ .l index
+} -returnCodes error -result {wrong # args: should be ".l index index"}
+test listbox-3.58 {ListboxWidgetCmd procedure, "index" option} -body {
+ .l index a b
+} -returnCodes error -result {wrong # args: should be ".l index index"}
+test listbox-3.59 {ListboxWidgetCmd procedure, "index" option} -body {
+ .l index @
+} -returnCodes error -result {bad listbox index "@": must be active, anchor, end, @x,y, or a number}
+test listbox-3.60 {ListboxWidgetCmd procedure, "index" option} -body {
.l index 2
-} 2
-test listbox-3.61 {ListboxWidgetCmd procedure, "index" option} {
+} -result 2
+test listbox-3.61 {ListboxWidgetCmd procedure, "index" option} -body {
.l index -1
-} -1
-test listbox-3.62 {ListboxWidgetCmd procedure, "index" option} {
+} -result {-1}
+test listbox-3.62 {ListboxWidgetCmd procedure, "index" option} -body {
.l index end
-} 18
-test listbox-3.63 {ListboxWidgetCmd procedure, "index" option} {
+} -result 18
+test listbox-3.63 {ListboxWidgetCmd procedure, "index" option} -body {
.l index 34
-} 34
-test listbox-3.64 {ListboxWidgetCmd procedure, "insert" option} {
- list [catch {.l insert} msg] $msg
-} {1 {wrong # args: should be ".l insert index ?element ...?"}}
-test listbox-3.65 {ListboxWidgetCmd procedure, "insert" option} {
- list [catch {.l insert badIndex} msg] $msg
-} {1 {bad listbox index "badIndex": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.66 {ListboxWidgetCmd procedure, "insert" option} {
- catch {destroy .l2}
+} -result 34
+test listbox-3.64 {ListboxWidgetCmd procedure, "insert" option} -body {
+ .l insert
+} -returnCodes error -result {wrong # args: should be ".l insert index ?element ...?"}
+test listbox-3.65 {ListboxWidgetCmd procedure, "insert" option} -body {
+ .l insert badIndex
+} -returnCodes error -result {bad listbox index "badIndex": must be active, anchor, end, @x,y, or a number}
+test listbox-3.66 {ListboxWidgetCmd procedure, "insert" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert end a b c d e
.l2 insert 3 x y z
.l2 get 0 end
-} {a b c x y z d e}
-test listbox-3.67 {ListboxWidgetCmd procedure, "insert" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {a b c x y z d e}
+test listbox-3.67 {ListboxWidgetCmd procedure, "insert" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert end a b c
.l2 insert -1 x
.l2 get 0 end
-} {x a b c}
-test listbox-3.68 {ListboxWidgetCmd procedure, "insert" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {x a b c}
+test listbox-3.68 {ListboxWidgetCmd procedure, "insert" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert end a b c
.l2 insert end x
.l2 get 0 end
-} {a b c x}
-test listbox-3.69 {ListboxWidgetCmd procedure, "insert" option} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {a b c x}
+test listbox-3.69 {ListboxWidgetCmd procedure, "insert" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert end a b c
.l2 insert 43 x
.l2 get 0 end
-} {a b c x}
-test listbox-3.70 {ListboxWidgetCmd procedure, "nearest" option} {
- list [catch {.l nearest} msg] $msg
-} {1 {wrong # args: should be ".l nearest y"}}
-test listbox-3.71 {ListboxWidgetCmd procedure, "nearest" option} {
- list [catch {.l nearest a b} msg] $msg
-} {1 {wrong # args: should be ".l nearest y"}}
-test listbox-3.72 {ListboxWidgetCmd procedure, "nearest" option} {
- list [catch {.l nearest 20p} msg] $msg
-} {1 {expected integer but got "20p"}}
-test listbox-3.73 {ListboxWidgetCmd procedure, "nearest" option} {
+} -cleanup {
+ destroy .l2
+} -result {a b c x}
+test listbox-3.70 {ListboxWidgetCmd procedure, "nearest" option} -body {
+ .l nearest
+} -returnCodes error -result {wrong # args: should be ".l nearest y"}
+test listbox-3.71 {ListboxWidgetCmd procedure, "nearest" option} -body {
+ .l nearest a b
+} -returnCodes error -result {wrong # args: should be ".l nearest y"}
+test listbox-3.72 {ListboxWidgetCmd procedure, "nearest" option} -body {
+ .l nearest 20p
+} -returnCodes error -result {expected integer but got "20p"}
+test listbox-3.73 {ListboxWidgetCmd procedure, "nearest" option} -body {
.l yview 3
.l nearest 1000
-} {7}
-test listbox-3.74 {ListboxWidgetCmd procedure, "scan" option} {
- list [catch {.l scan a b} msg] $msg
-} {1 {wrong # args: should be ".l scan mark|dragto x y"}}
-test listbox-3.75 {ListboxWidgetCmd procedure, "scan" option} {
- list [catch {.l scan a b c d} msg] $msg
-} {1 {wrong # args: should be ".l scan mark|dragto x y"}}
-test listbox-3.76 {ListboxWidgetCmd procedure, "scan" option} {
- list [catch {.l scan foo bogus 2} msg] $msg
-} {1 {expected integer but got "bogus"}}
-test listbox-3.77 {ListboxWidgetCmd procedure, "scan" option} {
- list [catch {.l scan foo 2 2.3} msg] $msg
-} {1 {expected integer but got "2.3"}}
-test listbox-3.78 {ListboxWidgetCmd procedure, "scan" option} {fonts} {
- catch {destroy .t}
+} -result {7}
+test listbox-3.74 {ListboxWidgetCmd procedure, "scan" option} -body {
+ .l scan a b
+} -returnCodes error -result {wrong # args: should be ".l scan mark|dragto x y"}
+test listbox-3.75 {ListboxWidgetCmd procedure, "scan" option} -body {
+ .l scan a b c d
+} -returnCodes error -result {wrong # args: should be ".l scan mark|dragto x y"}
+test listbox-3.76 {ListboxWidgetCmd procedure, "scan" option} -body {
+ .l scan foo bogus 2
+} -returnCodes error -result {expected integer but got "bogus"}
+test listbox-3.77 {ListboxWidgetCmd procedure, "scan" option} -body {
+ .l scan foo 2 2.3
+} -returnCodes error -result {expected integer but got "2.3"}
+test listbox-3.78 {ListboxWidgetCmd procedure, "scan" option} -constraints {
+ fonts
+} -setup {
+ destroy .t
+} -body {
toplevel .t
wm geom .t +0+0
listbox .t.l -width 10 -height 5
@@ -477,312 +745,454 @@ test listbox-3.78 {ListboxWidgetCmd procedure, "scan" option} {fonts} {
.t.l scan dragto 90 137
update
list [.t.l xview] [.t.l yview]
-} {{0.249364 0.427481} {0.0714286 0.428571}}
-test listbox-3.79 {ListboxWidgetCmd procedure, "scan" option} {
- list [catch {.l scan foo 2 4} msg] $msg
-} {1 {bad option "foo": must be mark or dragto}}
-test listbox-3.80 {ListboxWidgetCmd procedure, "see" option} {
- list [catch {.l see} msg] $msg
-} {1 {wrong # args: should be ".l see index"}}
-test listbox-3.81 {ListboxWidgetCmd procedure, "see" option} {
- list [catch {.l see a b} msg] $msg
-} {1 {wrong # args: should be ".l see index"}}
-test listbox-3.82 {ListboxWidgetCmd procedure, "see" option} {
- list [catch {.l see gorp} msg] $msg
-} {1 {bad listbox index "gorp": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.83 {ListboxWidgetCmd procedure, "see" option} {
+} -cleanup {
+ destroy .t
+} -result {{0.249364 0.427481} {0.0714286 0.428571}}
+test listbox-3.79 {ListboxWidgetCmd procedure, "scan" option} -body {
+ .l scan foo 2 4
+} -returnCodes error -result {bad option "foo": must be mark or dragto}
+test listbox-3.80 {ListboxWidgetCmd procedure, "see" option} -body {
+ .l see
+} -returnCodes error -result {wrong # args: should be ".l see index"}
+test listbox-3.81 {ListboxWidgetCmd procedure, "see" option} -body {
+ .l see a b
+} -returnCodes error -result {wrong # args: should be ".l see index"}
+test listbox-3.82 {ListboxWidgetCmd procedure, "see" option} -body {
+ .l see gorp
+} -returnCodes error -result {bad listbox index "gorp": must be active, anchor, end, @x,y, or a number}
+test listbox-3.83 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 7
.l index @0,0
-} {7}
-test listbox-3.84 {ListboxWidgetCmd procedure, "see" option} {
+} -result {7}
+test listbox-3.84 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 11
.l index @0,0
-} {7}
-test listbox-3.85 {ListboxWidgetCmd procedure, "see" option} {
+} -result {7}
+test listbox-3.85 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 6
.l index @0,0
-} {6}
-test listbox-3.86 {ListboxWidgetCmd procedure, "see" option} {
+} -result {6}
+test listbox-3.86 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 5
.l index @0,0
-} {3}
-test listbox-3.87 {ListboxWidgetCmd procedure, "see" option} {
+} -result {3}
+test listbox-3.87 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 12
.l index @0,0
-} {8}
-test listbox-3.88 {ListboxWidgetCmd procedure, "see" option} {
+} -result {8}
+test listbox-3.88 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 13
.l index @0,0
-} {11}
-test listbox-3.89 {ListboxWidgetCmd procedure, "see" option} {
+} -result {11}
+test listbox-3.89 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see -1
.l index @0,0
-} {0}
-test listbox-3.90 {ListboxWidgetCmd procedure, "see" option} {
+} -result {0}
+test listbox-3.90 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see end
.l index @0,0
-} {13}
-test listbox-3.91 {ListboxWidgetCmd procedure, "see" option} {
+} -result {13}
+test listbox-3.91 {ListboxWidgetCmd procedure, "see" option} -body {
.l yview 7
.l see 322
.l index @0,0
-} {13}
-test listbox-3.92 {ListboxWidgetCmd procedure, "see" option, partial last line} {
+} -result {13}
+test listbox-3.92 {ListboxWidgetCmd procedure, "see" option, partial last line} -body {
mkPartial
.partial.l see 4
.partial.l index @0,0
-} {1}
-test listbox-3.93 {ListboxWidgetCmd procedure, "selection" option} {
- list [catch {.l select a} msg] $msg
-} {1 {wrong # args: should be ".l selection option index ?index?"}}
-test listbox-3.94 {ListboxWidgetCmd procedure, "selection" option} {
- list [catch {.l select a b c d} msg] $msg
-} {1 {wrong # args: should be ".l selection option index ?index?"}}
-test listbox-3.95 {ListboxWidgetCmd procedure, "selection" option} {
- list [catch {.l selection a bogus} msg] $msg
-} {1 {bad listbox index "bogus": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.96 {ListboxWidgetCmd procedure, "selection" option} {
- list [catch {.l selection a 0 lousy} msg] $msg
-} {1 {bad listbox index "lousy": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.97 {ListboxWidgetCmd procedure, "selection" option} {
- list [catch {.l selection anchor 0 0} msg] $msg
-} {1 {wrong # args: should be ".l selection anchor index"}}
-test listbox-3.98 {ListboxWidgetCmd procedure, "selection" option} {
+} -result {1}
+test listbox-3.93 {ListboxWidgetCmd procedure, "selection" option} -body {
+ .l select a
+} -returnCodes error -result {wrong # args: should be ".l selection option index ?index?"}
+test listbox-3.94 {ListboxWidgetCmd procedure, "selection" option} -body {
+ .l select a b c d
+} -returnCodes error -result {wrong # args: should be ".l selection option index ?index?"}
+test listbox-3.95 {ListboxWidgetCmd procedure, "selection" option} -body {
+ .l selection a bogus
+} -returnCodes error -result {bad listbox index "bogus": must be active, anchor, end, @x,y, or a number}
+test listbox-3.96 {ListboxWidgetCmd procedure, "selection" option} -body {
+ .l selection a 0 lousy
+} -returnCodes error -result {bad listbox index "lousy": must be active, anchor, end, @x,y, or a number}
+test listbox-3.97 {ListboxWidgetCmd procedure, "selection" option} -body {
+ .l selection anchor 0 0
+} -returnCodes error -result {wrong # args: should be ".l selection anchor index"}
+test listbox-3.98 {ListboxWidgetCmd procedure, "selection" option} -body {
list [.l selection anchor 5; .l index anchor] \
[.l selection anchor 0; .l index anchor]
-} {5 0}
-test listbox-3.99 {ListboxWidgetCmd procedure, "selection" option} {
+} -result {5 0}
+test listbox-3.99 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection anchor -1
.l index anchor
-} {0}
-test listbox-3.100 {ListboxWidgetCmd procedure, "selection" option} {
+} -result {0}
+test listbox-3.100 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection anchor end
.l index anchor
-} {17}
-test listbox-3.101 {ListboxWidgetCmd procedure, "selection" option} {
+} -result {17}
+test listbox-3.101 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection anchor 44
.l index anchor
-} {17}
-test listbox-3.102 {ListboxWidgetCmd procedure, "selection" option} {
+} -result {17}
+test listbox-3.102 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection clear 0 end
.l selection set 2 8
.l selection clear 3 4
.l curselection
-} {2 5 6 7 8}
-test listbox-3.103 {ListboxWidgetCmd procedure, "selection" option} {
- list [catch {.l selection includes 0 0} msg] $msg
-} {1 {wrong # args: should be ".l selection includes index"}}
-test listbox-3.104 {ListboxWidgetCmd procedure, "selection" option} {
+} -result {2 5 6 7 8}
+test listbox-3.103 {ListboxWidgetCmd procedure, "selection" option} -body {
+ .l selection includes 0 0
+} -returnCodes error -result {wrong # args: should be ".l selection includes index"}
+test listbox-3.104 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection clear 0 end
.l selection set 2 8
.l selection clear 4
list [.l selection includes 3] [.l selection includes 4] \
[.l selection includes 5]
-} {1 0 1}
-test listbox-3.105 {ListboxWidgetCmd procedure, "selection" option} {
+} -result {1 0 1}
+test listbox-3.105 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection set 0 end
.l selection includes -1
-} {0}
-test listbox-3.106 {ListboxWidgetCmd procedure, "selection" option} {
+} -result {0}
+test listbox-3.106 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection clear 0 end
.l selection set end
.l selection includes end
-} {1}
-test listbox-3.107 {ListboxWidgetCmd procedure, "selection" option} {
+} -result {1}
+test listbox-3.107 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection set 0 end
.l selection includes 44
-} {0}
-test listbox-3.108 {ListboxWidgetCmd procedure, "selection" option} {
- catch {destroy .l2}
+} -result {0}
+test listbox-3.108 {ListboxWidgetCmd procedure, "selection" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 selection includes 0
-} {0}
-test listbox-3.109 {ListboxWidgetCmd procedure, "selection" option} {
+} -cleanup {
+ destroy .l2
+} -result {0}
+test listbox-3.109 {ListboxWidgetCmd procedure, "selection" option} -body {
.l selection clear 0 end
.l selection set 2
.l selection set 5 7
.l curselection
-} {2 5 6 7}
-test listbox-3.110 {ListboxWidgetCmd procedure, "selection" option} {
+} -result {2 5 6 7}
+test listbox-3.110 {ListboxWidgetCmd procedure, "selection" option} -body {
+ .l selection clear 0 end
+ .l selection set 2
+ .l selection set 5 7
.l selection set 5 7
.l curselection
-} {2 5 6 7}
-test listbox-3.111 {ListboxWidgetCmd procedure, "selection" option} {
- list [catch {.l selection badOption 0 0} msg] $msg
-} {1 {bad option "badOption": must be anchor, clear, includes, or set}}
-test listbox-3.112 {ListboxWidgetCmd procedure, "size" option} {
- list [catch {.l size a} msg] $msg
-} {1 {wrong # args: should be ".l size"}}
-test listbox-3.113 {ListboxWidgetCmd procedure, "size" option} {
+} -result {2 5 6 7}
+test listbox-3.111 {ListboxWidgetCmd procedure, "selection" option} -body {
+ .l selection badOption 0 0
+} -returnCodes error -result {bad option "badOption": must be anchor, clear, includes, or set}
+test listbox-3.112 {ListboxWidgetCmd procedure, "size" option} -body {
+ .l size a
+} -returnCodes error -result {wrong # args: should be ".l size"}
+test listbox-3.113 {ListboxWidgetCmd procedure, "size" option} -body {
.l size
-} {18}
-test listbox-3.114 {ListboxWidgetCmd procedure, "xview" option} {
- catch {destroy .l2}
+} -result {18}
+test listbox-3.114 {ListboxWidgetCmd procedure, "xview" option} -setup {
+ destroy .l2
+} -body {
listbox .l2
update
.l2 xview
-} {0 1}
-test listbox-3.115 {ListboxWidgetCmd procedure, "xview" option} {
- catch {destroy .l}
- listbox .l -width 10 -height 5 -font $fixed
- .l insert 0 a b c d e f g h i j k l m n o p q r s t
- pack .l
+} -cleanup {
+ destroy .l2
+} -result {0 1}
+test listbox-3.115 {ListboxWidgetCmd procedure, "xview" option} -setup {
+ destroy .l2
+} -body {
+ listbox .l2 -width 10 -height 5 -font $fixed
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ pack .l2
update
- .l xview
-} {0 1}
-catch {destroy .l}
-listbox .l -width 10 -height 5 -font $fixed
-.l insert 0 a b c d e f g h i j k l m n o p q r s t
-.l insert 1 "0123456789a123456789b123456789c123456789d123456789"
-pack .l
-update
-test listbox-3.116 {ListboxWidgetCmd procedure, "xview" option} {fonts} {
- .l xview 4
- .l xview
-} {0.08 0.28}
-test listbox-3.117 {ListboxWidgetCmd procedure, "xview" option} {
- list [catch {.l xview foo} msg] $msg
-} {1 {expected integer but got "foo"}}
-test listbox-3.118 {ListboxWidgetCmd procedure, "xview" option} {
- list [catch {.l xview zoom a b} msg] $msg
-} {1 {unknown option "zoom": must be moveto or scroll}}
-test listbox-3.119 {ListboxWidgetCmd procedure, "xview" option} {fonts} {
- .l xview 0
- .l xview moveto .4
+ .l2 xview
+} -cleanup {
+ destroy .l2
+} -result {0 1}
+
+test listbox-3.116 {ListboxWidgetCmd procedure, "xview" option} -constraints {
+ fonts
+} -setup {
+ destroy .l2
+ listbox .l2 -width 10 -height 5 -font $fixed
+ pack .l2
update
- .l xview
-} {0.4 0.6}
-test listbox-3.120 {ListboxWidgetCmd procedure, "xview" option} {fonts} {
+} -body {
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ .l2 insert 1 "0123456789a123456789b123456789c123456789d123456789"
+ .l2 xview 4
+ .l2 xview
+} -cleanup {
+ destroy .l2
+} -result {0.08 0.28}
+test listbox-3.117 {ListboxWidgetCmd procedure, "xview" option} -body {
+ .l xview foo
+} -returnCodes error -result {expected integer but got "foo"}
+test listbox-3.118 {ListboxWidgetCmd procedure, "xview" option} -body {
+ .l xview zoom a b
+} -returnCodes error -result {unknown option "zoom": must be moveto or scroll}
+test listbox-3.119 {ListboxWidgetCmd procedure, "xview" option} -constraints {
+ fonts
+} -setup {
+ destroy .l2
+ listbox .l2 -width 10 -height 5 -font $fixed
+ pack .l2
+ update
+} -body {
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ .l2 insert 1 "0123456789a123456789b123456789c123456789d123456789"
.l xview 0
- .l xview scroll 2 units
- update
- .l xview
-} {0.04 0.24}
-test listbox-3.121 {ListboxWidgetCmd procedure, "xview" option} {fonts} {
- .l xview 30
- .l xview scroll -1 pages
- update
- .l xview
-} {0.44 0.64}
-test listbox-3.122 {ListboxWidgetCmd procedure, "xview" option} {fonts} {
- .l configure -width 1
- update
- .l xview 30
- .l xview scroll -4 pages
- update
- .l xview
-} {0.52 0.54}
-test listbox-3.123 {ListboxWidgetCmd procedure, "yview" option} {
- catch {destroy .l}
- listbox .l
- pack .l
+ .l2 xview moveto .4
update
- .l yview
-} {0 1}
-test listbox-3.124 {ListboxWidgetCmd procedure, "yview" option} {
- catch {destroy .l}
- listbox .l
- .l insert 0 el1
- pack .l
+ .l2 xview
+} -cleanup {
+ destroy .l2
+} -result {0.4 0.6}
+test listbox-3.120 {ListboxWidgetCmd procedure, "xview" option} -constraints {
+ fonts
+} -setup {
+ destroy .l2
+ listbox .l2 -width 10 -height 5 -font $fixed
+ pack .l2
update
- .l yview
-} {0 1}
-catch {destroy .l}
-listbox .l -width 10 -height 5 -font $fixed
-.l insert 0 a b c d e f g h i j k l m n o p q r s t
-pack .l
-update
-test listbox-3.125 {ListboxWidgetCmd procedure, "yview" option} {
- .l yview 4
+} -body {
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ .l2 insert 1 "0123456789a123456789b123456789c123456789d123456789"
+ .l2 xview 0
+ .l2 xview scroll 2 units
+ update
+ .l2 xview
+} -cleanup {
+ destroy .l2
+} -result {0.04 0.24}
+test listbox-3.121 {ListboxWidgetCmd procedure, "xview" option} -constraints {
+ fonts
+} -setup {
+ destroy .l2
+ listbox .l2 -width 10 -height 5 -font $fixed
+ pack .l2
+ update
+} -body {
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ .l2 insert 1 "0123456789a123456789b123456789c123456789d123456789"
+ .l2 xview 30
+ .l2 xview scroll -1 pages
+ update
+ .l2 xview
+} -cleanup {
+ destroy .l2
+} -result {0.44 0.64}
+test listbox-3.122 {ListboxWidgetCmd procedure, "xview" option} -constraints {
+ fonts
+} -setup {
+ destroy .l2
+ listbox .l2 -width 10 -height 5 -font $fixed
+ pack .l2
+ update
+} -body {
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ .l2 insert 1 "0123456789a123456789b123456789c123456789d123456789"
+ .l2 configure -width 1
+ update
+ .l2 xview 30
+ .l2 xview scroll -4 pages
+ update
+ .l2 xview
+} -cleanup {
+ destroy .l2
+} -result {0.52 0.54}
+test listbox-3.123 {ListboxWidgetCmd procedure, "yview" option} -setup {
+ destroy .l2
+} -body {
+ listbox .l2
+ pack .l2
+ update
+ .l2 yview
+} -cleanup {
+ destroy .l2
+} -result {0 1}
+test listbox-3.124 {ListboxWidgetCmd procedure, "yview" option} -setup {
+ destroy .l2
+} -body {
+ listbox .l2
+ .l2 insert 0 el1
+ pack .l2
+ update
+ .l2 yview
+} -cleanup {
+ destroy .l2
+} -result {0 1}
+
+test listbox-3.125 {ListboxWidgetCmd procedure, "yview" option} -setup {
+ destroy .l2
+ listbox .l2 -width 10 -height 5 -font $fixed
+ pack .l2
+ update
+} -body {
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ .l2 yview 4
+ update
+ .l2 yview
+} -cleanup {
+ destroy .l2
+} -result {0.2 0.45}
+test listbox-3.126 {ListboxWidgetCmd procedure, "xview" option} -body {
+ .l yview foo
+} -returnCodes error -result {bad listbox index "foo": must be active, anchor, end, @x,y, or a number}
+test listbox-3.127 {ListboxWidgetCmd procedure, "xview" option} -body {
+ .l yview foo a b
+} -returnCodes error -result {unknown option "foo": must be moveto or scroll}
+test listbox-3.128 {ListboxWidgetCmd procedure, "xview" option} -setup {
+ destroy .l2
+ listbox .l2 -width 10 -height 5 -font $fixed
+ pack .l2
+ update
+} -body {
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ .l2 yview 0
+ .l2 yview moveto .31
+ .l2 yview
+} -cleanup {
+ destroy .l2
+} -result {0.3 0.55}
+test listbox-3.129 {ListboxWidgetCmd procedure, "xview" option} -setup {
+ destroy .l2
+ listbox .l2 -width 10 -height 5 -font $fixed
+ pack .l2
+ update
+} -body {
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ .l2 yview 2
+ .l2 yview scroll 2 pages
+ .l2 yview
+} -cleanup {
+ destroy .l2
+} -result {0.4 0.65}
+test listbox-3.130 {ListboxWidgetCmd procedure, "xview" option} -setup {
+ destroy .l2
+ listbox .l2 -width 10 -height 5 -font $fixed
+ pack .l2
+ update
+} -body {
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ .l2 yview 10
+ .l2 yview scroll -3 units
+ .l2 yview
+} -cleanup {
+ destroy .l2
+} -result {0.35 0.6}
+test listbox-3.131 {ListboxWidgetCmd procedure, "xview" option} -setup {
+ destroy .l2
+ listbox .l2 -width 10 -height 5 -font $fixed
+ pack .l2
+ update
+} -body {
+ .l2 insert 0 a b c d e f g h i j k l m n o p q r s t
+ .l2 configure -height 2
+ update
+ .l2 yview 15
+ .l2 yview scroll -4 pages
+ .l2 yview
+} -cleanup {
+ destroy .l2
+} -result {0.55 0.65}
+test listbox-3.132 {ListboxWidgetCmd procedure, "xview" option} -body {
+ .l whoknows
+} -returnCodes error -result {bad option "whoknows": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}
+test listbox-3.133 {ListboxWidgetCmd procedure, "xview" option} -body {
+ .l c
+} -returnCodes error -result {ambiguous option "c": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}
+test listbox-3.134 {ListboxWidgetCmd procedure, "xview" option} -body {
+ .l in
+} -returnCodes error -result {ambiguous option "in": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}
+test listbox-3.135 {ListboxWidgetCmd procedure, "xview" option} -body {
+ .l s
+} -returnCodes error -result {ambiguous option "s": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}
+test listbox-3.136 {ListboxWidgetCmd procedure, "xview" option} -body {
+ .l se
+} -returnCodes error -result {ambiguous option "se": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}
+
+test listbox-3.137 {ListboxWidgetCmd procedure, "yview" option, partial last line} -setup {
+ destroy .l
+ listbox .l -width 10 -height 5 -font $fixed
+ pack .l
update
- .l yview
-} {0.2 0.45}
-test listbox-3.126 {ListboxWidgetCmd procedure, "yview" option, partial last line} {
+} -body {
+ .l insert 0 a b c d e f g h i j k l m n o p q r s t
mkPartial
.partial.l yview
-} {0 0.266667}
-test listbox-3.127 {ListboxWidgetCmd procedure, "xview" option} {
- list [catch {.l yview foo} msg] $msg
-} {1 {bad listbox index "foo": must be active, anchor, end, @x,y, or a number}}
-test listbox-3.128 {ListboxWidgetCmd procedure, "xview" option} {
- list [catch {.l yview foo a b} msg] $msg
-} {1 {unknown option "foo": must be moveto or scroll}}
-test listbox-3.129 {ListboxWidgetCmd procedure, "xview" option} {
- .l yview 0
- .l yview moveto .31
- .l yview
-} {0.3 0.55}
-test listbox-3.130 {ListboxWidgetCmd procedure, "xview" option} {
- .l yview 2
- .l yview scroll 2 pages
- .l yview
-} {0.4 0.65}
-test listbox-3.131 {ListboxWidgetCmd procedure, "xview" option} {
- .l yview 10
- .l yview scroll -3 units
- .l yview
-} {0.35 0.6}
-test listbox-3.132 {ListboxWidgetCmd procedure, "xview" option} {
- .l configure -height 2
- update
- .l yview 15
- .l yview scroll -4 pages
- .l yview
-} {0.55 0.65}
-test listbox-3.133 {ListboxWidgetCmd procedure, "xview" option} {
- list [catch {.l whoknows} msg] $msg
-} {1 {bad option "whoknows": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}}
-test listbox-3.134 {ListboxWidgetCmd procedure, "xview" option} {
- list [catch {.l c} msg] $msg
-} {1 {ambiguous option "c": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}}
-test listbox-3.135 {ListboxWidgetCmd procedure, "xview" option} {
- list [catch {.l in} msg] $msg
-} {1 {ambiguous option "in": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}}
-test listbox-3.136 {ListboxWidgetCmd procedure, "xview" option} {
- list [catch {.l s} msg] $msg
-} {1 {ambiguous option "s": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}}
-test listbox-3.137 {ListboxWidgetCmd procedure, "xview" option} {
- list [catch {.l se} msg] $msg
-} {1 {ambiguous option "se": must be activate, bbox, cget, configure, curselection, delete, get, index, insert, itemcget, itemconfigure, nearest, scan, see, selection, size, xview, or yview}}
+} -cleanup {
+ destroy .l
+} -result {0 0.266667}
# No tests for DestroyListbox: I can't come up with anything to test
# in this procedure.
-test listbox-4.1 {ConfigureListbox procedure} {fonts} {
- catch {destroy .l}
+
+test listbox-4.1 {ConfigureListbox procedure} -constraints {
+ fonts
+} -setup {
+ deleteWindows
+ destroy .l
listbox .l -setgrid 1 -width 25 -height 15
pack .l
update
+} -body {
set x [getsize .]
.l configure -setgrid 0
update
list $x [getsize .]
-} {25x15 185x263}
+} -cleanup {
+ deleteWindows
+} -result {25x15 185x263}
resetGridInfo
-test listbox-4.2 {ConfigureListbox procedure} {
+test listbox-4.2 {ConfigureListbox procedure} -setup {
+ deleteWindows
+ destroy .l
+ listbox .l -setgrid 1 -width 25 -height 15
+ pack .l
+ update
+} -body {
.l configure -highlightthickness -3
.l cget -highlightthickness
-} {0}
-test listbox-4.3 {ConfigureListbox procedure} {
+} -cleanup {
+ deleteWindows
+} -result {0}
+test listbox-4.3 {ConfigureListbox procedure} -setup {
+ deleteWindows
+ destroy .l
+ listbox .l -setgrid 1 -width 25 -height 15
+ pack .l
+ update
+} -body {
.l configure -exportselection 0
.l delete 0 end
.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8
.l selection set 3 5
.l configure -exportselection 1
selection get
-} {el3
+} -cleanup {
+ deleteWindows
+} -result {el3
el4
el5}
-test listbox-4.4 {ConfigureListbox procedure} {
- catch {destroy .e}
+test listbox-4.4 {ConfigureListbox procedure} -setup {
+ deleteWindows
+ listbox .l -setgrid 1 -width 25 -height 15
+ pack .l
+ update
+} -body {
entry .e
.e insert 0 abc
.e select from 0
@@ -794,8 +1204,15 @@ test listbox-4.4 {ConfigureListbox procedure} {
.l selection clear 3 5
.l configure -exportselection 1
list [selection own] [selection get]
-} {.e ab}
-test listbox-4.5 {-exportselection option} {
+} -cleanup {
+ deleteWindows
+} -result {.e ab}
+test listbox-4.5 {-exportselection option} -setup {
+ deleteWindows
+ listbox .l -setgrid 1 -width 25 -height 15
+ pack .l
+ update
+} -body {
selection clear .
.l configure -exportselection 1
.l delete 0 end
@@ -811,11 +1228,16 @@ test listbox-4.5 {-exportselection option} {
lappend x [catch {selection get} msg] $msg [.l curselection]
.l config -exportselection 1
lappend x [catch {selection get} msg] $msg [.l curselection]
-} {0 el1 1 1 {PRIMARY selection doesn't exist or form "STRING" not defined} 1 1 {PRIMARY selection doesn't exist or form "STRING" not defined} {} 1 {PRIMARY selection doesn't exist or form "STRING" not defined} {1 2 3} 0 {el1
+} -cleanup {
+ deleteWindows
+} -result {0 el1 1 1 {PRIMARY selection doesn't exist or form "STRING" not defined} 1 1 {PRIMARY selection doesn't exist or form "STRING" not defined} {} 1 {PRIMARY selection doesn't exist or form "STRING" not defined} {1 2 3} 0 {el1
el2
el3} {1 2 3}}
-test listbox-4.6 {ConfigureListbox procedure} {fonts} {
- catch {destroy .l}
+test listbox-4.6 {ConfigureListbox procedure} -constraints {
+ fonts
+} -setup {
+ deleteWindows
+} -body {
# The following code (reset geometry, withdraw, etc.) is necessary
# to reset the state of some window managers like olvwm under
@@ -825,265 +1247,329 @@ test listbox-4.6 {ConfigureListbox procedure} {fonts} {
update
wm geom . {}
wm withdraw .
- listbox .l -font $fixed -width 15 -height 20
- pack .l
+ listbox .l2 -font $fixed -width 15 -height 20
+ pack .l2
update
wm deiconify .
set x [getsize .]
- .l configure -setgrid 1
+ .l2 configure -setgrid 1
update
list $x [getsize .]
-} {115x328 15x20}
-test listbox-4.7 {ConfigureListbox procedure} {
- catch {destroy .l}
+} -cleanup {
+ deleteWindows
+} -result {115x328 15x20}
+test listbox-4.7 {ConfigureListbox procedure} -setup {
+ deleteWindows
+} -body {
wm withdraw .
- listbox .l -font $fixed -width 30 -height 20 -setgrid 1
+ listbox .l2 -font $fixed -width 30 -height 20 -setgrid 1
wm geom . +25+25
- pack .l
+ pack .l2
update
wm deiconify .
set result [getsize .]
wm geom . 26x15
update
lappend result [getsize .]
- .l configure -setgrid 1
+ .l2 configure -setgrid 1
update
lappend result [getsize .]
-} {30x20 26x15 26x15}
-wm geom . {}
-catch {destroy .l}
+} -cleanup {
+ deleteWindows
+ wm geom . {}
+} -result {30x20 26x15 26x15}
+
resetGridInfo
-test listbox-4.8 {ConfigureListbox procedure} {
- catch {destroy .l}
- listbox .l -width 15 -height 20 -xscrollcommand "record x" \
+test listbox-4.8 {ConfigureListbox procedure} -setup {
+ destroy .l2
+} -body {
+ listbox .l2 -width 15 -height 20 -xscrollcommand "record x" \
-yscrollcommand "record y"
- pack .l
+ pack .l2
update
- .l configure -fg black
+ .l2 configure -fg black
set log {}
update
- set log
-} {{y 0 1} {x 0 1}}
-test listbox-4.9 {ConfigureListbox procedure, -listvar} {
- catch {destroy .l}
+ return $log
+} -cleanup {
+ destroy .l2
+} -result {{y 0 1} {x 0 1}}
+test listbox-4.9 {ConfigureListbox procedure, -listvar} -setup {
+ destroy .l2
+} -body {
set x [list a b c d]
- listbox .l -listvar x
- .l get 0 end
-} [list a b c d]
-test listbox-4.10 {ConfigureListbox, no listvar -> existing listvar} {
- catch {destroy .l}
+ listbox .l2 -listvar x
+ .l2 get 0 end
+} -cleanup {
+ destroy .l2
+} -result [list a b c d]
+test listbox-4.10 {ConfigureListbox, no listvar -> existing listvar} -setup {
+ destroy .l2
+} -body {
set x [list a b c d]
- listbox .l
- .l insert end 1 2 3 4
- .l configure -listvar x
- .l get 0 end
-} [list a b c d]
-test listbox-4.11 {ConfigureListbox procedure, listvar -> no listvar} {
- catch {destroy .l}
+ listbox .l2
+ .l2 insert end 1 2 3 4
+ .l2 configure -listvar x
+ .l2 get 0 end
+} -cleanup {
+ destroy .l2
+} -result [list a b c d]
+test listbox-4.11 {ConfigureListbox procedure, listvar -> no listvar} -setup {
+ destroy .l2
+} -body {
set x [list a b c d]
- listbox .l -listvar x
- .l configure -listvar {}
- .l insert end 1 2 3 4
- list $x [.l get 0 end]
-} [list [list a b c d] [list a b c d 1 2 3 4]]
-test listbox-4.12 {ConfigureListbox procedure, listvar -> different listvar} {
- catch {destroy .l}
+ listbox .l2 -listvar x
+ .l2 configure -listvar {}
+ .l2 insert end 1 2 3 4
+ list $x [.l2 get 0 end]
+} -cleanup {
+ destroy .l2
+} -result [list [list a b c d] [list a b c d 1 2 3 4]]
+test listbox-4.12 {ConfigureListbox procedure, listvar -> different listvar} -setup {
+ destroy .l2
+} -body {
set x [list a b c d]
set y [list 1 2 3 4]
- listbox .l
- .l configure -listvar x
- .l configure -listvar y
- .l insert end 5 6 7 8
+ listbox .l2
+ .l2 configure -listvar x
+ .l2 configure -listvar y
+ .l2 insert end 5 6 7 8
list $x $y
-} [list [list a b c d] [list 1 2 3 4 5 6 7 8]]
-test listbox-4.13 {ConfigureListbox, no listvar -> non-existant listvar} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l2
+} -result [list [list a b c d] [list 1 2 3 4 5 6 7 8]]
+test listbox-4.13 {ConfigureListbox, no listvar -> non-existant listvar} -setup {
+ destroy .l2
+} -body {
catch {unset x}
- listbox .l
- .l insert end a b c d
- .l configure -listvar x
- set x
-} [list a b c d]
-test listbox-4.14 {ConfigureListbox, non-existant listvar} {
- catch {destroy .l}
+ listbox .l2
+ .l2 insert end a b c d
+ .l2 configure -listvar x
+ return $x
+} -cleanup {
+ destroy .l2
+} -result [list a b c d]
+test listbox-4.14 {ConfigureListbox, non-existant listvar} -setup {
+ destroy .l2
+} -body {
catch {unset x}
- listbox .l -listvar x
+ listbox .l2 -listvar x
list [info exists x] $x
-} [list 1 {}]
-test listbox-4.15 {ConfigureListbox, listvar -> non-existant listvar} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l2
+} -result [list 1 {}]
+test listbox-4.15 {ConfigureListbox, listvar -> non-existant listvar} -setup {
+ destroy .l2
+} -body {
catch {unset y}
set x [list a b c d]
- listbox .l -listvar x
- .l configure -listvar y
+ listbox .l2 -listvar x
+ .l2 configure -listvar y
list [info exists y] $y
-} [list 1 [list a b c d]]
-test listbox-4.16 {ConfigureListbox, listvar -> same listvar} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l2
+} -result [list 1 [list a b c d]]
+test listbox-4.16 {ConfigureListbox, listvar -> same listvar} -setup {
+ destroy .l2
+} -body {
set x [list a b c d]
- listbox .l -listvar x
- .l configure -listvar x
- set x
-} [list a b c d]
-test listbox-4.17 {ConfigureListbox, no listvar -> no listvar} {
- catch {destroy .l}
- listbox .l
- .l insert end a b c d
- .l configure -listvar {}
- .l get 0 end
-} [list a b c d]
-test listbox-4.18 {ConfigureListbox, no listvar -> bad listvar} {
- catch {destroy .l}
- listbox .l
- .l insert end a b c d
+ listbox .l2 -listvar x
+ .l2 configure -listvar x
+ return $x
+} -cleanup {
+ destroy .l2
+} -result [list a b c d]
+test listbox-4.17 {ConfigureListbox, no listvar -> no listvar} -setup {
+ destroy .l2
+} -body {
+ listbox .l2
+ .l2 insert end a b c d
+ .l2 configure -listvar {}
+ .l2 get 0 end
+} -cleanup {
+ destroy .l2
+} -result [list a b c d]
+test listbox-4.18 {ConfigureListbox, no listvar -> bad listvar} -setup {
+ destroy .l2
+} -body {
+ listbox .l2
+ .l2 insert end a b c d
set x "this is a \" bad list"
- catch {.l configure -listvar x} result
- list [.l get 0 end] [.l cget -listvar] $result
-} [list [list a b c d] {} \
+ catch {.l2 configure -listvar x} result
+ list [.l2 get 0 end] [.l2 cget -listvar] $result
+} -cleanup {
+ destroy .l2
+} -result [list [list a b c d] {} \
"unmatched open quote in list: invalid -listvariable value"]
-test listbox-4.19 {ConfigureListbox, no listvar -> bad non-existent listvar} {
- catch {destroy .l}
+test listbox-4.19 {ConfigureListbox, no listvar -> bad non-existent listvar} -setup {
+ destroy .l2
+} -body {
unset -nocomplain ::foo
- listbox .l -listvar foo
- .l insert end a b c d
- catch {.l configure -listvar ::zoo::bar::foo} result
- list [.l get 0 end] [.l cget -listvar] $foo $result
-} [list [list a b c d] foo [list a b c d] \
+ listbox .l2 -listvar foo
+ .l2 insert end a b c d
+ catch {.l2 configure -listvar ::zoo::bar::foo} result
+ list [.l2 get 0 end] [.l2 cget -listvar] $foo $result
+} -cleanup {
+ destroy .l2
+} -result [list [list a b c d] foo [list a b c d] \
{can't set "::zoo::bar::foo": parent namespace doesn't exist}]
+
# No tests for DisplayListbox: I don't know how to test this procedure.
-test listbox-5.1 {ListboxComputeGeometry procedure} {fonts} {
- catch {destroy .l}
+test listbox-5.1 {ListboxComputeGeometry procedure} -constraints {
+ fonts
+} -setup {
+ destroy .l
+} -body {
listbox .l -font $fixed -width 15 -height 20
pack .l
list [winfo reqwidth .l] [winfo reqheight .l]
-} {115 328}
-test listbox-5.2 {ListboxComputeGeometry procedure} {fonts} {
- catch {destroy .l}
+} -result {115 328}
+test listbox-5.2 {ListboxComputeGeometry procedure} -constraints {
+ fonts
+} -setup {
+ destroy .l
+} -body {
listbox .l -font $fixed -width 0 -height 10
pack .l
update
list [winfo reqwidth .l] [winfo reqheight .l]
-} {17 168}
-test listbox-5.3 {ListboxComputeGeometry procedure} {fonts} {
- catch {destroy .l}
+} -result {17 168}
+test listbox-5.3 {ListboxComputeGeometry procedure} -constraints {
+ fonts
+} -setup {
+ destroy .l
+} -body {
listbox .l -font $fixed -width 0 -height 10 -bd 3
.l insert 0 Short "Really much longer" Longer
pack .l
update
list [winfo reqwidth .l] [winfo reqheight .l]
-} {138 170}
-test listbox-5.4 {ListboxComputeGeometry procedure} {fonts} {
- catch {destroy .l}
+} -result {138 170}
+test listbox-5.4 {ListboxComputeGeometry procedure} -constraints {
+ fonts
+} -setup {
+ destroy .l
+} -body {
listbox .l -font $fixed -width 10 -height 0
pack .l
update
list [winfo reqwidth .l] [winfo reqheight .l]
-} {80 24}
-test listbox-5.5 {ListboxComputeGeometry procedure} {fonts} {
- catch {destroy .l}
+} -result {80 24}
+test listbox-5.5 {ListboxComputeGeometry procedure} -constraints {
+ fonts
+} -setup {
+ destroy .l
+} -body {
listbox .l -font $fixed -width 10 -height 0 -highlightthickness 0
.l insert 0 Short "Really much longer" Longer
pack .l
update
list [winfo reqwidth .l] [winfo reqheight .l]
-} {76 52}
-test listbox-5.6 {ListboxComputeGeometry procedure} {
+} -result {76 52}
+test listbox-5.6 {ListboxComputeGeometry procedure} -setup {
+ destroy .l
+} -body {
# If "0" in selected font had 0 width, caused divide-by-zero error.
- catch {destroy .l}
pack [listbox .l -font {{open look glyph}}]
update
-} {}
+} -cleanup {
+ destroy .l
+} -result {}
-catch {destroy .l}
+# Listbox used in 6.*, 7.* tests
+destroy .l
listbox .l -height 2 -xscrollcommand "record x" -yscrollcommand "record y"
pack .l
update
-test listbox-6.1 {InsertEls procedure} {
+test listbox-6.1 {InsertEls procedure} -body {
.l delete 0 end
.l insert end a b c d
.l insert 5 x y z
.l insert 2 A
.l insert 0 q r s
.l get 0 end
-} {q r s a b A c d x y z}
-test listbox-6.2 {InsertEls procedure} {
+} -result {q r s a b A c d x y z}
+test listbox-6.2 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 2
.l insert 2 A B
.l index anchor
-} {4}
-test listbox-6.3 {InsertEls procedure} {
+} -result {4}
+test listbox-6.3 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 2
.l insert 3 A B
.l index anchor
-} {2}
-test listbox-6.4 {InsertEls procedure} {
+} -result {2}
+test listbox-6.4 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l insert 2 A B
.l index @0,0
-} {5}
-test listbox-6.5 {InsertEls procedure} {
+} -result {5}
+test listbox-6.5 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l insert 3 A B
.l index @0,0
-} {3}
-test listbox-6.6 {InsertEls procedure} {
+} -result {3}
+test listbox-6.6 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 5
.l insert 5 A B
.l index active
-} {7}
-test listbox-6.7 {InsertEls procedure} {
+} -result {7}
+test listbox-6.7 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 5
.l insert 6 A B
.l index active
-} {5}
-test listbox-6.8 {InsertEls procedure} {
+} -result {5}
+test listbox-6.8 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b c
.l index active
-} {2}
-test listbox-6.9 {InsertEls procedure} {
+} -result {2}
+test listbox-6.9 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0
.l index active
-} {0}
-test listbox-6.10 {InsertEls procedure} {
+} -result {0}
+test listbox-6.10 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b "two words" c d e f g h i j
update
set log {}
.l insert 0 word
update
- set log
-} {{y 0 0.166667}}
-test listbox-6.11 {InsertEls procedure} {
+ return $log
+} -result {{y 0 0.166667}}
+test listbox-6.11 {InsertEls procedure} -body {
.l delete 0 end
.l insert 0 a b "two words" c d e f g h i j
update
set log {}
.l insert 0 "much longer entry"
update
- set log
-} {{y 0 0.166667} {x 0 1}}
-test listbox-6.12 {InsertEls procedure} {fonts} {
- catch {destroy .l2}
+ return $log
+} -result {{y 0 0.166667} {x 0 1}}
+test listbox-6.12 {InsertEls procedure} -constraints {
+ fonts
+} -setup {
+ destroy .l2
+} -body {
listbox .l2 -width 0 -height 0
pack .l2 -side top
.l2 insert 0 a b "two words" c d
@@ -1091,23 +1577,31 @@ test listbox-6.12 {InsertEls procedure} {fonts} {
lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
.l2 insert 0 "much longer entry"
lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
-} {80 93 122 110}
-test listbox-6.13 {InsertEls procedure, check -listvar update} {
- catch {destroy .l2}
+} -cleanup {
+ destroy .l2
+} -result {80 93 122 110}
+test listbox-6.13 {InsertEls procedure, check -listvar update} -setup {
+ destroy .l2
+} -body {
set x [list a b c d]
listbox .l2 -listvar x
.l2 insert 0 1 2 3 4
- set x
-} [list 1 2 3 4 a b c d]
-test listbox-6.14 {InsertEls procedure, check selection update} {
- catch {destroy .l2}
+ return $x
+} -cleanup {
+ destroy .l2
+} -result [list 1 2 3 4 a b c d]
+test listbox-6.14 {InsertEls procedure, check selection update} -setup {
+ destroy .l2
+} -body {
listbox .l2
.l2 insert 0 0 1 2 3 4
.l2 selection set 2 4
.l2 insert 0 a
.l2 curselection
-} [list 3 4 5]
-test listbox-6.15 {InsertEls procedure, lost namespaced listvar} {
+} -cleanup {
+ destroy .l2
+} -result [list 3 4 5]
+test listbox-6.15 {InsertEls procedure, lost namespaced listvar} -body {
destroy .l2
namespace eval test { variable foo {a b} }
listbox .l2 -listvar ::test::foo
@@ -1117,156 +1611,161 @@ test listbox-6.15 {InsertEls procedure, lost namespaced listvar} {
.l2 insert end e f
catch {set ::test::foo} result
list [.l2 get 0 end] [.l2 cget -listvar] $result
-} [list [list a b c e f] ::test::foo \
+} -cleanup {
+ destroy .l2
+} -result [list [list a b c e f] ::test::foo \
{can't read "::test::foo": no such variable}]
-test listbox-7.1 {DeleteEls procedure} {
+test listbox-7.1 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection set 1 6
.l delete 4 3
list [.l size] [selection get]
-} {10 {b
+} -result {10 {b
c
d
e
f
g}}
-test listbox-7.2 {DeleteEls procedure} {
+test listbox-7.2 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection set 3 6
.l delete 4 4
list [.l size] [.l get 4] [.l curselection]
-} {9 f {3 4 5}}
-test listbox-7.3 {DeleteEls procedure} {
+} -result {9 f {3 4 5}}
+test listbox-7.3 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l delete 0 3
list [.l size] [.l get 0] [.l get 1]
-} {6 e f}
-test listbox-7.4 {DeleteEls procedure} {
+} -result {6 e f}
+test listbox-7.4 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l delete 8 1000
list [.l size] [.l get 7]
-} {8 h}
-test listbox-7.5 {DeleteEls procedure} {
+} -result {8 h}
+test listbox-7.5 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 2
.l delete 0 1
.l index anchor
-} {0}
-test listbox-7.6 {DeleteEls procedure} {
+} -result {0}
+test listbox-7.6 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 2
.l delete 2
.l index anchor
-} {2}
-test listbox-7.7 {DeleteEls procedure} {
+} -result {2}
+test listbox-7.7 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 4
.l delete 2 5
.l index anchor
-} {2}
-test listbox-7.8 {DeleteEls procedure} {
+} -result {2}
+test listbox-7.8 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l selection anchor 3
.l delete 4 5
.l index anchor
-} {3}
-test listbox-7.9 {DeleteEls procedure} {
+} -result {3}
+test listbox-7.9 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l delete 1 2
.l index @0,0
-} {1}
-test listbox-7.10 {DeleteEls procedure} {
+} -result {1}
+test listbox-7.10 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l delete 3 4
.l index @0,0
-} {3}
-test listbox-7.11 {DeleteEls procedure} {
+} -result {3}
+test listbox-7.11 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l delete 4 6
.l index @0,0
-} {3}
-test listbox-7.12 {DeleteEls procedure} {
+} -result {3}
+test listbox-7.12 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l yview 3
update
.l delete 3 end
.l index @0,0
-} {1}
-test listbox-7.13 {DeleteEls procedure, updating view with partial last line} {
+} -result {1}
+test listbox-7.13 {DeleteEls procedure, updating view with partial last line} -body {
mkPartial
.partial.l yview 8
update
.partial.l delete 10 13
.partial.l index @0,0
-} {7}
-test listbox-7.14 {DeleteEls procedure} {
+} -result {7}
+test listbox-7.14 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 6
.l delete 3 4
.l index active
-} {4}
-test listbox-7.15 {DeleteEls procedure} {
+} -result {4}
+test listbox-7.15 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 6
.l delete 5 7
.l index active
-} {5}
-test listbox-7.16 {DeleteEls procedure} {
+} -result {5}
+test listbox-7.16 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 6
.l delete 5 end
.l index active
-} {4}
-test listbox-7.17 {DeleteEls procedure} {
+} -result {4}
+test listbox-7.17 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j
.l activate 6
.l delete 0 end
.l index active
-} {0}
-test listbox-7.18 {DeleteEls procedure} {
+} -result {0}
+test listbox-7.18 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c "two words" d e f g h i j
update
set log {}
.l delete 4 6
update
- set log
-} {{y 0 0.25}}
-test listbox-7.19 {DeleteEls procedure} {
+ return $log
+} -result {{y 0 0.25}}
+test listbox-7.19 {DeleteEls procedure} -body {
.l delete 0 end
.l insert 0 a b c "two words" d e f g h i j
update
set log {}
.l delete 3
update
- set log
-} {{y 0 0.2} {x 0 1}}
-test listbox-7.20 {DeleteEls procedure} {fonts} {
- catch {destroy .l2}
+ return $log
+} -result {{y 0 0.2} {x 0 1}}
+test listbox-7.20 {DeleteEls procedure} -constraints {
+ fonts
+} -setup {
+ destroy .l2
+} -body {
listbox .l2 -width 0 -height 0
pack .l2 -side top
.l2 insert 0 a b "two words" c d e f g
@@ -1274,28 +1773,37 @@ test listbox-7.20 {DeleteEls procedure} {fonts} {
lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
.l2 delete 2 4
lappend x [winfo reqwidth .l2] [winfo reqheight .l2]
-} {80 144 17 93}
-catch {destroy .l2}
-test listbox-7.21 {DeleteEls procedure, check -listvar update} {
- catch {destroy .l2}
+} -result {80 144 17 93}
+test listbox-7.21 {DeleteEls procedure, check -listvar update} -setup {
+ destroy .l2
+} -body {
set x [list a b c d]
listbox .l2 -listvar x
.l2 delete 0 1
- set x
-} [list c d]
+ return $x
+} -result [list c d]
-test listbox-8.1 {ListboxEventProc procedure} {fonts} {
- catch {destroy .l}
+
+test listbox-8.1 {ListboxEventProc procedure} -constraints {
+ fonts
+} -setup {
+ destroy .l
+} -body {
listbox .l -setgrid 1
pack .l
update
set x [getsize .]
destroy .l
list $x [getsize .] [winfo exists .l] [info command .l]
-} {20x10 150x178 0 {}}
+} -cleanup {
+ destroy .l
+} -result {20x10 150x178 0 {}}
resetGridInfo
-test listbox-8.2 {ListboxEventProc procedure} {fonts} {
- catch {destroy .l}
+test listbox-8.2 {ListboxEventProc procedure} -constraints {
+ fonts
+} -setup {
+ destroy .l
+} -body {
listbox .l -height 5 -width 10
.l insert 0 a b c "A string that is very very long" d e f g h i j k
pack .l
@@ -1303,9 +1811,12 @@ test listbox-8.2 {ListboxEventProc procedure} {fonts} {
place .l -width 50 -height 80
update
list [.l xview] [.l yview]
-} {{0 0.222222} {0 0.333333}}
-test listbox-8.3 {ListboxEventProc procedure} {
+} -cleanup {
+ destroy .l
+} -result {{0 0.222222} {0 0.333333}}
+test listbox-8.3 {ListboxEventProc procedure} -setup {
deleteWindows
+} -body {
listbox .l1 -bg #543210
rename .l1 .l2
set x {}
@@ -1313,107 +1824,257 @@ test listbox-8.3 {ListboxEventProc procedure} {
lappend x [.l2 cget -bg]
destroy .l1
lappend x [info command .l*] [winfo children .]
-} {.l1 #543210 {} {}}
+} -cleanup {
+ deleteWindows
+} -result {.l1 #543210 {} {}}
+
-test listbox-9.1 {ListboxCmdDeletedProc procedure} {
+test listbox-9.1 {ListboxCmdDeletedProc procedure} -setup {
deleteWindows
+} -body {
listbox .l1
rename .l1 {}
list [info command .l*] [winfo children .]
-} {{} {}}
-test listbox-9.2 {ListboxCmdDeletedProc procedure, disabling -setgrid} fonts {
- catch {destroy .top}
+} -cleanup {
+ deleteWindows
+} -result {{} {}}
+test listbox-9.2 {ListboxCmdDeletedProc procedure, disabling -setgrid} -constraints {
+ fonts
+} -setup {
+ destroy .top
+} -body {
toplevel .top
wm geom .top +0+0
listbox .top.l -setgrid 1 -width 20 -height 10
pack .top.l
update
- set x [wm geometry .top]
+ set x [getsize .top]
rename .top.l {}
update
- lappend x [wm geometry .top]
+ lappend x [getsize .top]
+} -cleanup {
destroy .top
- set x
-} {20x10+0+0 150x178+0+0}
+} -result {20x10 150x178}
-catch {destroy .l}
-listbox .l
-pack .l
-.l delete 0 end
-.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
-test listbox-10.1 {GetListboxIndex procedure} {
+
+# Listbox used in 10.* tests
+destroy .l
+test listbox-10.1 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
.l activate 3
+ update
list [.l activate 3; .l index active] [.l activate 6; .l index active]
-} {3 6}
-test listbox-10.2 {GetListboxIndex procedure} {
+} -cleanup {
+ destroy .l
+} -result {3 6}
+test listbox-10.2 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
.l selection anchor 2
+ update
.l index anchor
-} 2
-test listbox-10.3 {GetListboxIndex procedure} {
+} -cleanup {
+ destroy .l
+} -result 2
+test listbox-10.3 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
.l insert end A B C D E
.l selection anchor end
+ update
.l delete 12 end
list [.l index anchor] [.l index end]
-} {12 12}
-test listbox-10.4 {GetListboxIndex procedure} {
- list [catch {.l index a} msg] $msg
-} {1 {bad listbox index "a": must be active, anchor, end, @x,y, or a number}}
-test listbox-10.5 {GetListboxIndex procedure} {
+} -cleanup {
+ destroy .l
+} -result {12 12}
+test listbox-10.4 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
+ .l index a
+} -cleanup {
+ destroy .l
+} -returnCodes error -result {bad listbox index "a": must be active, anchor, end, @x,y, or a number}
+test listbox-10.5 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
.l index end
-} {12}
-test listbox-10.6 {GetListboxIndex procedure} {
+} -cleanup {
+ destroy .l
+} -result {12}
+test listbox-10.6 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
.l get end
-} {el11}
-test listbox-10.7 {GetListboxIndex procedure} {
+} -cleanup {
+ destroy .l
+} -result {el11}
+test listbox-10.7 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
.l delete 0 end
+ update
.l index end
-} 0
-.l delete 0 end
-.l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
-update
-test listbox-10.8 {GetListboxIndex procedure} {
- list [catch {.l index @} msg] $msg
-} {1 {bad listbox index "@": must be active, anchor, end, @x,y, or a number}}
-test listbox-10.9 {GetListboxIndex procedure} {
- list [catch {.l index @foo} msg] $msg
-} {1 {bad listbox index "@foo": must be active, anchor, end, @x,y, or a number}}
-test listbox-10.10 {GetListboxIndex procedure} {
- list [catch {.l index @1x3} msg] $msg
-} {1 {bad listbox index "@1x3": must be active, anchor, end, @x,y, or a number}}
-test listbox-10.11 {GetListboxIndex procedure} {
- list [catch {.l index @1,} msg] $msg
-} {1 {bad listbox index "@1,": must be active, anchor, end, @x,y, or a number}}
-test listbox-10.12 {GetListboxIndex procedure} {
- list [catch {.l index @1,foo} msg] $msg
-} {1 {bad listbox index "@1,foo": must be active, anchor, end, @x,y, or a number}}
-test listbox-10.13 {GetListboxIndex procedure} {
- list [catch {.l index @1,2x} msg] $msg
-} {1 {bad listbox index "@1,2x": must be active, anchor, end, @x,y, or a number}}
-test listbox-10.14 {GetListboxIndex procedure} {fonts} {
+} -cleanup {
+ destroy .l
+} -result 0
+test listbox-10.8 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
+ .l index @
+} -cleanup {
+ destroy .l
+} -returnCodes error -result {bad listbox index "@": must be active, anchor, end, @x,y, or a number}
+test listbox-10.9 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
+ .l index @foo
+} -cleanup {
+ destroy .l
+} -returnCodes error -result {bad listbox index "@foo": must be active, anchor, end, @x,y, or a number}
+test listbox-10.10 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
+ .l index @1x3
+} -cleanup {
+ destroy .l
+} -returnCodes error -result {bad listbox index "@1x3": must be active, anchor, end, @x,y, or a number}
+test listbox-10.11 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
+ .l index @1,
+} -cleanup {
+ destroy .l
+} -returnCodes error -result {bad listbox index "@1,": must be active, anchor, end, @x,y, or a number}
+test listbox-10.12 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
+ .l index @1,foo
+} -cleanup {
+ destroy .l
+} -returnCodes error -result {bad listbox index "@1,foo": must be active, anchor, end, @x,y, or a number}
+test listbox-10.13 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
+ .l index @1,2x
+} -cleanup {
+ destroy .l
+} -returnCodes error -result {bad listbox index "@1,2x": must be active, anchor, end, @x,y, or a number}
+test listbox-10.14 {GetListboxIndex procedure} -constraints {
+ fonts
+} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
list [.l index @5,57] [.l index @5,58]
-} {3 3}
-test listbox-10.15 {GetListboxIndex procedure} {
- list [catch {.l index 1xy} msg] $msg
-} {1 {bad listbox index "1xy": must be active, anchor, end, @x,y, or a number}}
-test listbox-10.16 {GetListboxIndex procedure} {
+} -cleanup {
+ .l delete 0 end
+} -cleanup {
+ destroy .l
+} -result {3 3}
+test listbox-10.15 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
+ .l index 1xy
+} -cleanup {
+ destroy .l
+} -returnCodes error -result {bad listbox index "1xy": must be active, anchor, end, @x,y, or a number}
+test listbox-10.16 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
.l index 3
-} {3}
-test listbox-10.17 {GetListboxIndex procedure} {
+} -cleanup {
+ destroy .l
+} -result {3}
+test listbox-10.17 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
.l index 20
-} {20}
-test listbox-10.18 {GetListboxIndex procedure} {
+} -cleanup {
+ destroy .l
+} -result {20}
+test listbox-10.18 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
.l get 20
-} {}
-test listbox-10.19 {GetListboxIndex procedure} {
+} -cleanup {
+ destroy .l
+} -result {}
+test listbox-10.19 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
+ update
.l index -2
-} -2
-test listbox-10.20 {GetListboxIndex procedure} {
+} -cleanup {
+ destroy .l
+} -result -2
+test listbox-10.20 {GetListboxIndex procedure} -setup {
+ destroy .l
+} -body {
+ pack [listbox .l]
+ .l insert 0 el0 el1 el2 el3 el4 el5 el6 el7 el8 el9 el10 el11
.l delete 0 end
+ update
.l index 1
-} 1
+} -cleanup {
+ destroy .l
+} -result 1
+
-test listbox-11.1 {ChangeListboxView procedure, boundary conditions for index} {
- catch {destroy .l}
+test listbox-11.1 {ChangeListboxView procedure, boundary conditions for index} -setup {
+ destroy .l
+} -body {
listbox .l -height 5
pack .l
.l insert 0 a b c d e f g h i j
@@ -1423,9 +2084,12 @@ test listbox-11.1 {ChangeListboxView procedure, boundary conditions for index} {
.l yview -1
update
lappend x [.l index @0,0]
-} {3 0}
-test listbox-11.2 {ChangeListboxView procedure, boundary conditions for index} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {3 0}
+test listbox-11.2 {ChangeListboxView procedure, boundary conditions for index} -setup {
+ destroy .l
+} -body {
listbox .l -height 5
pack .l
.l insert 0 a b c d e f g h i j
@@ -1435,9 +2099,12 @@ test listbox-11.2 {ChangeListboxView procedure, boundary conditions for index} {
.l yview 20
update
lappend x [.l index @0,0]
-} {3 5}
-test listbox-11.3 {ChangeListboxView procedure} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {3 5}
+test listbox-11.3 {ChangeListboxView procedure} -setup {
+ destroy .l
+} -body {
listbox .l -height 5 -yscrollcommand "record y"
pack .l
.l insert 0 a b c d e f g h i j
@@ -1446,9 +2113,12 @@ test listbox-11.3 {ChangeListboxView procedure} {
.l yview 2
update
list [.l yview] $log
-} {{0.2 0.7} {{y 0.2 0.7}}}
-test listbox-11.4 {ChangeListboxView procedure} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {{0.2 0.7} {{y 0.2 0.7}}}
+test listbox-11.4 {ChangeListboxView procedure} -setup {
+ destroy .l
+} -body {
listbox .l -height 5 -yscrollcommand "record y"
pack .l
.l insert 0 a b c d e f g h i j
@@ -1457,9 +2127,12 @@ test listbox-11.4 {ChangeListboxView procedure} {
.l yview 8
update
list [.l yview] $log
-} {{0.5 1} {{y 0.5 1}}}
-test listbox-11.5 {ChangeListboxView procedure} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {{0.5 1} {{y 0.5 1}}}
+test listbox-11.5 {ChangeListboxView procedure} -setup {
+ destroy .l
+} -body {
listbox .l -height 5 -yscrollcommand "record y"
pack .l
.l insert 0 a b c d e f g h i j
@@ -1469,40 +2142,55 @@ test listbox-11.5 {ChangeListboxView procedure} {
.l yview 3
update
list [.l yview] $log
-} {{0.3 0.8} {}}
-test listbox-11.6 {ChangeListboxView procedure, partial last line} {
+} -cleanup {
+ destroy .l
+} -result {{0.3 0.8} {}}
+test listbox-11.6 {ChangeListboxView procedure, partial last line} -body {
mkPartial
.partial.l yview 13
.partial.l index @0,0
-} {11}
+} -cleanup {
+ destroy .l
+} -result {11}
+
-catch {destroy .l}
+# Listbox used in 12.* tests
+destroy .l
listbox .l -font $fixed -xscrollcommand "record x" -width 10
.l insert 0 0123456789a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789
pack .l
update
-test listbox-12.1 {ChangeListboxOffset procedure} {fonts} {
+test listbox-12.1 {ChangeListboxOffset procedure} -constraints {
+ fonts
+} -body {
set log {}
.l xview 99
update
list [.l xview] $log
-} {{0.9 1} {{x 0.9 1}}}
-test listbox-12.2 {ChangeListboxOffset procedure} {fonts} {
+} -result {{0.9 1} {{x 0.9 1}}}
+test listbox-12.2 {ChangeListboxOffset procedure} -constraints {
+ fonts
+} -body {
set log {}
+ .l xview 99
.l xview moveto -.25
update
list [.l xview] $log
-} {{0 0.1} {{x 0 0.1}}}
-test listbox-12.3 {ChangeListboxOffset procedure} {fonts} {
+} -result {{0 0.1} {{x 0 0.1}}}
+test listbox-12.3 {ChangeListboxOffset procedure} -constraints {
+ fonts
+} -body {
.l xview 10
update
set log {}
.l xview 10
update
list [.l xview] $log
-} {{0.1 0.2} {}}
+} -result {{0.1 0.2} {}}
+
-catch {destroy .l}
+# Listbox used in 12.* tests
+destroy .l
listbox .l -font $fixed -width 10 -height 5
pack .l
.l insert 0 a bb c d e f g h i j k l m n o p q r s
@@ -1510,15 +2198,19 @@ pack .l
update
set width [expr [lindex [.l bbox 2] 2] - [lindex [.l bbox 1] 2]]
set height [expr [lindex [.l bbox 2] 1] - [lindex [.l bbox 1] 1]]
-test listbox-13.1 {ListboxScanTo procedure} {fonts} {
+test listbox-13.1 {ListboxScanTo procedure} -constraints {
+ fonts
+} -body {
.l yview 0
.l xview 0
.l scan mark 10 20
.l scan dragto [expr 10-$width] [expr 20-$height]
update
list [.l xview] [.l yview]
-} {{0.2 0.4} {0.5 0.75}}
-test listbox-13.2 {ListboxScanTo procedure} {fonts} {
+} -result {{0.2 0.4} {0.5 0.75}}
+test listbox-13.2 {ListboxScanTo procedure} -constraints {
+ fonts
+} -body {
.l yview 5
.l xview 10
.l scan mark 10 20
@@ -1528,8 +2220,10 @@ test listbox-13.2 {ListboxScanTo procedure} {fonts} {
.l scan dragto [expr 20-$width] [expr 40-$height]
update
lappend x [.l xview] [.l yview]
-} {{0 0.2} {0 0.25} {0.2 0.4} {0.5 0.75}}
-test listbox-13.3 {ListboxScanTo procedure} {fonts} {
+} -result {{0 0.2} {0 0.25} {0.2 0.4} {0.5 0.75}}
+test listbox-13.3 {ListboxScanTo procedure} -constraints {
+ fonts
+} -body {
.l yview moveto 1.0
.l xview moveto 1.0
.l scan mark 10 20
@@ -1539,40 +2233,55 @@ test listbox-13.3 {ListboxScanTo procedure} {fonts} {
.l scan dragto [expr 5+$width] [expr 10+$height]
update
lappend x [.l xview] [.l yview]
-} {{0.8 1} {0.75 1} {0.64 0.84} {0.25 0.5}}
+} -result {{0.8 1} {0.75 1} {0.64 0.84} {0.25 0.5}}
-test listbox-14.1 {NearestListboxElement procedure, partial last line} {
+
+test listbox-14.1 {NearestListboxElement procedure, partial last line} -body {
mkPartial
.partial.l nearest [winfo height .partial.l]
-} {4}
-catch {destroy .l}
+} -result {4}
+# Listbox used in 14.* tests
+destroy .l
listbox .l -font $fixed -width 20 -height 10
.l insert 0 a b c d e f g h i j k l m n o p q r s t
.l yview 4
pack .l
update
-test listbox-14.2 {NearestListboxElement procedure} {fonts} {
+test listbox-14.2 {NearestListboxElement procedure} -constraints {
+ fonts
+} -body {
.l index @50,0
-} {4}
-test listbox-14.3 {NearestListboxElement procedure} {fonts} {
+} -result {4}
+test listbox-14.3 {NearestListboxElement procedure} -constraints {
+ fonts
+} -body {
list [.l index @50,35] [.l index @50,36]
-} {5 6}
-test listbox-14.4 {NearestListboxElement procedure} {fonts} {
+} -result {5 6}
+test listbox-14.4 {NearestListboxElement procedure} -constraints {
+ fonts
+} -body {
.l index @50,200
-} {13}
+} -result {13}
+
-test listbox-15.1 {ListboxSelect procedure} {
+# Listbox used in 15.* 16.* and 17.* tests
+destroy .l
+listbox .l -font $fixed -width 20 -height 10
+pack .l
+update
+test listbox-15.1 {ListboxSelect procedure} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j k l m n o p
.l select set 2 4
.l select set 7 12
.l select clear 4 7
.l curselection
-} {2 3 8 9 10 11 12}
-test listbox-15.2 {ListboxSelect procedure} {
+} -result {2 3 8 9 10 11 12}
+test listbox-15.2 {ListboxSelect procedure} -setup {
+ destroy .e
+} -body {
.l delete 0 end
.l insert 0 a b c d e f g h i j k l m n o p
- catch {destroy .e}
entry .e
.e insert 0 "This is some text"
.e select from 0
@@ -1581,78 +2290,81 @@ test listbox-15.2 {ListboxSelect procedure} {
set x [selection own]
.l selection set 3
list $x [selection own] [selection get]
-} {.e .l d}
-test listbox-15.3 {ListboxSelect procedure} {
+} -cleanup {
+ destroy .e
+} -result {.e .l d}
+test listbox-15.3 {ListboxSelect procedure} -body {
.l delete 0 end
.l selection clear 0 end
.l select set 0 end
.l curselection
-} {}
-test listbox-15.4 {ListboxSelect procedure, boundary conditions for indices} {
+} -result {}
+test listbox-15.4 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set -2 -1
.l curselection
-} {}
-test listbox-15.5 {ListboxSelect procedure, boundary conditions for indices} {
+} -result {}
+test listbox-15.5 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set -1 3
.l curselection
-} {0 1 2 3}
-test listbox-15.6 {ListboxSelect procedure, boundary conditions for indices} {
+} -result {0 1 2 3}
+test listbox-15.6 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set 2 4
.l curselection
-} {2 3 4}
-test listbox-15.7 {ListboxSelect procedure, boundary conditions for indices} {
+} -result {2 3 4}
+test listbox-15.7 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set 4 end
.l curselection
-} {4 5}
-test listbox-15.8 {ListboxSelect procedure, boundary conditions for indices} {
+} -result {4 5}
+test listbox-15.8 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set 4 30
.l curselection
-} {4 5}
-test listbox-15.9 {ListboxSelect procedure, boundary conditions for indices} {
+} -result {4 5}
+test listbox-15.9 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set end 30
.l curselection
-} {5}
-test listbox-15.10 {ListboxSelect procedure, boundary conditions for indices} {
+} -result {5}
+test listbox-15.10 {ListboxSelect procedure, boundary conditions for indices} -body {
.l delete 0 end
.l insert 0 a b c d e f
.l select clear 0 end
.l select set 20 25
.l curselection
-} {}
+} -result {}
-test listbox-16.1 {ListboxFetchSelection procedure} {
+
+test listbox-16.1 {ListboxFetchSelection procedure} -body {
.l delete 0 end
.l insert 0 a b c "two words" e f g h i \\ k l m n o p
.l selection set 2 4
.l selection set 9
.l selection set 11 12
selection get
-} "c\ntwo words\ne\n\\\nl\nm"
-test listbox-16.2 {ListboxFetchSelection procedure} {
+} -result "c\ntwo words\ne\n\\\nl\nm"
+test listbox-16.2 {ListboxFetchSelection procedure} -body {
.l delete 0 end
.l insert 0 a b c "two words" e f g h i \\ k l m n o p
.l selection set 3
selection get
-} "two words"
-test listbox-16.3 {ListboxFetchSelection procedure, retrieve in several parts} {
+} -result "two words"
+test listbox-16.3 {ListboxFetchSelection procedure, retrieve in several parts} -body {
set long "This is quite a long string\n"
append long $long $long $long $long
append long $long $long $long $long
@@ -1662,38 +2374,48 @@ test listbox-16.3 {ListboxFetchSelection procedure, retrieve in several parts} {
.l selection set 0 end
set sel [selection get]
string compare 1$long\n2$long\n3$long\n4$long\n5$long $sel
-} {0}
-catch {unset long sel}
+} -cleanup {
+ catch {unset long sel}
+} -result {0}
+
-test listbox-17.1 {ListboxLostSelection procedure} {
+test listbox-17.1 {ListboxLostSelection procedure} -setup {
+ destroy .e
+} -body {
.l delete 0 end
.l insert 0 a b c d e
.l select set 0 end
- catch {destroy .e}
entry .e
.e insert 0 "This is some text"
.e select from 0
.e select to 5
.l curselection
-} {}
-test listbox-17.2 {ListboxLostSelection procedure} {
+} -cleanup {
+ destroy .e
+} -result {}
+test listbox-17.2 {ListboxLostSelection procedure} -setup {
+ destroy .e
+} -body {
.l delete 0 end
.l insert 0 a b c d e
.l select set 0 end
.l configure -exportselection 0
- catch {destroy .e}
entry .e
.e insert 0 "This is some text"
.e select from 0
.e select to 5
.l curselection
-} {0 1 2 3 4}
+} -cleanup {
+ destroy .e
+} -result {0 1 2 3 4}
-catch {destroy .l}
+
+# Listbox used in 18.* tests
+destroy .l
listbox .l -font $fixed -width 10 -height 5
pack .l
update
-test listbox-18.1 {ListboxUpdateVScrollbar procedure} {
+test listbox-18.1 {ListboxUpdateVScrollbar procedure} -body {
.l configure -yscrollcommand "record y"
set log {}
.l insert 0 a b c
@@ -1702,38 +2424,41 @@ test listbox-18.1 {ListboxUpdateVScrollbar procedure} {
update
.l delete 0 end
update
- set log
-} {{y 0 1} {y 0 0.625} {y 0 1}}
-test listbox-18.2 {ListboxUpdateVScrollbar procedure, partial last line} {
+ return $log
+} -result {{y 0 1} {y 0 0.625} {y 0 1}}
+test listbox-18.2 {ListboxUpdateVScrollbar procedure, partial last line} -body {
mkPartial
.partial.l configure -yscrollcommand "record y"
set log {}
.partial.l yview 3
update
- set log
-} {{y 0.2 0.466667}}
-test listbox-18.3 {ListboxUpdateVScrollbar procedure} {
+ return $log
+} -result {{y 0.2 0.466667}}
+test listbox-18.3 {ListboxUpdateVScrollbar procedure} -body {
proc bgerror args {
- global x errorInfo
- set x [list $args $errorInfo]
+ global x errorInfo
+ set x [list $args $errorInfo]
}
.l configure -yscrollcommand gorp
.l insert 0 foo
update
- set x
-} {{{invalid command name "gorp"}} {invalid command name "gorp"
+ return $x
+} -cleanup {
+ rename bgerror {}
+} -result {{{invalid command name "gorp"}} {invalid command name "gorp"
while executing
"gorp 0 1"
(vertical scrolling command executed by listbox)}}
-if {[info exists bgerror]} {
- rename bgerror {}
-}
-catch {destroy .l}
+
+# Listbox used in 19.* tests
+destroy .l
listbox .l -font $fixed -width 10 -height 5
pack .l
update
-test listbox-19.1 {ListboxUpdateVScrollbar procedure} {fonts} {
+test listbox-19.1 {ListboxUpdateVScrollbar procedure} -constraints {
+ fonts
+} -body {
.l configure -xscrollcommand "record x"
set log {}
.l insert 0 abc
@@ -1742,98 +2467,126 @@ test listbox-19.1 {ListboxUpdateVScrollbar procedure} {fonts} {
update
.l delete 0 end
update
- set log
-} {{x 0 1} {x 0 0.322581} {x 0 1}}
-test listbox-19.2 {ListboxUpdateVScrollbar procedure} {
+ return $log
+} -result {{x 0 1} {x 0 0.322581} {x 0 1}}
+test listbox-19.2 {ListboxUpdateVScrollbar procedure} -body {
proc bgerror args {
- global x errorInfo
- set x [list $args $errorInfo]
+ global x errorInfo
+ set x [list $args $errorInfo]
}
.l configure -xscrollcommand bogus
.l insert 0 foo
update
- set x
-} {{{invalid command name "bogus"}} {invalid command name "bogus"
+ return $x
+} -result {{{invalid command name "bogus"}} {invalid command name "bogus"
while executing
"bogus 0 1"
(horizontal scrolling command executed by listbox)}}
-set l [interp hidden]
-deleteWindows
-test listbox-20.1 {listbox vs hidden commands} {
- catch {destroy .l}
+test listbox-20.1 {listbox vs hidden commands} -setup {
+ deleteWindows
+} -body {
+ set l [interp hidden]
listbox .l
interp hide {} .l
destroy .l
- list [winfo children .] [interp hidden]
-} [list {} $l]
+ set res1 [list [winfo children .] [interp hidden]]
+ set res2 [list {} $l]
+ expr {$res1 eq $res2}
+} -result 1
+
# tests for ListboxListVarProc
-test listbox-21.1 {ListboxListVarProc} {
- catch {destroy .l}
+test listbox-21.1 {ListboxListVarProc} -setup {
+ destroy .l
+} -body {
catch {unset x}
listbox .l -listvar x
set x [list a b c d]
.l get 0 end
-} [list a b c d]
-test listbox-21.2 {ListboxListVarProc} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result [list a b c d]
+test listbox-21.2 {ListboxListVarProc} -setup {
+ destroy .l
+} -body {
set x [list a b c d]
listbox .l -listvar x
unset x
- set x
-} [list a b c d]
-test listbox-21.3 {ListboxListVarProc} {
- catch {destroy .l}
+ return $x
+} -cleanup {
+ destroy .l
+} -result [list a b c d]
+test listbox-21.3 {ListboxListVarProc} -setup {
+ destroy .l
+} -body {
set x [list a b c d]
listbox .l -listvar x
.l configure -listvar {}
unset x
info exists x
-} 0
-test listbox-21.4 {ListboxListVarProc} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result 0
+test listbox-21.4 {ListboxListVarProc} -setup {
+ destroy .l
+} -body {
set x [list a b c d]
listbox .l -listvar x
lappend x e f g
.l size
-} 7
-test listbox-21.5 {ListboxListVarProc, test selection after listvar mod} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result 7
+test listbox-21.5 {ListboxListVarProc, test selection after listvar mod} -setup {
+ destroy .l
+} -body {
set x [list a b c d e f g]
listbox .l -listvar x
.l selection set end
set x [list a b c d]
set x [list 0 1 2 3 4 5 6]
.l curselection
-} {}
-test listbox-21.6 {ListboxListVarProc, test selection after listvar mod} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {}
+test listbox-21.6 {ListboxListVarProc, test selection after listvar mod} -setup {
+ destroy .l
+} -body {
set x [list a b c d]
listbox .l -listvar x
.l selection set 3
lappend x e f g
.l curselection
-} 3
-test listbox-21.7 {ListboxListVarProc, test selection after listvar mod} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result 3
+test listbox-21.7 {ListboxListVarProc, test selection after listvar mod} -setup {
+ destroy .l
+} -body {
set x [list a b c d]
listbox .l -listvar x
.l selection set 0
set x [linsert $x 0 1 2 3 4]
.l curselection
-} 0
-test listbox-21.8 {ListboxListVarProc, test selection after listvar mod} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result 0
+test listbox-21.8 {ListboxListVarProc, test selection after listvar mod} -setup {
+ destroy .l
+} -body {
set x [list a b c d]
listbox .l -listvar x
.l selection set 2
set x [list a b c]
.l curselection
-} 2
-test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result 2
+test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} -setup {
+ destroy .l
+} -body {
catch {unset x}
set log {}
listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
@@ -1843,10 +2596,13 @@ test listbox-21.9 {ListboxListVarProc, test hscrollbar after listvar mod} {
update
lappend x "00000000000000000000"
update
- set log
-} [list {x 0 1} {x 0 1} {x 0 0.5}]
-test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} {
- catch {destroy .l}
+ return $log
+} -cleanup {
+ destroy .l
+} -result [list {x 0 1} {x 0 1} {x 0 0.5}]
+test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} -setup {
+ destroy .l
+} -body {
catch {unset x}
set log {}
listbox .l -font $fixed -width 10 -xscrollcommand "record x" -listvar x
@@ -1858,54 +2614,72 @@ test listbox-21.10 {ListboxListVarProc, test hscrollbar after listvar mod} {
update
set x [list "0000000000"]
update
- set log
-} [list {x 0 1} {x 0 1} {x 0 0.5} {x 0 1}]
-test listbox-21.11 {ListboxListVarProc, bad list} {
- catch {destroy .l}
+ return $log
+} -cleanup {
+ destroy .l
+} -result [list {x 0 1} {x 0 1} {x 0 0.5} {x 0 1}]
+test listbox-21.11 {ListboxListVarProc, bad list} -setup {
+ destroy .l
+} -body {
catch {unset x}
listbox .l -listvar x
set x [list a b c d]
catch {set x "this is a \" bad list"} result
- set result
-} {can't set "x": invalid listvar value}
-test listbox-21.12 {ListboxListVarProc, cleanup item attributes} {
- catch {destroy .l}
+ return $result
+} -cleanup {
+ destroy .l
+} -result {can't set "x": invalid listvar value}
+test listbox-21.12 {ListboxListVarProc, cleanup item attributes} -setup {
+ destroy .l
+} -body {
set x [list a b c d e f g]
listbox .l -listvar x
.l itemconfigure end -fg red
set x [list a b c d]
set x [list 0 1 2 3 4 5 6]
.l itemcget end -fg
-} {}
-test listbox-21.12a {ListboxListVarProc, cleanup item attributes} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {}
+test listbox-21.13 {ListboxListVarProc, cleanup item attributes} -setup {
+ destroy .l
+} -body {
set x [list a b c d e f g]
listbox .l -listvar x
.l itemconfigure end -fg red
set x [list a b c d]
set x [list 0 1 2 3 4 5 6]
.l itemcget end -fg
-} {}
-test listbox-21.13 {listbox item configurations and listvar based deletions} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {}
+test listbox-21.14 {listbox item configurations and listvar based deletions} -setup {
+ destroy .l
+} -body {
catch {unset x}
listbox .l -listvar x
.l insert end a b c
.l itemconfigure 1 -fg red
set x [list b c]
.l itemcget 1 -fg
-} red
-test listbox-21.14 {listbox item configurations and listvar based inserts} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result red
+test listbox-21.15 {listbox item configurations and listvar based inserts} -setup {
+ destroy .l
+} -body {
catch {unset x}
listbox .l -listvar x
.l insert end a b c
.l itemconfigure 0 -fg red
set x [list 1 2 3 4 a b c]
.l itemcget 0 -fg
-} red
-test listbox-21.15 {ListboxListVarProc, update vertical scrollbar} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result red
+test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} -setup {
+ destroy .l
+} -body {
catch {unset x}
set log {}
listbox .l -listvar x -yscrollcommand "record y" -font fixed -height 3
@@ -1913,10 +2687,13 @@ test listbox-21.15 {ListboxListVarProc, update vertical scrollbar} {
update
lappend x a b c d e f
update
- set log
-} [list {y 0 1} {y 0 0.5}]
-test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} {
- catch {destroy .l}
+ return $log
+} -cleanup {
+ destroy .l
+} -result [list {y 0 1} {y 0 0.5}]
+test listbox-21.17 {ListboxListVarProc, update vertical scrollbar} -setup {
+ destroy .l
+} -body {
catch {unset x}
listbox .l -listvar x -height 3
pack .l
@@ -1931,12 +2708,16 @@ test listbox-21.16 {ListboxListVarProc, update vertical scrollbar} {
set x [lreplace $x 3 3]
update
lappend result [.l yview]
- set result
-} [list {0.5 1} {0 1}]
+ return $result
+} -cleanup {
+ destroy .l
+} -result [list {0.5 1} {0 1}]
+
# UpdateHScrollbar
-test listbox-22.1 {UpdateHScrollbar} {
- catch {destroy .l}
+test listbox-22.1 {UpdateHScrollbar} -setup {
+ destroy .l
+} -body {
set log {}
listbox .l -font $fixed -width 10 -xscrollcommand "record x"
pack .l
@@ -1945,42 +2726,58 @@ test listbox-22.1 {UpdateHScrollbar} {
update
.l insert end "00000000000000000000"
update
- set log
-} [list {x 0 1} {x 0 1} {x 0 0.5}]
+ return $log
+} -cleanup {
+ destroy .l
+} -result [list {x 0 1} {x 0 1} {x 0 0.5}]
+
# ConfigureListboxItem
-test listbox-23.1 {ConfigureListboxItem} {
- catch {destroy .l}
+test listbox-23.1 {ConfigureListboxItem} -setup {
+ destroy .l
+} -body {
listbox .l
catch {.l itemconfigure 0} result
- set result
-} {item number "0" out of range}
-test listbox-23.2 {ConfigureListboxItem} {
- catch {destroy .l}
+ return $result
+} -cleanup {
+ destroy .l
+} -result {item number "0" out of range}
+test listbox-23.2 {ConfigureListboxItem} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c d
.l itemconfigure 0
-} [list {-background background Background {} {}} \
+} -cleanup {
+ destroy .l
+} -result [list {-background background Background {} {}} \
{-bg -background} \
{-fg -foreground} \
{-foreground foreground Foreground {} {}} \
{-selectbackground selectBackground Foreground {} {}} \
{-selectforeground selectForeground Background {} {}}]
-test listbox-23.3 {ConfigureListboxItem, itemco shortcut} {
- catch {destroy .l}
+test listbox-23.3 {ConfigureListboxItem, itemco shortcut} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c d
.l itemco 0 -background
-} {-background background Background {} {}}
-test listbox-23.4 {ConfigureListboxItem, wrong num args} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {-background background Background {} {}}
+test listbox-23.4 {ConfigureListboxItem, wrong num args} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a
catch {.l itemco} result
- set result
-} {wrong # args: should be ".l itemconfigure index ?-option? ?value? ?-option value ...?"}
-test listbox-23.5 {ConfigureListboxItem, multiple calls} {
- catch {destroy .l}
+ return $result
+} -cleanup {
+ destroy .l
+} -result {wrong # args: should be ".l itemconfigure index ?-option? ?value? ?-option value ...?"}
+test listbox-23.5 {ConfigureListboxItem, multiple calls} -setup {
+ destroy .l
+} -body {
listbox .l
set i 0
foreach color {red orange yellow green blue white violet} {
@@ -1993,102 +2790,164 @@ test listbox-23.5 {ConfigureListboxItem, multiple calls} {
list [.l itemcget 0 -bg] [.l itemcget 1 -bg] [.l itemcget 2 -bg] \
[.l itemcget 3 -bg] [.l itemcget 4 -bg] [.l itemcget 5 -bg] \
[.l itemcget 6 -bg]
-} {red orange yellow green blue white violet}
-catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {red orange yellow green blue white violet}
+
+# Listbox used in 23.6 -23.17 tests
+destroy .l
listbox .l
.l insert end a b c d
-set i 6
-foreach test {
- {-background #ff0000 #ff0000 non-existent
- {unknown color name "non-existent"}}
- {-bg #ff0000 #ff0000 non-existent {unknown color name "non-existent"}}
- {-fg #110022 #110022 bogus {unknown color name "bogus"}}
- {-foreground #110022 #110022 bogus {unknown color name "bogus"}}
- {-selectbackground #110022 #110022 bogus {unknown color name "bogus"}}
- {-selectforeground #654321 #654321 bogus {unknown color name "bogus"}}
-} {
- set name [lindex $test 0]
- test listbox-23.$i {configuration options} {
- .l itemconfigure 0 $name [lindex $test 1]
- list [lindex [.l itemconfigure 0 $name] 4] [.l itemcget 0 $name]
- } [list [lindex $test 2] [lindex $test 2]]
- incr i
- if {[lindex $test 3] != ""} {
- test listbox-23.$i {configuration options} {
- list [catch {.l configure $name [lindex $test 3]} msg] $msg
- } [list 1 [lindex $test 4]]
- }
- .l configure $name [lindex [.l configure $name] 3]
- incr i
-}
+test listbox-23.6 {configuration options} -body {
+ .l itemconfigure 0 -background #ff0000
+ list [lindex [.l itemconfigure 0 -background] 4] [.l itemcget 0 -background]
+} -cleanup {
+ .l configure -background #ffffff
+} -result {{#ff0000} #ff0000}
+test listbox-23.7 {configuration options} -body {
+ .l configure -background non-existent
+} -returnCodes error -result {unknown color name "non-existent"}
+test listbox-23.8 {configuration options} -body {
+ .l itemconfigure 0 -bg #ff0000
+ list [lindex [.l itemconfigure 0 -bg] 4] [.l itemcget 0 -bg]
+} -cleanup {
+ .l configure -bg #ffffff
+} -result {{#ff0000} #ff0000}
+test listbox-23.9 {configuration options} -body {
+ .l configure -bg non-existent
+} -returnCodes error -result {unknown color name "non-existent"}
+test listbox-23.10 {configuration options} -body {
+ .l itemconfigure 0 -fg #110022
+ list [lindex [.l itemconfigure 0 -fg] 4] [.l itemcget 0 -fg]
+} -cleanup {
+ .l configure -fg #000000
+} -result {{#110022} #110022}
+test listbox-23.11 {configuration options} -body {
+ .l configure -fg bogus
+} -returnCodes error -result {unknown color name "bogus"}
+test listbox-23.12 {configuration options} -body {
+ .l itemconfigure 0 -foreground #110022
+ list [lindex [.l itemconfigure 0 -foreground] 4] [.l itemcget 0 -foreground]
+} -cleanup {
+ .l configure -foreground #000000
+} -result {{#110022} #110022}
+test listbox-23.13 {configuration options} -body {
+ .l configure -foreground bogus
+} -returnCodes error -result {unknown color name "bogus"}
+test listbox-23.14 {configuration options} -body {
+ .l itemconfigure 0 -selectbackground #110022
+ list [lindex [.l itemconfigure 0 -selectbackground] 4] [.l itemcget 0 -selectbackground]
+} -cleanup {
+ .l configure -selectbackground #c3c3c3
+} -result {{#110022} #110022}
+test listbox-23.15 {configuration options} -body {
+ .l configure -selectbackground bogus
+} -returnCodes error -result {unknown color name "bogus"}
+test listbox-23.16 {configuration options} -body {
+ .l itemconfigure 0 -selectforeground #654321
+ list [lindex [.l itemconfigure 0 -selectforeground] 4] [.l itemcget 0 -selectforeground]
+} -cleanup {
+ .l configure -selectforeground #000000
+} -result {{#654321} #654321}
+test listbox-23.17 {configuration options} -body {
+ .l configure -selectforeground bogus
+} -returnCodes error -result {unknown color name "bogus"}
+
# ListboxWidgetObjCmd, itemcget
-test listbox-24.1 {itemcget} {
- catch {destroy .l}
+test listbox-24.1 {itemcget} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c d
.l itemcget 0 -fg
-} {}
-test listbox-24.2 {itemcget} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {}
+test listbox-24.2 {itemcget} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c d
.l itemconfigure 0 -fg red
.l itemcget 0 -fg
-} red
-test listbox-24.3 {itemcget} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result red
+test listbox-24.3 {itemcget} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c d
catch {.l itemcget 0} result
- set result
-} {wrong # args: should be ".l itemcget index option"}
-test listbox-24.4 {itemcget, itemcg shortcut} {
- catch {destroy .l}
+ return $result
+} -cleanup {
+ destroy .l
+} -result {wrong # args: should be ".l itemcget index option"}
+test listbox-24.4 {itemcget, itemcg shortcut} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c d
catch {.l itemcg 0} result
- set result
-} {wrong # args: should be ".l itemcget index option"}
+ return $result
+} -cleanup {
+ destroy .l
+} -result {wrong # args: should be ".l itemcget index option"}
+
# General item configuration issues
-test listbox-25.1 {listbox item configurations and widget based deletions} {
- catch {destroy .l}
+test listbox-25.1 {listbox item configurations and widget based deletions} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a
.l itemconfigure 0 -fg red
.l delete 0 end
.l insert end a
.l itemcget 0 -fg
-} {}
-test listbox-25.2 {listbox item configurations and widget based inserts} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result {}
+test listbox-25.2 {listbox item configurations and widget based inserts} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c
.l itemconfigure 0 -fg red
.l insert 0 1 2 3 4
list [.l itemcget 0 -fg] [.l itemcget 4 -fg]
-} [list {} red]
+} -cleanup {
+ destroy .l
+} -result {{} red}
+
# state issues
-test listbox-26.1 {listbox disabled state disallows inserts} {
- catch {destroy .l}
+test listbox-26.1 {listbox disabled state disallows inserts} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c
.l configure -state disabled
.l insert end d e f
.l get 0 end
-} [list a b c]
-test listbox-26.2 {listbox disabled state disallows deletions} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result [list a b c]
+test listbox-26.2 {listbox disabled state disallows deletions} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c
.l configure -state disabled
.l delete 0 end
.l get 0 end
-} [list a b c]
-test listbox-26.3 {listbox disabled state disallows selection modification} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result [list a b c]
+test listbox-26.3 {listbox disabled state disallows selection modification} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c
.l selection set 0
@@ -2097,58 +2956,89 @@ test listbox-26.3 {listbox disabled state disallows selection modification} {
.l selection clear 0 end
.l selection set 1
.l curselection
-} [list 0 2]
-test listbox-26.4 {listbox disabled state disallows anchor modification} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result [list 0 2]
+test listbox-26.4 {listbox disabled state disallows anchor modification} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c
.l selection anchor 0
.l configure -state disabled
.l selection anchor 2
.l index anchor
-} 0
-test listbox-26.5 {listbox disabled state disallows active modification} {
- catch {destroy .l}
+} -cleanup {
+ destroy .l
+} -result 0
+test listbox-26.5 {listbox disabled state disallows active modification} -setup {
+ destroy .l
+} -body {
listbox .l
.l insert end a b c
.l activate 0
.l configure -state disabled
.l activate 2
.l index active
-} 0
+} -cleanup {
+ destroy .l
+} -result 0
-test listbox-27.1 {widget deletion while active} {
+
+test listbox-27.1 {widget deletion while active} -setup {
destroy .l
+} -body {
pack [listbox .l]
update
.l configure -cursor xterm -xscrollcommand { destroy .l }
update idle
winfo exists .l
-} 0
+} -cleanup {
+ destroy .l
+} -result 0
-test listbox-28.1 {listbox -activestyle} {
+
+test listbox-28.1 {listbox -activestyle} -setup {
destroy .l
+} -body {
listbox .l -activ non
.l cget -activestyle
-} none
-test listbox-28.2-nonwin {listbox -activestyle} {nonwin} {
+} -cleanup {
+ destroy .l
+} -result none
+test listbox-28.2 {listbox -activestyle} -constraints {
+ nonwin
+} -setup {
destroy .l
+} -body {
listbox .l
.l cget -activestyle
-} dotbox
-test listbox-28.2-win {listbox -activestyle} {win} {
+} -cleanup {
destroy .l
+} -result dotbox
+test listbox-28.3 {listbox -activestyle} -constraints {
+ win
+} -setup {
+ destroy .l
+} -body {
listbox .l
.l cget -activestyle
-} underline
-test listbox-28.3 {listbox -activestyle} {
+} -cleanup {
+ destroy .l
+} -result underline
+test listbox-28.4 {listbox -activestyle} -setup {
destroy .l
+} -body {
listbox .l -activestyle und
.l cget -activestyle
-} underline
+} -cleanup {
+ destroy .l
+} -result underline
-test listbox-29.1 {listbox selection behavior, -state disabled} {
+
+test listbox-29.1 {listbox selection behavior, -state disabled} -setup {
destroy .l
+} -body {
listbox .l
.l insert end 1 2 3
.l selection set 2
@@ -2158,7 +3048,9 @@ test listbox-29.1 {listbox selection behavior, -state disabled} {
# but selection cannot be changed (new behavior since 8.4)
.l selection set 3
lappend out [.l selection includes 2] [.l curselection]
-} {1 1 2}
+} -cleanup {
+ destroy .l
+} -result {1 1 2}
resetGridInfo
deleteWindows
@@ -2167,3 +3059,8 @@ option clear
# cleanup
cleanupTests
return
+
+
+
+
+