diff options
author | andreask <andreask> | 2013-01-22 19:30:43 (GMT) |
---|---|---|
committer | andreask <andreask> | 2013-01-22 19:30:43 (GMT) |
commit | 48c9fcb7281cc6aa076113db874c7ae0e105795d (patch) | |
tree | 7187940ff056462bfa41705a2ce04d0ed07d424e /tests/textImage.test | |
parent | 41f5d19540b0b3f053da352e1569c9a4ed019dd5 (diff) | |
download | tk-48c9fcb7281cc6aa076113db874c7ae0e105795d.zip tk-48c9fcb7281cc6aa076113db874c7ae0e105795d.tar.gz tk-48c9fcb7281cc6aa076113db874c7ae0e105795d.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/textImage.test')
-rw-r--r-- | tests/textImage.test | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/tests/textImage.test b/tests/textImage.test index 24246cc..212defb 100644 --- a/tests/textImage.test +++ b/tests/textImage.test @@ -22,7 +22,7 @@ destroy .t test textImage-1.1 {basic argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image } -cleanup { @@ -32,7 +32,7 @@ test textImage-1.1 {basic argument checking} -setup { test textImage-1.2 {basic argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image c } -cleanup { @@ -42,7 +42,7 @@ test textImage-1.2 {basic argument checking} -setup { test textImage-1.3 {cget argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image cget } -cleanup { @@ -52,7 +52,7 @@ test textImage-1.3 {cget argument checking} -setup { test textImage-1.4 {cget argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image cget blurf -flurp } -cleanup { @@ -62,7 +62,7 @@ test textImage-1.4 {cget argument checking} -setup { test textImage-1.5 {cget argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image cget 1.1 -flurp } -cleanup { @@ -72,7 +72,7 @@ test textImage-1.5 {cget argument checking} -setup { test textImage-1.6 {configure argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image configure } -cleanup { @@ -82,7 +82,7 @@ test textImage-1.6 {configure argument checking} -setup { test textImage-1.7 {configure argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image configure blurf } -cleanup { @@ -92,7 +92,7 @@ test textImage-1.7 {configure argument checking} -setup { test textImage-1.8 {configure argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image configure 1.1 } -cleanup { @@ -102,7 +102,7 @@ test textImage-1.8 {configure argument checking} -setup { test textImage-1.9 {create argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create } -cleanup { @@ -112,7 +112,7 @@ test textImage-1.9 {create argument checking} -setup { test textImage-1.10 {create argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create blurf } -cleanup { @@ -126,7 +126,7 @@ test textImage-1.11 {basic argument checking} -setup { image create photo small -width 5 -height 5 small put red -to 0 0 4 4 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create 1000.1000 -image small } -cleanup { @@ -137,14 +137,13 @@ test textImage-1.11 {basic argument checking} -setup { test textImage-1.12 {names argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image names dates places } -cleanup { destroy .t } -returnCodes error -result {wrong # args: should be ".t image names"} - test textImage-1.13 {names argument checking} -setup { destroy .t set result "" @@ -153,7 +152,7 @@ test textImage-1.13 {names argument checking} -setup { image create photo small -width 5 -height 5 small put red -to 0 0 4 4 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t lappend result [.t image names] .t image create insert -image small @@ -170,7 +169,7 @@ test textImage-1.13 {names argument checking} -setup { test textImage-1.14 {basic argument checking} -setup { destroy .t } -body { - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image huh } -cleanup { @@ -184,7 +183,7 @@ test textImage-1.15 {align argument checking} -setup { image create photo small -width 5 -height 5 small put red -to 0 0 4 4 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create end -image small -align wrong } -cleanup { @@ -199,7 +198,7 @@ test textImage-1.16 {configure} -setup { image create photo small -width 5 -height 5 small put red -to 0 0 4 4 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create end -image small .t image configure small @@ -216,7 +215,7 @@ test textImage-1.17 {basic cget options} -setup { image create photo small -width 5 -height 5 small put red -to 0 0 4 4 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create end -image small foreach i {align padx pady image name} { @@ -238,7 +237,7 @@ test textImage-1.18 {basic configure options} -setup { image create photo large -width 50 -height 50 large put green -to 0 0 50 50 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create end -image small foreach {option value} {align top padx 5 pady 7 image large name none} { @@ -258,7 +257,7 @@ test textImage-1.19 {basic image naming} -setup { image create photo small -width 5 -height 5 small put red -to 0 0 4 4 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create end -image small .t image create end -image small -name small @@ -277,7 +276,7 @@ test textImage-2.1 {debug} -setup { image create photo small -width 5 -height 5 small put red -to 0 0 4 4 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t debug 1 .t insert end front @@ -291,7 +290,6 @@ test textImage-2.1 {debug} -setup { image delete small } -result {} - test textImage-3.1 {image change propagation} -setup { destroy .t set result "" @@ -300,7 +298,7 @@ test textImage-3.1 {image change propagation} -setup { image create photo vary -width 5 -height 5 vary put red -to 0 0 4 4 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create end -image vary -align top update @@ -325,7 +323,7 @@ test textImage-3.2 {delayed image management} -setup { image create photo small -width 5 -height 5 small put red -to 0 0 4 4 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create end -name test update @@ -351,7 +349,7 @@ test textImage-4.1 {alignment checking - except baseline} -setup { image create photo large -width 50 -height 50 large put green -to 0 0 50 50 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create end -image large .t image create end -image small @@ -380,7 +378,7 @@ test textImage-4.2 {alignment checking - baseline} -setup { large put green -to 0 0 50 50 } font create test_font2 -size 5 - text .t -font test_font2 -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font2 -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create end -image large .t image create end -image small -align baseline @@ -391,9 +389,9 @@ test textImage-4.2 {alignment checking - baseline} -setup { font configure test_font2 -size $size array set Metrics [font metrics test_font2] update - foreach {x y w h} [.t bbox small] {} + lassign [.t bbox small] x y w h set norm [expr { - (([image height large] - $Metrics(-linespace))/2 + ((([image height large] - $Metrics(-linespace)) / 2) + $Metrics(-ascent) - [image height small] - $y) }] lappend result "$size $norm" @@ -418,7 +416,7 @@ test textImage-4.3 {alignment and padding checking} -constraints { image create photo large -width 50 -height 50 large put green -to 0 0 50 50 } - text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0 + text .t -font test_font -borderwidth 0 -highlightthickness 0 -padx 0 -pady 0 pack .t .t image create end -image large .t image create end -image small -padx 5 -pady 10 @@ -436,7 +434,6 @@ test textImage-4.3 {alignment and padding checking} -constraints { image delete small large } -result {{default:55 22 5 5} {top:55 10 5 5} {bottom:55 35 5 5} {center:55 22 5 5} {baseline:55 22 5 5}} - test textImage-5.1 {peer widget images} -setup { destroy .t .tt } -body { |