File: xmlswitch.test

package info (click to toggle)
tclxml 3.3~svn11-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,392 kB
  • sloc: ansic: 13,292; tcl: 11,656; xml: 3,269; sh: 559; makefile: 15
file content (95 lines) | stat: -rw-r--r-- 2,068 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Commands covered:  ::xmlswitch::xmlswitch
#
# This file contains a collection of tests for one or more of the 
# xmlswitch commands.  It also tests the XPath parsing package.
# Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2008 Explain
# Copyright (c) 2000-2003 Zveno Pty Ltd.
#
# $Id: xmlswitch.test,v 1.3 2003/12/03 20:18:45 balls Exp $

package require tcltest
source [file join [tcltest::workingDirectory] tcldomutils.tcl]

testPackage xmlswitch

namespace eval ::dom::xmlswitchTest {
    namespace import -force ::tcltest::*

    catch {namespace import ::xmlswitch::xmlswitch}

    test xmlswitch-1.1 {Empty statement} -constraints {!dom_libxml2} -body {
	xmlswitch {<test></test>} {
	}
    } -result {}

    test xmlswitch-2.1 {Simple template in single argument} -constraints {!dom_libxml2} -setup {
	set result {}
    } -body {
	xmlswitch {<test></test>} {
	    test {
		append result test
	    }
	    * {
		append result *
	    }
	}
	set result
    } -result {test*}

    test xmlswitch-2.2 {Match absolute path} -constraints {!dom_libxml2} -setup {
	set result {}
    } -body {
	xmlswitch {<test><test/></test>} {
	    /test {
		append result absolute
	    }
	    test {
		append result relative
	    }
	    * {
		append result *
	    }
	}
	set result
    } -result {absoluterelative}

    test xmlswitch-2.3 {Match predicate} -constraints {!dom_libxml2} -setup {
	set result {}
    } -body {
	xmlswitch {<test><test/><test/></test>} {
	    test[2] {
		append result second
	    }
	    test[1] {
		append result first
	    }
	}
	set result
    } -result {firstsecond}

    test xmlswitch-3.1 {Simple template in multiple arguments} -constraints {!dom_libxml2} -setup {
	set result {}
    } -body {
	xmlswitch {<test></test>} \
	    test {
		append result test
	    } \
	    * {
		append result *
	    }
	set result
    } -result {test}

    # Test break return code

    # Test continue return code

    cleanupTests
}

namespace delete ::dom::xmlswitchTest

return