File: pi.test

package info (click to toggle)
tclxml 3.1-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,076 kB
  • ctags: 876
  • sloc: ansic: 6,064; tcl: 5,116; xml: 4,642; sh: 3,112; makefile: 60
file content (87 lines) | stat: -rwxr-xr-x 2,473 bytes parent folder | download | duplicates (5)
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
# Features covered:  Processing Instructions
#
# This file contains a collection of tests for the TclXML parser.
# This file tests the parser's performance on Processing Instructions.
# Sourcing this file into Tcl runs the tests and generates output
# for errors.  No output means no errors were found.
#
# Copyright (c) 1998-2004 Zveno Pty Ltd.
#
# $Id: pi.test,v 1.7 2004/02/20 09:15:52 balls Exp $

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

testPackage $::tcltest::parser

namespace eval ::xml::piTest {
    namespace import -force ::tcltest::*

    variable SETUP {
	variable result {}

	proc PI {target data args} {
	    variable result
	    lappend result $target $data
	}

	set parser [xml::parser \
		-processinginstructioncommand [namespace code PI]]
    }
    variable CLEANUP {
	catch {unset result}
	$parser free
    }

    test pi-1.1 {PI} -setup $SETUP -body {
	$parser parse {<?xml version="1.0"?>
<!DOCTYPE Test>
<Test><?Test This is a processing instruction?></Test>
}
	set result
    } -cleanup $CLEANUP -result {Test {This is a processing instruction}}

    test pi-1.2 {PI: missing trailing ?} -setup $SETUP -match regexp -body {
	expectError {
	    $parser parse {<?xml version="1.0"?>
<!DOCTYPE Test>
<Test><?Test This is a syntax error></Test>
}
	}
    } -cleanup $CLEANUP -result {(PI: expected '\?' character)|(error:.*PI Test never end)|(.*processing-instruction-not-finished.*)}

    # Test Tcl special characters in PI data.
    # NB. Tets had to modified since the PI target must be
    # an XML Name (reported by rolf@pointsman.de)

    test pi-2.1 {PI with special characters} -setup $SETUP -body {
	$parser parse {<?xml version="1.0"?>
<!DOCTYPE Test>
<Test><?if [!VMLRender]?></Test>
}
	set result
    } -cleanup $CLEANUP -result {if {[!VMLRender]}}

    test pi-2.2 {PI target with special characters} -setup $SETUP -match regexp -body {
	expectError {
	    $parser parse {<?xml version="1.0"?>
<!DOCTYPE Test>
<Test><?[if !VMLRender]?></Test>
}
	}
    } -cleanup $CLEANUP -result {(illegal character.*in processing instruction target)|(no target name)}

    test pi-2.3 {PI target with "xml"} -setup $SETUP -constraints {!xml_libxml2} -match glob -body {
	expectError {
	    $parser parse {<?xml version="1.0"?>
<!DOCTYPE Test>
<Test><?abxMLcl illegal?></Test>
}
	}
    } -cleanup $CLEANUP -result {*characters "xml" not permitted*}

    cleanupTests
}

namespace delete ::xml::piTest
return