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
|
# Commands covered: relaxng validate
#
# This file contains a collection of tests for one or more of the
# TclDOM commands. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 2009 Explain
#
# $Id$
package require tcltest
source [file join [tcltest::workingDirectory] tcldomutils.tcl]
testPackage dom
namespace eval ::dom::relaxngTest {
namespace import -force ::tcltest::*
variable SETUP {
set valid [dom::parse {<t:Test xmlns:t='urn:tcl-dom-test'>This is a valid document</t:Test>}]
set invalid [dom::parse {<t:Invalid xmlns:t='urn:tcl-dom-test'>This is an invalid document</t:Invalid>}]
set schema [dom::parse {<grammar xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:rng="http://relaxng.org/ns/structure/1.0"
xmlns:test="urn:tcl-dom-test"
ns="urn:tcl-dom-test">
<start>
<ref name='test.Test'/>
</start>
<define name='test.Test'>
<element name='Test'>
<text/>
</element>
</define>
</grammar>
}]
}
variable CLEANUP {
dom::destroy $valid
dom::destroy $invalid
dom::destroy $schema
}
### RELAX NG compilation
test relaxng-1.1 {compile RELAX NG schema} -setup $SETUP -constraints {dom_libxml2} -match glob -body {
$schema relaxng compile
} -cleanup $CLEANUP -result {*}
test relaxng-1.2 {RELAX NG compile too many args} -setup $SETUP -constraints {dom_libxml2} -match glob -body {
expectError {
$schema relaxng compile another
}
} -cleanup $CLEANUP -result {wrong # args*}
test relaxng-1.3 {RELAX NG too few args} -setup $SETUP -constraints {dom_libxml2} -match glob -body {
expectError {
$schema relaxng
}
} -cleanup $CLEANUP -result {wrong # args*}
test relaxng-2.1 {RELAX NG validate validate doc} -setup {
eval $SETUP
$schema relaxng compile
} -constraints {dom_libxml2} -body {
$schema relaxng validate $valid
} -cleanup $CLEANUP -result {}
test relaxng-2.2 {RELAX NG validate invalid doc} -constraints {dom_libxml2} -setup {
eval $SETUP
$schema relaxng compile
} -match glob -body {
expectError {
$schema relaxng validate $invalid
}
} -cleanup $CLEANUP -result {*relaxng-validation error*Expecting element Test*}
cleanupTests
}
namespace delete ::dom::relaxngTest
return
|