From 35a1e14c068ac924f1b2e74474e535cafc86f2a0 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 12 Feb 2024 16:16:46 +0000 Subject: [PATCH] "eval destroy" -> "destroy {*}" in testcases/demo's --- library/console.tcl | 2 +- library/demos/rolodex | 2 +- library/demos/widget | 2 +- tests/color.test | 4 +-- tests/grid.test | 2 +- tests/message.test | 4 +-- tests/oldpack.test | 8 ++--- tests/pack.test | 6 ++-- tests/raise.test | 4 +-- tests/scale.test | 4 +-- tests/ttk/ttk.test | 2 +- tests/unixEmbed.test | 84 +++++++++++++++++++++---------------------- 12 files changed, 61 insertions(+), 63 deletions(-) diff --git a/library/console.tcl b/library/console.tcl index 83723f15f2..d73b2f5c81 100644 --- a/library/console.tcl +++ b/library/console.tcl @@ -595,7 +595,7 @@ proc ::tk::ConsoleBind {w} { tk::ConsoleInsert %W %A } bind Console { - eval destroy [winfo child .] + destroy {*}[winfo children .] source -encoding utf-8 [file join $tk_library console.tcl] } if {[tk windowingsystem] eq "aqua"} { diff --git a/library/demos/rolodex b/library/demos/rolodex index 89415708d8..22952a5507 100644 --- a/library/demos/rolodex +++ b/library/demos/rolodex @@ -10,7 +10,7 @@ exec wish "$0" ${1+"$@"} package require Tk -foreach i [winfo child .] { +foreach i [winfo children .] { catch {destroy $i} } diff --git a/library/demos/widget b/library/demos/widget index 13b8d0eb71..b37c70cf77 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -13,7 +13,7 @@ exec wish "$0" ${1+"$@"} package require Tk 8.5 package require msgcat -eval destroy [winfo child .] +destroy {*}[winfo children .] set tk_demoDirectory [file join [pwd] [file dirname [info script]]] ::msgcat::mcload $tk_demoDirectory namespace import ::msgcat::mc diff --git a/tests/color.test b/tests/color.test index 5b8c5d2360..fe92aaf11c 100644 --- a/tests/color.test +++ b/tests/color.test @@ -209,7 +209,7 @@ test color-2.11 {Tk_GetColor, 6 hex digits, last one invalid} -body { } -returnCodes error -result {invalid color name "#12345g"} test color-3.1 {Tk_FreeColor procedure, reference counting} colorsFree { - eval destroy [winfo child .t] + destroy {*}[winfo children .t] mkColors .t.c 40 6 0 240 240 0 -6 0 0 0 -40 pack .t.c mkColors .t.c2 20 1 250 0 0 -10 0 0 0 0 0 @@ -223,7 +223,7 @@ test color-3.1 {Tk_FreeColor procedure, reference counting} colorsFree { lappend result [colorsFree .t] } {0 1} test color-3.2 {Tk_FreeColor procedure, flushing stressed cmap information} colorsFree { - eval destroy [winfo child .t] + destroy {*}[winfo children .t] mkColors .t.c 40 6 0 240 240 0 -6 0 0 0 -40 pack .t.c mkColors .t.c2 20 1 250 0 0 -10 0 0 0 0 0 diff --git a/tests/grid.test b/tests/grid.test index 4a03cff95e..89897cafda 100644 --- a/tests/grid.test +++ b/tests/grid.test @@ -23,7 +23,7 @@ proc grid_reset {{test ?} {top .}} { gets stdin } } - eval destroy [winfo children $top] + destroy {*}[winfo children $top] update foreach {cols rows} [grid size .] {} for {set i 0} {$i <= $cols} {incr i} { diff --git a/tests/message.test b/tests/message.test index 02c04f4ede..4d6c77fc19 100644 --- a/tests/message.test +++ b/tests/message.test @@ -404,7 +404,7 @@ test message-2.2 {Tk_MessageObjCmd procedure} -body { } -returnCodes {error} -result {bad window path name "foo"} test message-2.3 {Tk_MessageObjCmd procedure} -body { catch {message foo} - winfo child . + winfo children . } -result {} test message-2.4 {Tk_MessageObjCmd procedure} -body { @@ -412,7 +412,7 @@ test message-2.4 {Tk_MessageObjCmd procedure} -body { } -returnCodes {error} -result {unknown option "-gorp"} test message-2.5 {Tk_MessageObjCmd procedure} -body { catch {message .s -gorp dump} - winfo child . + winfo children . } -result {} diff --git a/tests/oldpack.test b/tests/oldpack.test index 94e0710df1..00de930ce7 100644 --- a/tests/oldpack.test +++ b/tests/oldpack.test @@ -402,7 +402,7 @@ test oldpack-7.2 {multiple expanded windows} -body { [winfo geometry .pack.red] } -result {70x20+30+77 40x40+45+30 10x20+60+3} test oldpack-7.3 {multiple expanded windows} -body { - foreach i [winfo child .pack] { + foreach i [winfo children .pack] { pack unpack $i } pack append .pack .pack.green {left e fill} .pack.red {left expand fill} \ @@ -412,7 +412,7 @@ test oldpack-7.3 {multiple expanded windows} -body { [winfo geometry .pack.blue] } -result {40x100+0+0 20x100+40+0 40x40+60+0} test oldpack-7.4 {multiple expanded windows} -body { - foreach i [winfo child .pack] { + foreach i [winfo children .pack] { pack unpack $i } pack append .pack .pack.red {top expand} .pack.violet {top expand} \ @@ -422,7 +422,7 @@ test oldpack-7.4 {multiple expanded windows} -body { [winfo geometry .pack.blue] } -result {10x20+45+5 80x20+10+35 40x40+60+60} test oldpack-7.5 {multiple expanded windows} -body { - foreach i [winfo child .pack] { + foreach i [winfo children .pack] { pack unpack $i } pack append .pack .pack.green {right frame s} .pack.red {top expand} @@ -430,7 +430,7 @@ test oldpack-7.5 {multiple expanded windows} -body { list [winfo geometry .pack.green] [winfo geometry .pack.red] } -result {30x40+70+60 10x20+30+40} test oldpack-7.6 {multiple expanded windows} -body { - foreach i [winfo child .pack] { + foreach i [winfo children .pack] { pack unpack $i } pack append .pack .pack.violet {bottom frame e} .pack.red {right expand} diff --git a/tests/pack.test b/tests/pack.test index fb59fd91e9..6ee65f4f94 100644 --- a/tests/pack.test +++ b/tests/pack.test @@ -1557,7 +1557,7 @@ test pack-17.2 {PackLostContentProc procedure} -setup { test pack-18.1.1 {unmap content when container unmapped} -constraints { macOrUnix failsOnUbuntu failsOnXQuarz } -setup { - destroy {*}[winfo child .pack] + destroy {*}[winfo children .pack] # adjust the position of .pack before test to avoid a screen switch # that occurs with window managers that have desktops four times as big # as the screen (screen switch causes scale and other tests to fail). @@ -1580,7 +1580,7 @@ test pack-18.1.1 {unmap content when container unmapped} -constraints { test pack-18.1.2 {unmap content when container unmapped} -constraints { win } -setup { - destroy {*}[winfo child .pack] + destroy {*}[winfo children .pack] # adjust the position of .pack before test to avoid a screen switch # that occurs with window managers that have desktops four times as big # as the screen (screen switch causes scale and other tests to fail). @@ -1601,7 +1601,7 @@ test pack-18.1.2 {unmap content when container unmapped} -constraints { } -result {1 0 200 75 1} test pack-18.2 {unmap content when container unmapped} -constraints {failsOnUbuntu failsOnXQuarz} -setup { - destroy {*}[winfo child .pack] + destroy {*}[winfo children .pack] # adjust the position of .pack before test to avoid a screen switch # that occurs with window managers that have desktops four times as big # as the screen (screen switch causes scale and other tests to fail). diff --git a/tests/raise.test b/tests/raise.test index f596b2f2e3..d4ffe4967a 100644 --- a/tests/raise.test +++ b/tests/raise.test @@ -17,9 +17,7 @@ namespace import -force tcltest::test # make it easy to detect differences in order. proc raise_setup {} { - foreach i [winfo child .raise] { - destroy $i - } + destroy {*}[winfo children .raise] update idletasks foreach i {a b c d e} { label .raise.$i -text $i -relief raised -bd 2 diff --git a/tests/scale.test b/tests/scale.test index 0f32ad4883..6fc0089e1c 100644 --- a/tests/scale.test +++ b/tests/scale.test @@ -328,14 +328,14 @@ test scale-2.2 {Tk_ScaleCmd procedure} -body { } -returnCodes error -result {bad window path name "foo"} test scale-2.3 {Tk_ScaleCmd procedure} -body { catch {scale foo} - winfo child . + winfo children . } -result {} test scale-2.4 {Tk_ScaleCmd procedure} -body { scale .s -gorp dumb } -returnCodes error -result {unknown option "-gorp"} test scale-2.5 {Tk_ScaleCmd procedure} -body { catch {scale .s -gorp dumb} - winfo child . + winfo children . } -result {} diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test index f25a852e2c..fb7f47b94a 100644 --- a/tests/ttk/ttk.test +++ b/tests/ttk/ttk.test @@ -664,7 +664,7 @@ test ttk-ensemble-5 "style element create: valid" -body { ttk::style element create plain.background from default } -returnCodes 0 -result "" -eval destroy [winfo children .] +destroy {*}[winfo children .] tcltest::cleanupTests diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 383a5d5202..9b39dba239 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -142,7 +142,7 @@ test unixEmbed-1.5 {TkpUseWindow procedure, creating Container records} -constra pack .f1 .f2 dobg "set w [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t -use $w list [testembed] [expr [lindex [lindex [testembed all] 0] 0] - $w] } @@ -162,7 +162,7 @@ test unixEmbed-1.5a {TkpUseWindow procedure, creating Container records} -constr pack .f1 .f2 child alias w winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t -use [w] list [testembed] [expr {[lindex [lindex [testembed all] 0] 0] - [w]}] } @@ -181,7 +181,7 @@ test unixEmbed-1.6 {TkpUseWindow procedure, creating Container records} -constra dobg "set w1 [winfo id .f1]" dobg "set w2 [winfo id .f2]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 toplevel .t2 -use $w2 testembed @@ -203,7 +203,7 @@ test unixEmbed-1.6a {TkpUseWindow procedure, creating Container records} -constr child alias w1 winfo id .f1 child alias w2 winfo id .f2 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] toplevel .t2 -use [w2] testembed @@ -240,7 +240,7 @@ test unixEmbed-2.1 {EmbeddedEventProc procedure} -constraints { pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 testembed } @@ -264,7 +264,7 @@ test unixEmbed-2.1a {EmbeddedEventProc procedure} -constraints { pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] testembed } @@ -285,7 +285,7 @@ test unixEmbed-2.2 {EmbeddedEventProc procedure} -constraints { pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 testembed destroy .t1 @@ -306,7 +306,7 @@ test unixEmbed-2.2a {EmbeddedEventProc procedure} -constraints { pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] testembed destroy .t1 @@ -353,7 +353,7 @@ test unixEmbed-3.1 {ContainerEventProc procedure, detect creation} -constraints dobg "set w1 [winfo id .f1]" set x [testembed] dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 wm withdraw .t1 } @@ -373,7 +373,7 @@ test unixEmbed-3.1a {ContainerEventProc procedure, detect creation} -constraints child alias w1 winfo id .f1 set x [testembed] child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] wm withdraw .t1 } @@ -405,7 +405,7 @@ test unixEmbed-3.3 {ContainerEventProc procedure, disallow position changes} -co pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 -bd 2 -relief raised update wm geometry .t1 +30+40 @@ -429,7 +429,7 @@ test unixEmbed-3.3a {ContainerEventProc procedure, disallow position changes} -c pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] -bd 2 -relief raised update wm geometry .t1 +30+40 @@ -449,7 +449,7 @@ test unixEmbed-3.4 {ContainerEventProc procedure, disallow position changes} -co pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 update wm geometry .t1 300x100+30+40 @@ -473,7 +473,7 @@ test unixEmbed-3.4a {ContainerEventProc procedure, disallow position changes} -c pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] update wm geometry .t1 300x100+30+40 @@ -493,7 +493,7 @@ test unixEmbed-3.5 {ContainerEventProc procedure, geometry requests} -constraint pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 } update @@ -517,7 +517,7 @@ test unixEmbed-3.5a {ContainerEventProc procedure, geometry requests} -constrain pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] .t1 configure -width 300 -height 80 update @@ -536,7 +536,7 @@ test unixEmbed-3.6 {ContainerEventProc procedure, map requests} -constraints { pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 set x unmapped bind .t1 {set x mapped} @@ -562,7 +562,7 @@ test unixEmbed-3.6a {ContainerEventProc procedure, map requests} -constraints { pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] set x unmapped bind .t1 {set x mapped} @@ -586,7 +586,7 @@ test unixEmbed-3.7 {ContainerEventProc procedure, destroy events} -constraints { bind .f1 {set x dead} set x alive dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 } update @@ -612,7 +612,7 @@ test unixEmbed-3.7a {ContainerEventProc procedure, destroy events} -constraints bind .f1 {set x dead} set x alive child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] update destroy .t1 @@ -633,7 +633,7 @@ test unixEmbed-4.1 {EmbedStructureProc procedure, configure events} -constraints pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 } update @@ -659,7 +659,7 @@ test unixEmbed-4.1a {EmbedStructureProc procedure, configure events} -constraint pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] update .t1 configure -width 180 -height 100 @@ -679,7 +679,7 @@ test unixEmbed-4.2 {EmbedStructureProc procedure, destroy events} -constraints { pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 } update @@ -703,7 +703,7 @@ test unixEmbed-4.2a {EmbedStructureProc procedure, destroy events} -constraints update child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] } set x [testembed] @@ -725,7 +725,7 @@ test unixEmbed-5.1 {EmbedFocusProc procedure, FocusIn events} -constraints { update dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 bind .t1 {lappend x "focus in %W"} bind .t1 {lappend x "focus out %W"} @@ -750,7 +750,7 @@ test unixEmbed-5.1a {EmbedFocusProc procedure, FocusIn events} -constraints { update child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] bind .t1 {lappend x "focus in %W"} bind .t1 {lappend x "focus out %W"} @@ -774,7 +774,7 @@ test unixEmbed-5.2 {EmbedFocusProc procedure, focusing on dead window} -constrai update dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 } update @@ -800,7 +800,7 @@ test unixEmbed-5.2a {EmbedFocusProc procedure, focusing on dead window} -constra update child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] update after 200 {destroy .t1} @@ -822,7 +822,7 @@ test unixEmbed-5.3 {EmbedFocusProc procedure, FocusOut events} -constraints { update dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 bind .t1 {lappend x "focus in %W"} bind .t1 {lappend x "focus out %W"} @@ -850,7 +850,7 @@ test unixEmbed-5.3a {EmbedFocusProc procedure, FocusOut events} -constraints { update child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] set x {} bind .t1 {lappend x "focus in %W"} @@ -878,7 +878,7 @@ test unixEmbed-6.1 {EmbedGeometryRequest procedure, window changes size} -constr pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 update bind .t1 {lappend x {configure .t1 %w %h}} @@ -902,7 +902,7 @@ test unixEmbed-6.1a {EmbedGeometryRequest procedure, window changes size} -const pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] update bind .t1 {set x {configure .t1 %w %h}} @@ -924,7 +924,7 @@ test unixEmbed-6.2 {EmbedGeometryRequest procedure, window changes size} -constr place .f1 -width 200 -height 200 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 update bind .t1 {lappend x {configure .t1 %w %h}} @@ -949,7 +949,7 @@ test unixEmbed-6.2a {EmbedGeometryRequest procedure, window changes size} -const update child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] update bind .t1 {set x {configure .t1 %w %h}} @@ -975,7 +975,7 @@ test unixEmbed-7.1 {TkpRedirectKeyEvent procedure, forward keystroke} -constrain pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 } focus -force . @@ -1009,7 +1009,7 @@ test unixEmbed-7.1a {TkpRedirectKeyEvent procedure, forward keystroke} -constrai pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] } focus -force . @@ -1038,7 +1038,7 @@ test unixEmbed-7.2 {TkpRedirectKeyEvent procedure, don't forward keystroke width pack .f1 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 } update @@ -1071,7 +1071,7 @@ test unixEmbed-7.2a {TkpRedirectKeyEvent procedure, don't forward keystroke widt pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] } update @@ -1104,7 +1104,7 @@ test unixEmbed-8.1 {TkpClaimFocus procedure} -constraints { pack .f1 .f2 dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 -highlightthickness 2 -bd 2 -relief sunken } focus -force .f2 @@ -1132,7 +1132,7 @@ test unixEmbed-8.1a {TkpClaimFocus procedure} -constraints unix -setup { update child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] -highlightthickness 2 -bd 2 -relief sunken } # This should clear focus from the application embedded in .f1 @@ -1206,7 +1206,7 @@ test unixEmbed-9.2 {EmbedWindowDeleted procedure, check embeddedPtr} -constraint update dobg "set w1 [winfo id .f1]" dobg { - eval destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use $w1 -highlightthickness 2 -bd 2 -relief sunken set x {} lappend x [testembed] @@ -1228,7 +1228,7 @@ test unixEmbed-9.2a {EmbedWindowDeleted procedure, check embeddedPtr} -constrain pack .f1 child alias w1 winfo id .f1 child eval { - destroy [winfo child .] + destroy {*}[winfo children .] toplevel .t1 -use [w1] -highlightthickness 2 -bd 2 -relief sunken set x {} lappend x [testembed]