.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
.\"
.\" 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" ''
. ds C`
. ds C'
'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 >0, 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.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.if !\nF .nr F 0
.if \nF>0 \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
.\}
.\" ========================================================================
.\"
.IX Title "XML::Compile::Tester 3pm"
.TH XML::Compile::Tester 3pm "2018-05-18" "perl v5.26.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"
.ie n .IP "\fBreader_create\fR($schema, $comment, $type, %options)" 4
.el .IP "\fBreader_create\fR($schema, \f(CW$comment\fR, \f(CW$type\fR, \f(CW%options\fR)" 4
.IX Item "reader_create($schema, $comment, $type, %options)"
Create a reader for \f(CW$type\fR. 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 \f(CW%options\fR 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
.ie n .IP "\fBreader_error\fR($schema, $type, $xml)" 4
.el .IP "\fBreader_error\fR($schema, \f(CW$type\fR, \f(CW$xml\fR)" 4
.IX Item "reader_error($schema, $type, $xml)"
Parsing the \f(CW$xml\fR to interpret the \f(CW$type\fR 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"
.ie n .IP "\fBwriter_create\fR($schema, $comment, $type, %options)" 4
.el .IP "\fBwriter_create\fR($schema, \f(CW$comment\fR, \f(CW$type\fR, \f(CW%options\fR)" 4
.IX Item "writer_create($schema, $comment, $type, %options)"
Create a writer for \f(CW$type\fR. 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 \f(CW%options\fR 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
.ie n .IP "\fBwriter_error\fR($schema, $type, $data)" 4
.el .IP "\fBwriter_error\fR($schema, \f(CW$type\fR, \f(CW$data\fR)" 4
.IX Item "writer_error($schema, $type, $data)"
Translating the Perl \f(CW$data\fR 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
.ie n .IP "\fBwriter_test\fR( $writer, $data, [$doc] )" 4
.el .IP "\fBwriter_test\fR( \f(CW$writer\fR, \f(CW$data\fR, [$doc] )" 4
.IX Item "writer_test( $writer, $data, [$doc] )"
Run the test with a compiled \f(CW$writer\fR, which was created with \fIwriter_create()\fR.
When no \f(CW$doc\fR (XML::LibXML::Document object) was specified, then one will
be created for you.
.SS "Check templates"
.IX Subsection "Check templates"
.ie n .IP "\fBtempl_perl\fR($schema, $type, %options)" 4
.el .IP "\fBtempl_perl\fR($schema, \f(CW$type\fR, \f(CW%options\fR)" 4
.IX Item "templ_perl($schema, $type, %options)"
.PD 0
.ie n .IP "\fBtempl_xml\fR($schema, $type, %options)" 4
.el .IP "\fBtempl_xml\fR($schema, \f(CW$type\fR, \f(CW%options\fR)" 4
.IX Item "templ_xml($schema, $type, %options)"
.PD
Create an example template for \f(CW$type\fR, as \s-1XML\s0 message.
The \f(CW%options\fR 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"
.ie n .IP "\fBcompare_xml\fR( $created, $expected, [$comment] )" 4
.el .IP "\fBcompare_xml\fR( \f(CW$created\fR, \f(CW$expected\fR, [$comment] )" 4
.IX Item "compare_xml( $created, $expected, [$comment] )"
Compare the \f(CW$created\fR \s-1XML\s0 (either a string or an XML::LibXML::Element)
with the \f(CW$expected\fR 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(%options)" 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 \f(CW%options\fR 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($testns)" 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.91,
built on May 11, 2018. Website: \fIhttp://perl.overmeer.net/CPAN/\fR
.SH "LICENSE"
.IX Header "LICENSE"
Copyrights 2008\-2018 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://dev.perl.org/licenses/\fR