XML-Compile-Tester-0.91/0000755000175000001440000000000013275155417015465 5ustar00markovusers00000000000000XML-Compile-Tester-0.91/README.md0000644000175000001440000000413413275155366016751 0ustar00markovusers00000000000000# distribution XML-Compile-Tester * My extended documentation: * Development via GitHub: * Download from CPAN: * Indexed from CPAN: and The XML-Compile suite is a large set of modules for various XML related standards. This component provides help with testing. ## Development → Release Important to know, is that I use an extension on POD to write the manuals. The "raw" unprocessed version is visible on GitHub. It will run without problems, but does not contain manual-pages. Releases to CPAN are different: "raw" documentation gets removed from the code and translated into real POD and clean HTML. This reformatting is implemented with the OODoc distribution (A name I chose before OpenOffice existed, sorry for the confusion) Clone from github for the "raw" version. For instance, when you want to contribute a new feature. On github, you can find the processed version for each release. But the better source is CPAN; to get it installed simply run: ```sh cpan -i XML::Compile::Tester ``` ## Contributing When you want to contribute to this module, you do not need to provide a perfect patch... actually: it is nearly impossible to create a patch which I will merge without modification. Usually, I need to adapt the style of code and documentation to my own strict rules. When you submit an extension, please contribute a set with 1. code 2. code documentation 3. regression tests in t/ **Please note:** When you contribute in any way, you agree to transfer the copyrights to Mark Overmeer (you will get the honors in the code and/or ChangeLog). You also automatically agree that your contribution is released under the same license as this project: licensed as perl itself. ## Copyright and License This project is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See XML-Compile-Tester-0.91/MANIFEST0000644000175000001440000000044213275155417016616 0ustar00markovusers00000000000000ChangeLog MANIFEST Makefile.PL README README.md lib/XML/Compile/Tester.pm lib/XML/Compile/Tester.pod t/01use.t xt/99pod.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) XML-Compile-Tester-0.91/ChangeLog0000644000175000001440000000235213275155416017240 0ustar00markovusers00000000000000 === version history of XML::Compile::Tester Unless noted otherwise, these changes where initiated and applied by Mark Overmeer. version 0.91: Fri May 11 01:51:33 CEST 2018 Improvements: - change documentation style. - convert to GIT and GitHub version 0.90: Thu Aug 16 00:06:24 CEST 2012 Improvements: - add templ_tree() version 0.06: Tue Jun 15 14:49:28 CEST 2010 Fixes: - templ_xml should default include_namespaces to version 0.05: Wed Feb 11 11:07:24 CET 2009 Fixes: - do not use /bin/pwd in t/99pod.t - use 'use_default_namespace' i.s.o 'use_default_prefix' in writer. - do not complain if default_namespace is not set. Improvements: - removed superfluous '$' before 'templ*' in SYNOPSIS version 0.04: Wed Oct 1 22:12:59 CEST 2008 Fixes: - dependency with XML::Compile::Util. [cpantesters] version 0.03: Wed Oct 1 09:50:53 CEST 2008 Changes: - create_reader --> reader_create, create_writer --> writer_create Improvements: - much more documentation. version 0.02: Tue Apr 29 19:01:14 CEST 2008 Improvements: - does not depend on XML::Compile. - Add ChangeLog file to package. version 0.01: Mon Apr 21 17:09:08 CEST 2008 - initial implementation, derived from XML::Compile file t/TestTools.pm XML-Compile-Tester-0.91/t/0000755000175000001440000000000013275155417015730 5ustar00markovusers00000000000000XML-Compile-Tester-0.91/t/01use.t0000644000175000001440000000017313275155366017056 0ustar00markovusers00000000000000#!/usr/bin/perl use warnings; use strict; use lib 'lib'; use Test::More tests => 1; require_ok('XML::Compile::Tester'); XML-Compile-Tester-0.91/xt/0000755000175000001440000000000013275155417016120 5ustar00markovusers00000000000000XML-Compile-Tester-0.91/xt/99pod.t0000644000175000001440000000041213275155366017251 0ustar00markovusers00000000000000#!/usr/bin/perl use warnings; use strict; use Test::More; BEGIN { eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; plan skip_all => "devel home uses OODoc" if $ENV{MARKOV_DEVEL}; } all_pod_files_ok(); XML-Compile-Tester-0.91/lib/0000755000175000001440000000000013275155417016233 5ustar00markovusers00000000000000XML-Compile-Tester-0.91/lib/XML/0000755000175000001440000000000013275155417016673 5ustar00markovusers00000000000000XML-Compile-Tester-0.91/lib/XML/Compile/0000755000175000001440000000000013275155417020263 5ustar00markovusers00000000000000XML-Compile-Tester-0.91/lib/XML/Compile/Tester.pm0000644000175000001440000001104013275155416022062 0ustar00markovusers00000000000000# Copyrights 2008-2018 by [Mark Overmeer ]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.02. # This code is part of distribution XML-Compile-Tester. Meta-POD processed # with OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package XML::Compile::Tester; use vars '$VERSION'; $VERSION = '0.91'; use base 'Exporter'; use warnings; use strict; our @EXPORT = qw/ set_compile_defaults set_default_namespace reader_create create_reader writer_create create_writer writer_test reader_error writer_error templ_xml templ_perl templ_tree compare_xml /; use Test::More; use Data::Dumper; use Log::Report qw/try/; my $default_namespace; my @compile_defaults; # not using pack_type, which avoids a recursive dependency to XML::Compile sub _reltype_to_abs($) { defined $default_namespace && substr($_[0], 0,1) eq '{' ? "{$default_namespace}$_[0]" : $_[0] } sub reader_create($$$@) { my ($schema, $test, $reltype) = splice @_, 0, 3; my $type = _reltype_to_abs $reltype; my $read_t = $schema->compile ( READER => $type , check_values => 1 , include_namespaces => 0 , @compile_defaults , @_ ); isa_ok($read_t, 'CODE', "reader element $test"); $read_t; } *create_reader = \&reader_create; # name change in 0.03 sub reader_error($$$) { my ($schema, $reltype, $xml) = @_; my $r = reader_create $schema, "check read error $reltype", $reltype; defined $r or return; my $tree = try { $r->($xml) }; my $error = ref $@ && $@->exceptions ? join("\n", map {$_->message} $@->exceptions) : ''; undef $tree if $error; # there is output if only warnings are produced ok(!defined $tree, "no return for $reltype"); warn "RETURNED TREE=",Dumper $tree if defined $tree; ok(length $error, "ER=$error"); $error; } sub writer_create($$$@) { my ($schema, $test, $reltype) = splice @_, 0, 3; my $type = _reltype_to_abs $reltype; my $write_t = $schema->compile ( WRITER => $type , check_values => 1 , include_namespaces => 0 , use_default_namespace => 1 , @compile_defaults , @_ ); isa_ok($write_t, 'CODE', "writer element $test"); $write_t; } *create_writer = \&writer_create; # name change in 0.03 sub writer_test($$;$) { my ($writer, $data, $doc) = @_; $doc ||= XML::LibXML->createDocument('1.0', 'UTF-8'); isa_ok($doc, 'XML::LibXML::Document'); my $tree = $writer->($doc, $data); ok(defined $tree); defined $tree or return; isa_ok($tree, 'XML::LibXML::Node'); $tree; } sub writer_error($$$) { my ($schema, $reltype, $data) = @_; my $write = writer_create $schema, "writer for $reltype", $reltype; my $node; try { my $doc = XML::LibXML->createDocument('1.0', 'UTF-8'); isa_ok($doc, 'XML::LibXML::Document'); $node = $write->($doc, $data); }; my $error = ref $@ && $@->exceptions ? join("\n", map $_->message, $@->exceptions) : ''; undef $node if $error; # there is output if only warnings are produced # my $error = $@ ? $@->wasFatal->message : ''; ok(!defined $node, "no return for $reltype expected"); warn "RETURNED =", $node->toString if ref $node; ok(length $error, "EW=$error"); $error; } #-------------- sub templ_xml($$@) { my ($schema, $test, @opts) = @_; my $abs = _reltype_to_abs $test; $schema->template ( XML => $abs , include_namespaces => 1 , @opts ) . "\n"; } sub templ_perl($$@) { my ($schema, $test, @opts) = @_; my $abs = _reltype_to_abs $test; $schema->template ( PERL => $abs , include_namespaces => 0 , @opts ); } sub templ_tree($$@) { my ($schema, $test, @opts) = @_; my $abs = _reltype_to_abs($test); $schema->template ( TREE => $abs , @opts ); } sub set_compile_defaults(@) { @compile_defaults = @_ } sub set_default_namespace($) { $default_namespace = shift } sub compare_xml($$;$) { my ($tree, $expect, $comment) = @_; my $dump = ref $tree ? $tree->toString : $tree; for($dump, $expect) { defined $_ or next; s/\>\s+/>/gs; s/\s+\\s+\ 0, @other_opts); set_compile_defaults(); # reset # set default namespace, such that $type only needs to use local my $ns = 'some-schemas-targetNamespace'; my $type = pack_type($ns, 'localName'); # X::C::Util set_default_namespace($ns); my $type = 'localName'; # 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); =head1 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. =head1 FUNCTIONS =head2 Reader checks =over 4 =item B($schema, $comment, $type, %options) Create a reader for $type. One test is created, reporting success or failure of the creation. Of course, XML::Compile::Schema subroutine compile is being called, with some options. By default, C is true, and C is false. These values can be overruled using L, and with the %options parameter list. example: reader_create my $type = pack_type('namespace', 'localName'); my $reader = reader_create($schema, 'my test', $type , check_occurs => 0, @other_options); my $data = $reader->($xml); is_deeply($data, $expected, 'my test'); # Test::More cmp_deeply($data, $expected, 'my test'); # Test::Deep # alternative for $type: set_default_namespace('namespace'); my $reader = reader_create($schema, 'my test', 'localName' , check_occurs => 0, @other_options); =item B($schema, $type, $xml) Parsing the $xml to interpret the $type should return an error. The error text is returned. example: reader_error my $error = reader_error($schema, $type, <<_XML); ... _XML is($error, 'error text', 'my test'); like($error, qr/error pattern/, 'my test'); =back =head2 Writer checks =over 4 =item B($schema, $comment, $type, %options) Create a writer for $type. One test (in the Test::More sense) is created, reporting success or failure of the creation. Of course, XML::Compile::Schema subroutine compile is being called, with some options. By default, C and C are true, and C is false. These values can be overruled using L, and with the %options parameter list. example: writer_create set_default_namespace('namespace'); my $writer = writer_create($schema, 'my test', 'test1'); my $doc = XML::LibXML::Document->new('1.0', 'UTF-8'); my $xml = $writer->($doc, $data); compare_xml($xml, <<_EXPECTED, 'my test'); ... _EXPECTED # implicit creation of $doc my $xml = writer_test($writer, $data); =item B($schema, $type, $data) Translating the Perl $data into the XML type should return a validation error, which is returned. example: writer_error my $error = writer_error($schema, $type, $data); is($error, 'error text', 'my test'); like($error, qr/error pattern/, 'my test'); =item B( $writer, $data, [$doc] ) Run the test with a compiled $writer, which was created with L. When no $doc (XML::LibXML::Document object) was specified, then one will be created for you. =back =head2 Check templates =over 4 =item B($schema, $type, %options) =item B($schema, $type, %options) Create an example template for $type, as XML message. The %options are passed to XML::Compile::Schema subroutine template. example: templ_xml my $out = templ_xml($schema, $type, show => 'ALL'); is($out, $expected); =back =head2 Helpers =over 4 =item B( $created, $expected, [$comment] ) Compare the $created XML (either a string or an XML::LibXML::Element) with the $expected string. Both sources are stripped from layout before comparing. In a future release, this algorithm will get improved to compare the parsed XML node trees, not the strings. example: compare_xml compare_xml($xml, <<_XML, 'my test'); ... _XML =item B(%options) Each call to create a reader or writer (also indirectly) with XML::Compile::Schema subroutine compile will get these %options passed, on top (and overruling) the usual settings. example: # defaults for XML::Compile::Schema::compile() set_compile_defaults(include_namespaces => 1, validate => 0 , sloppy_intergers => 1, sloppy_floats => 1); set_compile_defaults(); # reset =item B($testns) Defined which namespace to use when a relative (only localName) type is provided. By default, this is C (an error when used) =back =head1 SEE ALSO This module is part of XML-Compile-Tester distribution version 0.91, built on May 11, 2018. Website: F =head1 LICENSE Copyrights 2008-2018 by [Mark Overmeer ]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F XML-Compile-Tester-0.91/README0000644000175000001440000000150413275155366016350 0ustar00markovusers00000000000000=== README for XML-Compile-Tester version 0.91 = Generated on Fri May 11 01:51:18 2018 by OODoc 2.02 There are various ways to install this module: (1) if you have a command-line, you can do: perl -MCPAN -e 'install ' (2) if you use Windows, have a look at http://ppm.activestate.com/ (3) if you have downloaded this module manually (as root/administrator) gzip -d XML-Compile-Tester-0.91.tar.gz tar -xf XML-Compile-Tester-0.91.tar cd XML-Compile-Tester-0.91 perl Makefile.PL make # optional make test # optional make install For usage, see the included manual-pages or http://search.cpan.org/dist/XML-Compile-Tester-0.91/ Please report problems to http://rt.cpan.org/Dist/Display.html?Queue=XML-Compile-Tester XML-Compile-Tester-0.91/Makefile.PL0000644000175000001440000000223213275155366017441 0ustar00markovusers00000000000000use ExtUtils::MakeMaker; use 5.008; WriteMakefile ( NAME => 'XML::Compile::Tester' , VERSION => '0.91' , PREREQ_PM => { Log::Report => 0.17 , Test::More => 0.54 , Test::Deep => 0.095 } , AUTHOR => 'Mark Overmeer ' , ABSTRACT => 'support XML::Compile related regression testing' , LICENSE => 'perl_5' , META_MERGE => { 'meta-spec' => { version => 2 } , resources => { repository => { type => 'git' , url => 'https://github.com/markov2/perl5-XML-Compile-Tester.git' , web => 'https://github.com/markov2/perl5-XML-Compile-Tester' } , homepage => 'http://perl.overmeer.net/CPAN/' , license => [ 'http://dev.perl.org/licenses/' ] } } ); ### used by oodist during production of distribution sub MY::postamble { <<'__POSTAMBLE' } # for DIST RAWDIR = ../public_html/xml-compile-tester/raw DISTDIR = ../public_html/xml-compile-tester/source SKIP_LINKS = XML::LibXML # for POD FIRST_YEAR = 2008 EMAIL = markov@cpan.org WEBSITE = http://perl.overmeer.net/CPAN/ __POSTAMBLE XML-Compile-Tester-0.91/META.yml0000644000175000001440000000142713275155417016742 0ustar00markovusers00000000000000--- abstract: 'support XML::Compile related regression testing' author: - 'Mark Overmeer ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: XML-Compile-Tester no_index: directory: - t - inc requires: Log::Report: '0.17' Test::Deep: '0.095' Test::More: '0.54' resources: homepage: http://perl.overmeer.net/CPAN/ license: http://dev.perl.org/licenses/ repository: https://github.com/markov2/perl5-XML-Compile-Tester.git version: '0.91' x_serialization_backend: 'CPAN::Meta::YAML version 0.011' XML-Compile-Tester-0.91/META.json0000644000175000001440000000254313275155417017112 0ustar00markovusers00000000000000{ "abstract" : "support XML::Compile related regression testing", "author" : [ "Mark Overmeer " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "XML-Compile-Tester", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Log::Report" : "0.17", "Test::Deep" : "0.095", "Test::More" : "0.54" } } }, "release_status" : "stable", "resources" : { "homepage" : "http://perl.overmeer.net/CPAN/", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "https://github.com/markov2/perl5-XML-Compile-Tester.git", "web" : "https://github.com/markov2/perl5-XML-Compile-Tester" } }, "version" : "0.91", "x_serialization_backend" : "JSON::PP version 2.94" }