.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "XML::Compile::Tester 3pm" .TH XML::Compile::Tester 3pm "2012-08-15" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" XML::Compile::Tester \- support XML::Compile related regression testing .SH "INHERITANCE" .IX Header "INHERITANCE" .Vb 2 \& XML::Compile::Tester \& is a Exporter .Ve .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use XML::Compile::Tester; \& \& # default additional compile flags, avoids repetition \& set_compile_defaults(validation => 0, @other_opts); \& set_compile_defaults(); # reset \& \& # set default namespace, such that $type only needs to use local \& my $ns = \*(Aqsome\-schemas\-targetNamespace\*(Aq; \& my $type = pack_type($ns, \*(AqlocalName\*(Aq); # X::C::Util \& set_default_namespace($ns); \& my $type = \*(AqlocalName\*(Aq; # now implicit in $ns \& \& my $reader = reader_create($schema, "my reader", $type, @opts); \& my $data = $reader\->($xml); # $xml is string, filename, node \& \& my $writer = writer_create($schema, "my writer", $type, @opts); \& my $xml = $writer\->($doc, $data); \& my $xml = writer_test($writer, $data); \& \& my $rerror = reader_error($schema, $type, $xml); \& my $werror = writer_error($schema, $type, $data); \& \& my $output = templ_xml($schema, $type, @options); \& my $output = templ_perl($schema, $type, @options); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The XML::Compile module suite has extensive regression testing. Probably, you want to do regression testing as well. This module provide functions which simplify writing tests for XML::Compile related distributions. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "Reader checks" .IX Subsection "Reader checks" .IP "\fBreader_create\fR(\s-1SCHEMA\s0, \s-1COMMENT\s0, \s-1TYPE\s0, \s-1OPTIONS\s0)" 4 .IX Item "reader_create(SCHEMA, COMMENT, TYPE, OPTIONS)" Create a reader for \s-1TYPE\s0. One test is created, reporting success or failure of the creation. .Sp Of course, XML::Compile::Schema subroutine compile is being called, with some options. By default, \f(CW\*(C`check_values\*(C'\fR is true, and \f(CW\*(C`include_namespaces\*(C'\fR is false. These values can be overruled using \fIset_compile_defaults()\fR, and with the \s-1OPTIONS\s0 parameter list. .Sp example: reader_create .Sp .Vb 3 \& my $type = pack_type(\*(Aqnamespace\*(Aq, \*(AqlocalName\*(Aq); \& my $reader = reader_create($schema, \*(Aqmy test\*(Aq, $type \& , check_occurs => 0, @other_options); \& \& my $data = $reader\->($xml); \& is_deeply($data, $expected, \*(Aqmy test\*(Aq); # Test::More \& cmp_deeply($data, $expected, \*(Aqmy test\*(Aq); # Test::Deep \& \& # alternative for $type: \& set_default_namespace(\*(Aqnamespace\*(Aq); \& my $reader = reader_create($schema, \*(Aqmy test\*(Aq, \*(AqlocalName\*(Aq \& , check_occurs => 0, @other_options); .Ve .IP "\fBreader_error\fR(\s-1SCHEMA\s0, \s-1TYPE\s0, \s-1XML\s0)" 4 .IX Item "reader_error(SCHEMA, TYPE, XML)" Parsing the \s-1XML\s0 to interpret the \s-1TYPE\s0 should return an error. The error text is returned. .Sp example: reader_error .Sp .Vb 3 \& my $error = reader_error($schema, $type, <<_XML); \& ... \& _XML \& \& is($error, \*(Aqerror text\*(Aq, \*(Aqmy test\*(Aq); \& like($error, qr/error pattern/, \*(Aqmy test\*(Aq); .Ve .SS "Writer checks" .IX Subsection "Writer checks" .IP "\fBwriter_create\fR(\s-1SCHEMA\s0, \s-1COMMENT\s0, \s-1TYPE\s0, \s-1OPTIONS\s0)" 4 .IX Item "writer_create(SCHEMA, COMMENT, TYPE, OPTIONS)" Create a writer for \s-1TYPE\s0. One test (in the Test::More sense) is created, reporting success or failure of the creation. .Sp Of course, XML::Compile::Schema subroutine compile is being called, with some options. By default, \f(CW\*(C`check_values\*(C'\fR and \f(CW\*(C`use_default_namespace\*(C'\fR are true, and \f(CW\*(C`include_namespaces\*(C'\fR is false. These values can be overruled using \&\fIset_compile_defaults()\fR, and with the \s-1OPTIONS\s0 parameter list. .Sp example: writer_create .Sp .Vb 2 \& set_default_namespace(\*(Aqnamespace\*(Aq); \& my $writer = writer_create($schema, \*(Aqmy test\*(Aq, \*(Aqtest1\*(Aq); \& \& my $doc = XML::LibXML::Document\->new(\*(Aq1.0\*(Aq, \*(AqUTF\-8\*(Aq); \& my $xml = $writer\->($doc, $data); \& compare_xml($xml, <<_EXPECTED, \*(Aqmy test\*(Aq); \& ... \& _EXPECTED \& \& # implicit creation of $doc \& my $xml = writer_test($writer, $data); .Ve .IP "\fBwriter_error\fR(\s-1SCHEMA\s0, \s-1TYPE\s0, \s-1DATA\s0)" 4 .IX Item "writer_error(SCHEMA, TYPE, DATA)" Translating the Perl \s-1DATA\s0 into the \s-1XML\s0 type should return a validation error, which is returned. .Sp example: writer_error .Sp .Vb 1 \& my $error = writer_error($schema, $type, $data); \& \& is($error, \*(Aqerror text\*(Aq, \*(Aqmy test\*(Aq); \& like($error, qr/error pattern/, \*(Aqmy test\*(Aq); .Ve .IP "\fBwriter_test\fR(\s-1WRITER\s0, \s-1DATA\s0, [\s-1DOC\s0])" 4 .IX Item "writer_test(WRITER, DATA, [DOC])" Run the test with a compiled \s-1WRITER\s0, which was created with \fIwriter_create()\fR. When no \s-1DOC\s0 (XML::LibXML::Document object) was specified, then one will be created for you. .SS "Check templates" .IX Subsection "Check templates" .IP "\fBtempl_perl\fR(\s-1SCHEMA\s0, \s-1TYPE\s0, \s-1OPTIONS\s0)" 4 .IX Item "templ_perl(SCHEMA, TYPE, OPTIONS)" .PD 0 .IP "\fBtempl_xml\fR(\s-1SCHEMA\s0, \s-1TYPE\s0, \s-1OPTIONS\s0)" 4 .IX Item "templ_xml(SCHEMA, TYPE, OPTIONS)" .PD Create an example template for \s-1TYPE\s0, as \s-1XML\s0 message. The \s-1OPTIONS\s0 are passed to XML::Compile::Schema subroutine template. .Sp example: templ_xml .Sp .Vb 2 \& my $out = templ_xml($schema, $type, show => \*(AqALL\*(Aq); \& is($out, $expected); .Ve .SS "Helpers" .IX Subsection "Helpers" .IP "\fBcompare_xml\fR(\s-1XML\s0, \s-1EXPECTED\s0, [\s-1COMMENT\s0])" 4 .IX Item "compare_xml(XML, EXPECTED, [COMMENT])" Compare the \s-1XML\s0 (either a string or an XML::LibXML::Element) with the \s-1EXPECTED\s0 string. Both sources are stripped from layout before comparing. .Sp In a future release, this algorithm will get improved to compare the parsed \s-1XML\s0 node trees, not the strings. .Sp example: compare_xml .Sp .Vb 3 \& compare_xml($xml, <<_XML, \*(Aqmy test\*(Aq); \& ... \& _XML .Ve .IP "\fBset_compile_defaults\fR(\s-1OPTIONS\s0)" 4 .IX Item "set_compile_defaults(OPTIONS)" Each call to create a reader or writer (also indirectly) with XML::Compile::Schema subroutine compile will get these \s-1OPTIONS\s0 passed, on top (and overruling) the usual settings. .Sp example: .Sp .Vb 3 \& # defaults for XML::Compile::Schema::compile() \& set_compile_defaults(include_namespaces => 1, validate => 0 \& , sloppy_intergers => 1, sloppy_floats => 1); \& \& set_compile_defaults(); # reset .Ve .IP "\fBset_default_namespace\fR(\s-1TESTNS\s0)" 4 .IX Item "set_default_namespace(TESTNS)" Defined which namespace to use when a relative (only localName) type is provided. By default, this is \f(CW\*(C`undef\*(C'\fR (an error when used) .SH "SEE ALSO" .IX Header "SEE ALSO" This module is part of XML-Compile-Tester distribution version 0.90, built on August 16, 2012. Website: \fIhttp://perl.overmeer.net/xml\-compile/\fR .PP Other distributions in this suite: XML::Compile, XML::Compile::SOAP, XML::Compile::SOAP12, XML::Compile::SOAP::Daemon, XML::Compile::SOAP::WSA, XML::Compile::C14N, XML::Compile::WSS, XML::Compile::Tester, XML::Compile::Cache, XML::Compile::Dumper, XML::Compile::RPC, XML::Rewrite, XML::eXistDB, and XML::LibXML::Simple. .PP Please post questions or ideas to the mailinglist at \&\fIhttp://lists.scsys.co.uk/cgi\-bin/mailman/listinfo/xml\-compile\fR For live contact with other developers, visit the \f(CW\*(C`#xml\-compile\*(C'\fR channel on \f(CW\*(C`irc.perl.org\*(C'\fR. .SH "LICENSE" .IX Header "LICENSE" Copyrights 2008\-2012 by [Mark Overmeer]. For other contributors see ChangeLog. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See \fIhttp://www.perl.com/perl/misc/Artistic.html\fR