summaryrefslogtreecommitdiffstats
path: root/tests/main.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/main.test
parent41f5d19540b0b3f053da352e1569c9a4ed019dd5 (diff)
downloadtk-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/main.test')
-rw-r--r--tests/main.test48
1 files changed, 24 insertions, 24 deletions
diff --git a/tests/main.test b/tests/main.test
index 7ab624f..19291c1 100644
--- a/tests/main.test
+++ b/tests/main.test
@@ -25,16 +25,16 @@ test main-2.1 {Tk_MainEx: -encoding option} -constraints stdio -setup {
set script [makeFile {} script]
file delete $script
set f [open $script w]
- fconfigure $f -encoding utf-8
- puts $f {puts [list $argv0 $argv $tcl_interactive]}
- puts -nonewline $f {puts [string equal \u20ac }
- puts $f "\u20ac]; exit"
- close $f
+ chan configure $f -encoding utf-8
+ chan puts $f {puts [list $argv0 $argv $tcl_interactive]}
+ chan puts -nonewline $f {puts [string equal \u20ac }
+ chan puts $f "\u20ac]; exit"
+ chan close $f
catch {set f [open "|[list [interpreter] -encoding utf-8 script]" r]}
} -body {
- read $f
+ chan read $f
} -cleanup {
- close $f
+ chan close $f
removeFile script
} -result "script {} 0\n1\n"
@@ -42,16 +42,16 @@ test main-2.2 {Tk_MainEx: -encoding option} -constraints stdio -setup {
set script [makeFile {} script]
file delete $script
set f [open $script w]
- fconfigure $f -encoding utf-8
- puts $f {puts [list $argv0 $argv $tcl_interactive]}
- puts -nonewline $f {puts [string equal \u20ac }
- puts $f "\u20ac]; exit"
- close $f
+ chan configure $f -encoding utf-8
+ chan puts $f {puts [list $argv0 $argv $tcl_interactive]}
+ chan puts -nonewline $f {puts [string equal \u20ac }
+ chan puts $f "\u20ac]; exit"
+ chan close $f
catch {set f [open "|[list [interpreter] -encoding ascii script]" r]}
} -body {
- read $f
+ chan read $f
} -cleanup {
- close $f
+ chan close $f
removeFile script
} -result "script {} 0\n0\n"
@@ -60,8 +60,8 @@ test main-2.2 {Tk_MainEx: -encoding option} -constraints stdio -setup {
proc type {chan script} {
foreach line [split $script \n] {
if {[catch {
- puts $chan $line
- flush $chan
+ chan puts $chan $line
+ chan flush $chan
}]} {
return
}
@@ -74,20 +74,20 @@ test main-2.3 {Tk_MainEx: -encoding option} -constraints stdio -setup {
set script [makeFile {} script]
file delete $script
set f [open $script w]
- fconfigure $f -encoding utf-8
- puts $f {puts [list $argv0 $argv $tcl_interactive]}
- puts -nonewline $f {puts [string equal \u20ac }
- puts $f "\u20ac]"
- close $f
+ chan configure $f -encoding utf-8
+ chan puts $f {puts [list $argv0 $argv $tcl_interactive]}
+ chan puts -nonewline $f {puts [string equal \u20ac }
+ chan puts $f "\u20ac]"
+ chan close $f
catch {set f [open "|[list [interpreter] -enc utf-8 script]" r+]}
} -body {
type $f {
- puts $argv
+ chan puts $argv
exit
}
- gets $f
+ chan gets $f
} -cleanup {
- close $f
+ chan close $f
removeFile script
} -returnCodes ok -result {-enc utf-8 script}