summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-05-19 12:51:34 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-05-19 12:51:34 (GMT)
commit60527b86bc700ebbb6dc28928918ce206bd0c5ce (patch)
treec0d0f991217209257e0f7aca4eba13b10174dfed
parenteed4bea0be5e6a437943a58152e4f8ebde40fd66 (diff)
downloadtcl-60527b86bc700ebbb6dc28928918ce206bd0c5ce.zip
tcl-60527b86bc700ebbb6dc28928918ce206bd0c5ce.tar.gz
tcl-60527b86bc700ebbb6dc28928918ce206bd0c5ce.tar.bz2
Use constraints instead of conditional tests
-rw-r--r--tests/pid.test32
-rw-r--r--tests/proc.test47
2 files changed, 21 insertions, 58 deletions
diff --git a/tests/pid.test b/tests/pid.test
index 39838d9..09715e5 100644
--- a/tests/pid.test
+++ b/tests/pid.test
@@ -11,28 +11,22 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: pid.test,v 1.10 2004/02/25 23:56:59 dgp Exp $
+# RCS: @(#) $Id: pid.test,v 1.11 2004/05/19 12:51:34 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
namespace import -force ::tcltest::*
}
-# If pid is not defined just return with no error
-# Some platforms may not have the pid command implemented
-if {[info commands pid] == ""} {
- puts "pid is not implemented for this machine"
- ::tcltest::cleanupTests
- return
-}
+testConstraint pidDefined [llength [info commands pid]]
-test pid-1.1 {pid command} {
+test pid-1.1 {pid command} pidDefined {
regexp {(^[0-9]+$)|(^0x[0-9a-fA-F]+$)} [pid]
} 1
test pid-1.2 {pid command} -constraints {unixOrPc unixExecs} -setup {
set path(test1) [makeFile {} test1]
file delete $path(test1)
-} -body {
+} -constraints pidDefined -body {
set f [open |[list echo foo | cat >$path(test1)] w]
set pids [pid $f]
close $f
@@ -42,7 +36,7 @@ test pid-1.2 {pid command} -constraints {unixOrPc unixExecs} -setup {
} -cleanup {
removeFile test1
} -result {2 1 1 0}
-test pid-1.3 {pid command} -setup {
+test pid-1.3 {pid command} -constraints pidDefined -setup {
set path(test1) [makeFile {} test1]
file delete $path(test1)
} -body {
@@ -53,25 +47,13 @@ test pid-1.3 {pid command} -setup {
} -cleanup {
removeFile test1
} -result {}
-test pid-1.4 {pid command} {
+test pid-1.4 {pid command} pidDefined {
list [catch {pid a b} msg] $msg
} {1 {wrong # args: should be "pid ?channelId?"}}
-test pid-1.5 {pid command} {
+test pid-1.5 {pid command} pidDefined {
list [catch {pid gorp} msg] $msg
} {1 {can not find channel named "gorp"}}
# cleanup
::tcltest::cleanupTests
return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/proc.test b/tests/proc.test
index 4f7fab6..988fb0f 100644
--- a/tests/proc.test
+++ b/tests/proc.test
@@ -13,13 +13,19 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: proc.test,v 1.15 2004/05/02 21:04:44 msofer Exp $
+# RCS: @(#) $Id: proc.test,v 1.16 2004/05/19 12:54:56 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
}
+if {[catch {package require procbodytest}]} {
+ testConstraint procbodytest 0
+} else {
+ testConstraint procbodytest 1
+}
+
catch {namespace delete {expand}[namespace children :: test_ns_*]}
catch {rename p ""}
catch {rename {} ""}
@@ -177,13 +183,6 @@ catch {rename {} ""}
catch {rename {a b c} {}}
catch {unset msg}
-if {[catch {package require procbodytest}]} {
- puts "This application couldn't load the \"procbodytest\" package, so I"
- puts "can't test creation of procs whose bodies have type \"procbody\"."
- ::tcltest::cleanupTests
- return
-}
-
catch {rename p ""}
catch {rename t ""}
@@ -192,7 +191,7 @@ catch {rename t ""}
# is executed, so that the Proc struct is populated correctly (CompiledLocals
# are added at compile time).
-test proc-4.1 {TclCreateProc, procbody obj} {
+test proc-4.1 {TclCreateProc, procbody obj} procbodytest {
catch {
proc p x {return "$x:$x"}
set rv [p P]
@@ -204,8 +203,7 @@ test proc-4.1 {TclCreateProc, procbody obj} {
catch {rename t ""}
set result
} {P:P T:T}
-
-test proc-4.2 {TclCreateProc, procbody obj, use compiled locals} {
+test proc-4.2 {TclCreateProc, procbody obj, use compiled locals} procbodytest {
catch {
proc p x {
set y [string tolower $x]
@@ -220,8 +218,7 @@ test proc-4.2 {TclCreateProc, procbody obj, use compiled locals} {
catch {rename t ""}
set result
} {P:p T:t}
-
-test proc-4.3 {TclCreateProc, procbody obj, too many args} {
+test proc-4.3 {TclCreateProc, procbody obj, too many args} procbodytest {
catch {
proc p x {
set y [string tolower $x]
@@ -236,8 +233,7 @@ test proc-4.3 {TclCreateProc, procbody obj, too many args} {
catch {rename t ""}
set result
} {procedure "t": arg list contains 3 entries, precompiled header expects 1}
-
-test proc-4.4 {TclCreateProc, procbody obj, inconsitent arg name} {
+test proc-4.4 {TclCreateProc, procbody obj, inconsitent arg name} procbodytest {
catch {
proc p {x y z} {
set v [join [list $x $y $z]]
@@ -253,8 +249,7 @@ test proc-4.4 {TclCreateProc, procbody obj, inconsitent arg name} {
catch {rename t ""}
set result
} {procedure "t": formal parameter 1 is inconsistent with precompiled body}
-
-test proc-4.5 {TclCreateProc, procbody obj, inconsitent arg default type} {
+test proc-4.5 {TclCreateProc, procbody obj, inconsitent arg default type} procbodytest {
catch {
proc p {x y {z Z}} {
set v [join [list $x $y $z]]
@@ -270,8 +265,7 @@ test proc-4.5 {TclCreateProc, procbody obj, inconsitent arg default type} {
catch {rename t ""}
set result
} {procedure "t": formal parameter 2 is inconsistent with precompiled body}
-
-test proc-4.6 {TclCreateProc, procbody obj, inconsitent arg default type} {
+test proc-4.6 {TclCreateProc, procbody obj, inconsitent arg default type} procbodytest {
catch {
proc p {x y z} {
set v [join [list $x $y $z]]
@@ -287,8 +281,7 @@ test proc-4.6 {TclCreateProc, procbody obj, inconsitent arg default type} {
catch {rename t ""}
set result
} {procedure "t": formal parameter 2 is inconsistent with precompiled body}
-
-test proc-4.7 {TclCreateProc, procbody obj, inconsitent arg default value} {
+test proc-4.7 {TclCreateProc, procbody obj, inconsitent arg default value} procbodytest {
catch {
proc p {x y {z Z}} {
set v [join [list $x $y $z]]
@@ -345,15 +338,3 @@ catch {rename p ""}
catch {rename t ""}
::tcltest::cleanupTests
return
-
-
-
-
-
-
-
-
-
-
-
-