summaryrefslogtreecommitdiffstats
path: root/tests/msgbox.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/msgbox.test')
-rw-r--r--tests/msgbox.test43
1 files changed, 18 insertions, 25 deletions
diff --git a/tests/msgbox.test b/tests/msgbox.test
index b15c61d..ec98c89 100644
--- a/tests/msgbox.test
+++ b/tests/msgbox.test
@@ -6,28 +6,25 @@
# All rights reserved.
package require tcltest 2.1
-namespace import -force tcltest::configure
-namespace import -force tcltest::testsDirectory
-configure -testdir [file join [pwd] [file dirname [info script]]]
-configure -loadfile [file join [testsDirectory] constraints.tcl]
+eval tcltest::configure $argv
tcltest::loadTestedCommands
test msgbox-1.1 {tk_messageBox command} {
list [catch {tk_messageBox -foo} msg] $msg
-} {1 {bad option "-foo": must be -default, -icon, -message, -parent, -title, or -type}}
+} {1 {bad option "-foo": must be -default, -detail, -icon, -message, -parent, -title, or -type}}
test msgbox-1.2 {tk_messageBox command} {
list [catch {tk_messageBox -foo bar} msg] $msg
-} {1 {bad option "-foo": must be -default, -icon, -message, -parent, -title, or -type}}
+} {1 {bad option "-foo": must be -default, -detail, -icon, -message, -parent, -title, or -type}}
catch {tk_messageBox -foo bar} msg
regsub -all , $msg "" options
regsub \"-foo\" $options "" options
foreach option $options {
- if {[string index $option 0] == "-"} {
- test msgbox-1.3 {tk_messageBox command} {
- list [catch {tk_messageBox $option} msg] $msg
- } [list 1 "value for \"$option\" missing"]
+ if {[string index $option 0] eq "-"} {
+ test msgbox-1.3$option {tk_messageBox command} -body {
+ tk_messageBox $option
+ } -returnCodes error -result "value for \"$option\" missing"
}
}
@@ -67,11 +64,7 @@ test msgbox-1.10 {tk_messageBox command} {
list [catch {tk_messageBox -parent foo.bar} msg] $msg
} {1 {bad window path name "foo.bar"}}
-if {[info commands tk::MessageBox] == ""} {
- set isNative 1
-} else {
- set isNative 0
-}
+set isNative [expr {[info commands tk::MessageBox] == ""}]
proc ChooseMsg {parent btn} {
global isNative
@@ -133,35 +126,35 @@ foreach spec $specs {
set buttons [lindex $spec 3]
set button [lindex $buttons 0]
- test msgbox-2.$count {tk_messageBox command} {nonUnixUserInteraction} {
+ test msgbox-2.$count {tk_messageBox command} nonUnixUserInteraction {
ChooseMsg $parent $button
tk_messageBox -title Hi -message "Please press $button" \
- -type $type
+ -type $type
} $button
incr count
foreach icon {warning error info question} {
test msgbox-2.$count {tk_messageBox command -icon option} \
- {nonUnixUserInteraction} {
+ nonUnixUserInteraction {
ChooseMsg $parent $button
tk_messageBox -title Hi -message "Please press $button" \
- -type $type -icon $icon
+ -type $type -icon $icon
} $button
incr count
}
foreach button $buttons {
- test msgbox-2.$count {tk_messageBox command} {nonUnixUserInteraction} {
+ test msgbox-2.$count {tk_messageBox command} nonUnixUserInteraction {
ChooseMsg $parent $button
tk_messageBox -title Hi -message "Please press $button" \
- -type $type -default $button
+ -type $type -default $button
} "$button"
incr count
}
}
# These tests will hang your test suite if they fail.
-test msgbox-3.1 {tk_messageBox handles withdrawn parent} {nonUnixUserInteraction} {
+test msgbox-3.1 {tk_messageBox handles withdrawn parent} nonUnixUserInteraction {
wm withdraw .
ChooseMsg . "ok"
tk_messageBox -title Hi -message "Please press ok" \
@@ -169,14 +162,14 @@ test msgbox-3.1 {tk_messageBox handles withdrawn parent} {nonUnixUserInteraction
} "ok"
wm deiconify .
-test msgbox-3.2 {tk_messageBox handles iconified parent} {nonUnixUserInteraction} {
+test msgbox-3.2 {tk_messageBox handles iconified parent} nonUnixUserInteraction {
wm iconify .
ChooseMsg . "ok"
tk_messageBox -title Hi -message "Please press ok" \
-type ok -default ok
} "ok"
-wm deiconify .
+wm deiconify .
# cleanup
-::tcltest::cleanupTests
+cleanupTests
return