summaryrefslogtreecommitdiffstats
path: root/tests/visual.test
diff options
context:
space:
mode:
authorandreask <andreask>2013-01-22 19:30:43 (GMT)
committerandreask <andreask>2013-01-22 19:30:43 (GMT)
commit48c9fcb7281cc6aa076113db874c7ae0e105795d (patch)
tree7187940ff056462bfa41705a2ce04d0ed07d424e /tests/visual.test
parent41f5d19540b0b3f053da352e1569c9a4ed019dd5 (diff)
downloadtk-contrib_patrick_fradin_code_cleanup.zip
tk-contrib_patrick_fradin_code_cleanup.tar.gz
tk-contrib_patrick_fradin_code_cleanup.tar.bz2
Contribution by Patrick Fradin <patrick.fradin@planar.com>contrib_patrick_fradin_code_cleanup
Quoting his mail: <pre> ========================================================== Hi Jeff, I spent some of my time to contribute to the TclTk community ! I'm in late for Christmas gift but like we said in French : "Mieux vaut tard que jamais". ;-) I've use TclDevKit 5.3.0 tclchecker to analyse TclTk code in Tcl and Tk library directories (library, tools and tests) to correct a lot of warnings and few errors. (encapsulate some expr, use 'chan xxx' instead of fconfigure, fileevent...) I've made some improvements too : Examples : - Use 'lassign' instead of many 'lindex' of 'foreach/break' loop. - Use 'in' or 'ni' operators instead of 'lsearch -exact' or to factorise some eq/ne && / || tests. - Use 'eq' or 'ne' to tests strings instead of '==' or '!='. - Use 'unset -nocomplain' to avoid 'catch {unset...}'. - Remove some useless catch around 'destroy' calls. - Use expand {*} instead of 'eval'. Don't touch a lot of code because I don't know all structs and lists. I think it could be a greater improvement to reduce 'eval' calls. Due to previous experience, I dot not change any indentation ! ;-) ========================================================== </pre>
Diffstat (limited to 'tests/visual.test')
-rw-r--r--tests/visual.test22
1 files changed, 7 insertions, 15 deletions
diff --git a/tests/visual.test b/tests/visual.test
index 2f5c34a..2a53764 100644
--- a/tests/visual.test
+++ b/tests/visual.test
@@ -22,16 +22,16 @@ update
# w - Name of toplevel window to create.
proc eatColors {w} {
- catch {destroy $w}
+ destroy $w
toplevel $w
wm geom $w +0+0
- canvas $w.c -width 400 -height 200 -bd 0
+ canvas $w.c -width 400 -height 200 -borderwidth 0
pack $w.c
for {set y 0} {$y < 8} {incr y} {
for {set x 0} {$x < 40} {incr x} {
- set color [format #%02x%02x%02x [expr $x*6] [expr $y*30] 0]
- $w.c create rectangle [expr 10*$x] [expr 20*$y] \
- [expr 10*$x + 10] [expr 20*$y + 20] -outline {} \
+ set color [format "#%02x%02x%02x" [expr {$x * 6}] [expr {$y * 30}] 0]
+ $w.c create rectangle [expr {10 * $x}] [expr {20 * $y}] \
+ [expr {(10 * $x) + 10}] [expr {(20 * $y) + 20}] -outline "" \
-fill $color
}
}
@@ -49,9 +49,8 @@ proc eatColors {w} {
# to see if there are colormap entries free.
proc colorsFree {w {red 31} {green 245} {blue 192}} {
- set vals [winfo rgb $w [format #%02x%02x%02x $red $green $blue]]
- expr ([lindex $vals 0]/256 == $red) && ([lindex $vals 1]/256 == $green) \
- && ([lindex $vals 2]/256 == $blue)
+ lassign [winfo rgb $w [format "#%02x%02x%02x" $red $green $blue]] w_red w_green w_blue
+ expr {(($w_red / 256) == $red) && (($w_green / 256) == $green) && (($w_blue / 256) == $blue)}
}
# If more than one visual type is available for the screen, pick one
@@ -130,7 +129,6 @@ test visual-1.5 {Tk_GetVisual, default colormap} -setup {
deleteWindows
} -result $default
-
test visual-2.1 {Tk_GetVisual, different visual types} -constraints {
nonPortable
} -setup {
@@ -336,7 +334,6 @@ test visual-2.17 {Tk_GetVisual, different visual types} -constraints {
deleteWindows
} -result {truecolor 32}
-
test visual-3.1 {Tk_GetVisual, parsing visual string} -setup {
deleteWindows
} -body {
@@ -381,7 +378,6 @@ test visual-3.5 {Tk_GetVisual, parsing visual string} -setup {
deleteWindows
} -returnCodes error -result {expected integer but got "48x"}
-
test visual-4.1 {Tk_GetVisual, numerical visual id} -constraints {
haveOtherVisual nonPortable
} -setup {
@@ -414,7 +410,6 @@ test visual-4.3 {Tk_GetVisual, numerical visual id} -setup {
deleteWindows
} -returnCodes error -result {couldn't find an appropriate visual}
-
test visual-5.1 {Tk_GetVisual, no matching visual} -constraints {
!havePseudocolorVisual
} -setup {
@@ -426,7 +421,6 @@ test visual-5.1 {Tk_GetVisual, no matching visual} -constraints {
deleteWindows
} -returnCodes error -result {couldn't find an appropriate visual}
-
test visual-6.1 {Tk_GetVisual, no matching visual} -constraints {
havePseudocolorVisual haveMultipleVisuals nonPortable
} -setup {
@@ -522,7 +516,6 @@ test visual-7.6 {Tk_GetColormap, copy from other window} -constraints {
deleteWindows
} -returnCodes error -result {can't use colormap for .t1: incompatible visuals}
-
test visual-8.1 {Tk_FreeColormap procedure} -setup {
deleteWindows
} -body {
@@ -556,7 +549,6 @@ test visual-8.2 {Tk_FreeColormap procedure} -constraints haveOtherVisual -setup
deleteWindows
} -result {}
-
deleteWindows
rename eatColors {}
rename colorsFree {}