XML-Compile-Tester-0.91/ 0000755 0001750 0000144 00000000000 13275155417 015465 5 ustar 00markov users 0000000 0000000 XML-Compile-Tester-0.91/README.md 0000644 0001750 0000144 00000004134 13275155366 016751 0 ustar 00markov users 0000000 0000000 # 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/MANIFEST 0000644 0001750 0000144 00000000442 13275155417 016616 0 ustar 00markov users 0000000 0000000 ChangeLog
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/ChangeLog 0000644 0001750 0000144 00000002352 13275155416 017240 0 ustar 00markov users 0000000 0000000
=== 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/ 0000755 0001750 0000144 00000000000 13275155417 015730 5 ustar 00markov users 0000000 0000000 XML-Compile-Tester-0.91/t/01use.t 0000644 0001750 0000144 00000000173 13275155366 017056 0 ustar 00markov users 0000000 0000000 #!/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/ 0000755 0001750 0000144 00000000000 13275155417 016120 5 ustar 00markov users 0000000 0000000 XML-Compile-Tester-0.91/xt/99pod.t 0000644 0001750 0000144 00000000412 13275155366 017251 0 ustar 00markov users 0000000 0000000 #!/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/ 0000755 0001750 0000144 00000000000 13275155417 016233 5 ustar 00markov users 0000000 0000000 XML-Compile-Tester-0.91/lib/XML/ 0000755 0001750 0000144 00000000000 13275155417 016673 5 ustar 00markov users 0000000 0000000 XML-Compile-Tester-0.91/lib/XML/Compile/ 0000755 0001750 0000144 00000000000 13275155417 020263 5 ustar 00markov users 0000000 0000000 XML-Compile-Tester-0.91/lib/XML/Compile/Tester.pm 0000644 0001750 0000144 00000011040 13275155416 022062 0 ustar 00markov users 0000000 0000000 # 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+\>