tclxslt/testutils.tcl File Reference

Go to the source code of this file.

Functions/Subroutines

ret ok ()
ret result (type result)
ret tracemsg (type string)
ret assert (type expr, optional message="")
ret expectError (type script, optional pattern="*")
ret comparenodes (type node1, type node2)
ret nodelist (type list1, type list2)
ret nodeset (type set1, type set2)
ret checkTree (type node, type spec)
ret testPackage (type package, optional version="")

Variables

variable tracing
variable tracingErrors

Function Documentation

ret assert ( type  expr,
optional  message = "" 
)

Definition at line 40 of file tclxslt/testutils.tcl.

References error().

00040                                                {
00041     if {![uplevel 1 [list expr $expr]]} {
00042     return -code error "Assertion {$expr} failed:\n$message"
00043     }
00044 }

Here is the call graph for this function:

ret checkTree ( type  node,
type  spec 
)

Definition at line 112 of file tclxslt/testutils.tcl.

References name, and result().

00112                                        {
00113     foreach child [dom::node children $node] specchild $spec {
00114     switch [lindex $specchild 0] {
00115         element {
00116         if {[dom::node cget $child -nodeType] != "element"} {
00117             return 0
00118         }
00119         if {[dom::node cget $child -nodeName] != [lindex $specchild 1]} {
00120             return 0
00121         }
00122         foreach {name value} [lindex $specchild 2] {
00123             if {[dom::element getAttribute $child $name] != $value} {
00124             return 0
00125             }
00126         }
00127         set result [checkTree $child [lindex $specchild 3]]
00128         if {!$result} {
00129             return 0
00130         }
00131         }
00132         pi {
00133         if {[dom::node cget $child -nodeType] != "processingInstruction"} {
00134             return 0
00135         }
00136         if {[dom::node cget $child -nodeName] != [lindex $specchild 1]} {
00137             return 0
00138         }
00139         }
00140         dtd {
00141         if {[dom::node cget $child -nodeType] != "dtd"} {
00142             return 0
00143         }
00144         }
00145         text {
00146         if {[dom::node cget $child -nodeType] != "textNode"} {
00147             return 0
00148         }
00149         if {[dom::node cget $child -nodeValue] != [lindex $specchild 1]} {
00150             return 0
00151         }
00152         }
00153         default {
00154         }
00155     }
00156     }
00157 
00158     return 1
00159 }

Here is the call graph for this function:

ret comparenodes ( type  node1,
type  node2 
)

Definition at line 69 of file tclxslt/testutils.tcl.

Referenced by nodelist(), and nodeset().

00069                                             {
00070     if {[::tcltest::testConstraint dom_libxml2] || [::tcltest::testConstraint dom_tcl]} {
00071     ::dom::node isSameNode $node1 $node2
00072     } else {
00073     return [expr ![string compare $node1 $node2]]
00074     }
00075 }

Here is the caller graph for this function:

ret expectError ( type  script,
optional  pattern = "*" 
)

Definition at line 53 of file tclxslt/testutils.tcl.

References error(), result(), and tracingErrors.

00053                                                        {
00054     set rc [catch [list uplevel 1 $script] result]
00055     if {$::tracingErrors} {
00056     puts stderr "==> [string replace $result 70 end ...]"
00057     }
00058     set rmsg [string replace $result 40 end ...]
00059     if {$rc != 1} {
00060     return -code error \
00061         "Expected error, got '$rmsg' (rc=$rc)"
00062     }
00063     return $result
00064 }

Here is the call graph for this function:

ret nodelist ( type  list1,
type  list2 
)

Definition at line 81 of file tclxslt/testutils.tcl.

References comparenodes().

00081                                         {
00082     if {[llength $list1] != [llength $list2]} {
00083     return 0
00084     }
00085     foreach node1 $list1 node2 $list2 {
00086     if {![comparenodes $node1 $node2]} {
00087         return 0
00088     }
00089     }
00090     return 1
00091 }

Here is the call graph for this function:

ret nodeset ( type  set1,
type  set2 
)

Definition at line 97 of file tclxslt/testutils.tcl.

References comparenodes().

00097                                      {
00098     if {[llength $set1] != [llength $set2]} {
00099     return 0
00100     }
00101     foreach node1 [lsort $set1] node2 [lsort $set2] {
00102     if {![comparenodes $node1 $node2]} {
00103         return 0
00104     }
00105     }
00106     return 1
00107 }

Here is the call graph for this function:

ret ok (  ) 

Definition at line 20 of file tclxslt/testutils.tcl.

00020 { return {} }

ret result ( type  result  ) 

Definition at line 25 of file tclxslt/testutils.tcl.

Referenced by checkTree(), expectError(), and testPackage().

00025 { return $result }

Here is the caller graph for this function:

ret testPackage ( type  package,
optional  version = "" 
)

Definition at line 170 of file tclxslt/testutils.tcl.

References result().

00170                                                        {
00171     if {![catch "package present $package $version"]} { return }
00172     set rc [catch "package require $package $version" result]
00173     if {$rc} { return -code $rc $result }
00174     set version $result
00175     set loadScript [package ifneeded $package $version]
00176     puts $::tcltest::outputChannel \
00177     "Loaded $package version $version via {$loadScript}"
00178     return;
00179 }

Here is the call graph for this function:

ret tracemsg ( type  string  ) 

Definition at line 30 of file tclxslt/testutils.tcl.

References tracing.

00030                             {
00031     if {$::tracing} {
00032     puts $::tcltest::outputChannel $string
00033     }
00034 }


Variable Documentation

variable tracing

Definition at line 11 of file tclxslt/testutils.tcl.

Referenced by tracemsg().

variable tracingErrors

Definition at line 12 of file tclxslt/testutils.tcl.

Referenced by expectError().


Generated on 21 Sep 2010 for Gui by  doxygen 1.6.1