Imported Upstream version 2.21 upstream/2.21
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 25 Jul 2022 01:33:30 +0000 (10:33 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 25 Jul 2022 01:33:30 +0000 (10:33 +0900)
20 files changed:
Changes
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
dist.ini
lib/XML/Simple.pm
lib/XML/Simple/FAQ.pod
t/1_XMLin.t
t/2_XMLout.t
t/3_Storable.t
t/4_MemShare.t
t/5_MemCopy.t
t/7_SaxStuff.t
t/8_Namespaces.t
t/A_XMLParser.t
t/B_Hooks.t
t/release-pod-syntax.t

diff --git a/Changes b/Changes
index 82f4ffed43be9633beec0dad2c24855f3dd1462b..bdb8db5dfd9b63784c932055c5603251d181c75d 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,20 @@
 Revision history for XML-Simple
 
+2.21      2015-12-04 16:33:49+13:00 Pacific/Auckland
+  - Improved diagnostics - xml_in() will now catch parse exceptions and add
+    caller information via Carp::croak
+  - Switch to use lexical warnings (suppress with either 'no warnings;' or
+    'no warnings "XML::Simple";', rather than $^W = 0)
+  - POD fixes (from David Steinbrunner)
+  - Regex escaping fixes for Perl 5.22+ (from Kent Fredric)
+  - Add workaround for test failures on RHEL/CentOS 6.5 (RT#102115 from
+    Chris Drake, workaround from Tim Bunce)
+  - Remove some 'eval' calls from test suite which could mask root cause of
+    test failures
+  - Make each test script use unique filenames to allow tests to be run in
+    parallel (RT#101362 from Karen Etheridge & Kent Fredric)
+  - POD update: mention XML::Twig in 'STATUS' section (RT#79228 from Matt Trout)
+
 2.20      2012-06-20 22:00:13 Pacific/Auckland
   - Suppress warning from empty CDATA section (RT#58359 from Juan Antonio
     Navarro PĂ©rez)
diff --git a/LICENSE b/LICENSE
index 612805d643a9ebde43dd55fcb1907b89e334ff8b..afb727a9535ff6ce778ee83b92c6ebaea6ecaf5f 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -18,15 +18,16 @@ This is free software, licensed under:
 
   The GNU General Public License, Version 1, February 1989
 
-                   GNU GENERAL PUBLIC LICENSE
-                    Version 1, February 1989
+                    GNU GENERAL PUBLIC LICENSE
+                     Version 1, February 1989
 
  Copyright (C) 1989 Free Software Foundation, Inc.
-                59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
+ 51 Franklin St, Suite 500, Boston, MA  02110-1335  USA
+
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
-                           Preamble
+                            Preamble
 
   The license agreements of most software companies try to keep users
 at the mercy of those companies.  By contrast, our General Public
@@ -67,7 +68,7 @@ authors' reputations.
   The precise terms and conditions for copying, distribution and
 modification follow.
 
-                   GNU GENERAL PUBLIC LICENSE
+                    GNU GENERAL PUBLIC LICENSE
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
   0. This License Agreement applies to any program or other work which
@@ -185,7 +186,7 @@ make exceptions for this.  Our decision will be guided by the two goals
 of preserving the free status of all derivatives of our free software and
 of promoting the sharing and reuse of software generally.
 
-                           NO WARRANTY
+                            NO WARRANTY
 
   9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
 FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
@@ -207,9 +208,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGES.
 
-                    END OF TERMS AND CONDITIONS
+                     END OF TERMS AND CONDITIONS
 
-       Appendix: How to Apply These Terms to Your New Programs
+        Appendix: How to Apply These Terms to Your New Programs
 
   If you develop a new program, and you want it to be of the greatest
 possible use to humanity, the best way to achieve this is to make it
@@ -235,8 +236,9 @@ the exclusion of warranty; and each file should have at least the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software Foundation,
-    Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
+
 
 Also add information on how to contact you by electronic and paper mail.
 
index 257820637d990097a0151d2db05e1d6c4ab800c1..1f34c03dc04c3aa8fa44b94793ac766b34efef9a 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,3 +1,4 @@
+# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.022.
 Changes
 LICENSE
 MANIFEST
index 41f6e925c8b8f023d0fda79d323cba389cd6f137..0c5473179aca42b9a1db09a11bf61b58775a2f23 100644 (file)
--- a/META.json
+++ b/META.json
@@ -1,10 +1,10 @@
 {
-   "abstract" : "Easily read/write XML (esp config files)",
+   "abstract" : "An API for simple XML files",
    "author" : [
       "Grant McLean <grantm@cpan.org>"
    ],
    "dynamic_config" : 0,
-   "generated_by" : "Dist::Zilla version 4.200004, CPAN::Meta::Converter version 2.101670",
+   "generated_by" : "Dist::Zilla version 5.022, CPAN::Meta::Converter version 2.142690",
    "license" : [
       "perl_5"
    ],
    "prereqs" : {
       "configure" : {
          "requires" : {
-            "ExtUtils::MakeMaker" : "6.31"
+            "ExtUtils::MakeMaker" : "0"
+         }
+      },
+      "develop" : {
+         "requires" : {
+            "Test::Pod" : "1.41"
          }
       },
       "runtime" : {
          "requires" : {
             "XML::NamespaceSupport" : "1.04",
             "XML::SAX" : "0.15",
-            "XML::SAX::Expat" : 0,
+            "XML::SAX::Expat" : "0",
             "perl" : "5.008"
          }
       },
@@ -38,9 +43,9 @@
       "repository" : {
          "type" : "git",
          "url" : "git://github.com/grantm/xml-simple.git",
-         "web" : "http://github.com/grantm/xml-simple"
+         "web" : "https://github.com/grantm/xml-simple"
       }
    },
-   "version" : "2.20"
+   "version" : "2.21"
 }
 
index 79c77b161deed5a091ef27dbb77b9fb8323d3c4f..9092f202efd71cd851d4f85477a90950017bb271 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,13 +1,13 @@
 ---
-abstract: 'Easily read/write XML (esp config files)'
+abstract: 'An API for simple XML files'
 author:
   - 'Grant McLean <grantm@cpan.org>'
 build_requires:
   Test::More: 0.88
 configure_requires:
-  ExtUtils::MakeMaker: 6.31
+  ExtUtils::MakeMaker: 0
 dynamic_config: 0
-generated_by: 'Dist::Zilla version 4.200004, CPAN::Meta::Converter version 2.101670'
+generated_by: 'Dist::Zilla version 5.022, CPAN::Meta::Converter version 2.142690'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -20,4 +20,4 @@ requires:
   perl: 5.008
 resources:
   repository: git://github.com/grantm/xml-simple.git
-version: 2.20
+version: 2.21
index 94e41a581056d749cb44d77242737dba775dc34e..4b40df7571882786cc3174d8dcc0db37535dedb8 100644 (file)
@@ -1,49 +1,53 @@
 
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.022.
 use strict;
 use warnings;
 
-BEGIN { require 5.008; }
+use 5.008;
 
-use ExtUtils::MakeMaker 6.31;
+use ExtUtils::MakeMaker;
 
 
 
 my %WriteMakefileArgs = (
-  'ABSTRACT' => 'Easily read/write XML (esp config files)',
-  'AUTHOR' => 'Grant McLean <grantm@cpan.org>',
-  'BUILD_REQUIRES' => {
-    'Test::More' => '0.88'
+  "ABSTRACT" => "An API for simple XML files",
+  "AUTHOR" => "Grant McLean <grantm\@cpan.org>",
+  "CONFIGURE_REQUIRES" => {
+    "ExtUtils::MakeMaker" => 0
   },
-  'CONFIGURE_REQUIRES' => {
-    'ExtUtils::MakeMaker' => '6.31'
+  "DISTNAME" => "XML-Simple",
+  "EXE_FILES" => [],
+  "LICENSE" => "perl",
+  "MIN_PERL_VERSION" => "5.008",
+  "NAME" => "XML::Simple",
+  "PREREQ_PM" => {
+    "XML::NamespaceSupport" => "1.04",
+    "XML::SAX" => "0.15",
+    "XML::SAX::Expat" => 0
   },
-  'DISTNAME' => 'XML-Simple',
-  'EXE_FILES' => [],
-  'LICENSE' => 'perl',
-  'NAME' => 'XML::Simple',
-  'PREREQ_PM' => {
-    'XML::NamespaceSupport' => '1.04',
-    'XML::SAX' => '0.15',
-    'XML::SAX::Expat' => '0'
+  "TEST_REQUIRES" => {
+    "Test::More" => "0.88"
   },
-  'VERSION' => '2.20',
-  'test' => {
-    'TESTS' => 't/*.t'
+  "VERSION" => "2.21",
+  "test" => {
+    "TESTS" => "t/*.t"
   }
 );
 
 
-unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) {
-  my $br = delete $WriteMakefileArgs{BUILD_REQUIRES};
-  my $pp = $WriteMakefileArgs{PREREQ_PM};
-  for my $mod ( keys %$br ) {
-    if ( exists $pp->{$mod} ) {
-      $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod};
-    }
-    else {
-      $pp->{$mod} = $br->{$mod};
-    }
-  }
+my %FallbackPrereqs = (
+  "ExtUtils::MakeMaker" => 0,
+  "Test::More" => "0.88",
+  "XML::NamespaceSupport" => "1.04",
+  "XML::SAX" => "0.15",
+  "XML::SAX::Expat" => 0
+);
+
+
+unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
+  delete $WriteMakefileArgs{TEST_REQUIRES};
+  delete $WriteMakefileArgs{BUILD_REQUIRES};
+  $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
 }
 
 delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
diff --git a/README b/README
index 2a0a8e8b1cc24248e071a1abe89a761d138ed4a0..07d2eb8099c057fae27eee5b17acdb77fb283406 100644 (file)
--- a/README
+++ b/README
@@ -1,9 +1,9 @@
 
 
 This archive contains the distribution XML-Simple,
-version 2.20:
+version 2.21:
 
-  Easily read/write XML (esp config files)
+  An API for simple XML files
 
 This software is copyright (c) 2012 by Grant McLean.
 
@@ -11,3 +11,5 @@ This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.
 
 
+This README file was generated by Dist::Zilla::Plugin::Readme v5.022.
+
index 7d474bc70d2a27e28d90603a2d9a89637a56b491..771bc6b21ebdf06ae7e95c0162f3156442ecb904 100644 (file)
--- a/dist.ini
+++ b/dist.ini
@@ -1,6 +1,6 @@
 name             = XML-Simple
 author           = Grant McLean <grantm@cpan.org>
-version          = 2.20
+version          = 2.21
 license          = Perl_5
 copyright_holder = Grant McLean
 copyright_year   = 2012
index 0686c1097b6ffc34dd7db62eb33db56feb1e7e2f..e585f77eab1cb6e9b831778acd041d9d78386f0d 100644 (file)
@@ -1,14 +1,14 @@
 package XML::Simple;
-BEGIN {
-  $XML::Simple::VERSION = '2.20';
-}
-
+$XML::Simple::VERSION = '2.21';
 =head1 NAME
 
-XML::Simple - Easily read/write XML (esp config files)
+XML::Simple - An API for simple XML files
 
 =head1 SYNOPSIS
 
+You really don't want to use this module in new code.  If you ignore this
+warning and use it anyway, the C<qw(:strict)> mode will save you a little pain.
+
     use XML::Simple qw(:strict);
 
     my $ref = XMLin([<xml file or string>] [, <options>]);
@@ -38,6 +38,8 @@ not to imply items should be supplied in arrayrefs.
 # Load essentials here, other modules loaded on demand later
 
 use strict;
+use warnings;
+use warnings::register;
 use Carp;
 require Exporter;
 
@@ -326,7 +328,10 @@ sub default_config_file {
 sub build_simple_tree {
   my $self = shift;
 
-  my $tree = $self->build_tree(@_);
+  my $tree = eval {
+    $self->build_tree(@_);
+  };
+  Carp::croak("$@XML::Simple called") if $@;
 
   return $self->{opt}->{keeproot}
          ? $self->collapse({}, @$tree)
@@ -787,7 +792,7 @@ sub handle_options  {
   }
 
   if(exists($opt->{parseropts})) {
-    if($^W) {
+    if(warnings::enabled()) {
       carp "Warning: " .
            "'ParserOpts' is deprecated, contact the author if you need it";
     }
@@ -1010,7 +1015,7 @@ sub collapse {
 
   if(my $var = $self->{_var_values}) {
     while(my($key, $val) = each(%$attr)) {
-      $val =~ s{\$\{([\w.]+)\}}{ $self->get_var($1) }ge;
+      $val =~ s^\$\{([\w.]+)\}^ $self->get_var($1) ^ge;
       $attr->{$key} = $val;
     }
   }
@@ -1047,7 +1052,7 @@ sub collapse {
       # do variable substitutions
 
       if(my $var = $self->{_var_values}) {
-        $val =~ s{\$\{(\w+)\}}{ $self->get_var($1) }ge;
+        $val =~ s^\$\{(\w+)\}^ $self->get_var($1) ^ge;
       }
 
 
@@ -1321,15 +1326,15 @@ sub array_to_hash {
 # 3. ignores message and returns silently if neither strict mode nor warnings
 #    are enabled
 #
-# Option 2 looks at the global warnings variable $^W - which is not really
-# appropriate in the modern world of lexical warnings - TODO: Fix
 
 sub die_or_warn {
   my $self = shift;
   my $msg  = shift;
 
   croak $msg if($self->{opt}->{strictmode});
-  carp "Warning: $msg" if($^W);
+  if(warnings::enabled()) {
+    carp "Warning: $msg";
+  }
 }
 
 
@@ -1354,7 +1359,7 @@ sub new_hashref {
 #
 # Arguments expected are:
 # - an XML::Simple object
-# - a hasref
+# - a hashref
 # the hashref is a former array, turned into a hash by array_to_hash because
 # of the presence of key attributes
 # at this point collapse_content avoids over-complicated structures like
@@ -1547,7 +1552,7 @@ sub value_to_xml {
           unless(exists($self->{opt}->{suppressempty})
              and !defined($self->{opt}->{suppressempty})
           ) {
-            carp 'Use of uninitialized value' if($^W);
+            carp 'Use of uninitialized value' if warnings::enabled();
           }
           if($key eq $self->{opt}->{contentkey}) {
             $text_content = '';
@@ -1890,10 +1895,12 @@ __END__
 
 The use of this module in new code is discouraged.  Other modules are available
 which provide more straightforward and consistent interfaces.  In particular,
-L<XML::LibXML> is highly recommended.
+L<XML::LibXML> is highly recommended and L<XML::Twig> is an excellent
+alternative.
 
-The major problems with this module are the large number of options and the
-arbitrary ways in which these options interact - often with unexpected results.
+The major problems with this module are the large number of options (some of
+which have unfortunate defaults) and the arbitrary ways in which these options
+interact - often producing unexpected results.
 
 Patches with bug fixes and documentation fixes are welcome, but new features
 are unlikely to be added.
@@ -1995,7 +2002,7 @@ case, you might want to read L<"WHERE TO FROM HERE?">.
 
 The XML::Simple module provides a simple API layer on top of an underlying XML
 parsing module (either XML::Parser or one of the SAX2 parser modules).  Two
-functions are exported: C<XMLin()> and C<XMLout()>.  Note: you can explicity
+functions are exported: C<XMLin()> and C<XMLout()>.  Note: you can explicitly
 request the lower case versions of the function names: C<xml_in()> and
 C<xml_out()>.
 
@@ -2470,7 +2477,7 @@ rolled up into a scalar rather than an array and therefore will not be folded
 
 =head2 KeyAttr => { list } I<# in+out - important>
 
-This alternative (and preferred) method of specifiying the key attributes
+This alternative (and preferred) method of specifying the key attributes
 allows more fine grained control over which elements are folded and on which
 attributes.  For example the option 'KeyAttr => { package => 'id' } will cause
 any package elements to be folded on the 'id' attribute.  No other elements
@@ -2479,7 +2486,8 @@ which have an 'id' attribute will be folded at all.
 Note: C<XMLin()> will generate a warning (or a fatal error in L<"STRICT MODE">)
 if this syntax is used and an element which does not have the specified key
 attribute is encountered (eg: a 'package' element without an 'id' attribute, to
-use the example above).  Warnings will only be generated if B<-w> is in force.
+use the example above).  Warnings can be suppressed with the lexical
+C<no warnings;> pragma or C<no warnings 'XML::Simple';>.
 
 Two further variations are made possible by prefixing a '+' or a '-' character
 to the attribute name:
@@ -2944,8 +2952,8 @@ KeyAttr hash.
 
 Data error - KeyAttr is set to say { part => 'partnum' } but the XML contains
 one or more E<lt>partE<gt> elements without a 'partnum' attribute (or nested
-element).  Note: if strict mode is not set but -w is, this condition triggers a
-warning.
+element).  Note: if strict mode is not set but C<use warnings;> is in force,
+this condition triggers a warning.
 
 =item *
 
@@ -3233,7 +3241,7 @@ The <anon> tag can be used to form anonymous arrays:
                 ]
     }
 
-Anonymous arrays can be nested to arbirtrary levels and as a special case, if
+Anonymous arrays can be nested to arbitrary levels and as a special case, if
 the surrounding tags for an XML document contain only an anonymous array the
 arrayref will be returned directly rather than the usual hashref:
 
@@ -3299,7 +3307,7 @@ You don't need help converting between different encodings
 =back
 
 In a serious XML project, you'll probably outgrow these assumptions fairly
-quickly.  This section of the document used to offer some advice on chosing a
+quickly.  This section of the document used to offer some advice on choosing a
 more powerful option.  That advice has now grown into the 'Perl-XML FAQ'
 document which you can find at: L<http://perl-xml.sourceforge.net/faq/>
 
@@ -3307,7 +3315,7 @@ The advice in the FAQ boils down to a quick explanation of tree versus
 event based parsers and then recommends:
 
 For event based parsing, use SAX (do not set out to write any new code for
-XML::Parser's handler API - it is obselete).
+XML::Parser's handler API - it is obsolete).
 
 For tree-based parsing, you could choose between the 'Perlish' approach of
 L<XML::Twig> and more standards based DOM implementations - preferably one with
index 4c5c90444ad1283ba65b361ea5a4d467fb5ea1fc..2039b354563b3da51232ac28e45b9eb3cfc77790 100644 (file)
@@ -1,4 +1,5 @@
 package XML::Simple::FAQ;
+$XML::Simple::FAQ::VERSION = '2.21';
 1;
 
 __END__
@@ -170,7 +171,7 @@ directory under your Perl installation (typically C:\Perl).
 
 Is the directory where you've unpacked XML::Simple mounted from a file server
 using NFS, SMB or some other network file sharing?  If so, that may cause
-errors in the the following test scripts:
+errors in the following test scripts:
 
   3_Storable.t
   4_MemShare.t
@@ -200,7 +201,7 @@ used.
 
 Is one of the three test scripts (above) failing but you're not running on
 a network filesystem?  Are you running Win32?  If so, you may be seeing a bug
-in Win32 where writes to a file do not affect its modfication timestamp.
+in Win32 where writes to a file do not affect its modification timestamp.
 
 If none of these scenarios match your situation, please confirm you're
 running the latest version of XML::Simple and then email the output of
index eb38280ac3baa81c5b14a5465f461e382519b9f0..84935cdcf3b65b94230b6491e7db8f1d5da95be3 100644 (file)
@@ -5,10 +5,7 @@ use Test::More;
 use IO::File;
 use File::Spec;
 
-
-# The suppress-able warnings still check the global flag
-
-$^W = 1;
+use XML::Simple;
 
 # Initialise filenames and check they're there
 
@@ -18,13 +15,11 @@ unless(-e $XMLFile) {
   plan skip_all => 'Test data missing';
 }
 
-plan tests => 131;
+plan tests => 132;
 
 
 my $last_warning = '';
 
-$@ = '';
-eval "use XML::Simple;";
 is($@, '', 'Module compiled OK');
 my $version = 'unknown';
 if(open my $chg, '<Changes') {
@@ -391,13 +386,14 @@ $target = {
   );
 
   $last_warning = '';
-  local($^W) = 0;
-  $opt = XMLin($xml, keyattr => { item => 'name' }, @cont_key);
-  is_deeply($opt, $target, "did not fold on specific key with non-scalar value");
-  is($last_warning, '', 'no warning issued (as expected)');
+  {
+    no warnings 'XML::Simple';
+    $opt = XMLin($xml, keyattr => { item => 'name' }, @cont_key);
+    is_deeply($opt, $target, "did not fold on specific key with non-scalar value");
+    is($last_warning, '', 'no warning issued (as expected)');
+  }
 
   $last_warning = '';
-  $^W = 1;
   my $xitems = q(<opt>
     <item name="color">red</item>
     <item name="mass">heavy</item>
@@ -416,13 +412,14 @@ $target = {
     'expected warning issued');
 
   $last_warning = '';
-  $^W = 0;
-  $opt = XMLin($xitems, keyattr => { item => 'name' }, @cont_key);
-  is_deeply($opt, $items, "same again");
-  is($last_warning, '', 'but with no warning this time');
+  {
+    no warnings;
+    $opt = XMLin($xitems, keyattr => { item => 'name' }, @cont_key);
+    is_deeply($opt, $items, "same again");
+    is($last_warning, '', 'but with no warning this time');
+  }
 
   $last_warning = '';
-  $^W = 1;
   $xitems = q(<opt>
     <item name="color">red</item>
     <item name="mass">heavy</item>
@@ -448,10 +445,12 @@ $target = {
     'expected warning issued');
 
   $last_warning = '';
-  $^W = 0;
-  $opt = XMLin($xitems, keyattr => { item => 'name' }, @cont_key);
-  is_deeply($opt, $items, "same again");
-  is($last_warning, '', 'but with no warning this time');
+  {
+    no warnings;
+    $opt = XMLin($xitems, keyattr => { item => 'name' }, @cont_key);
+    is_deeply($opt, $items, "same again");
+    is($last_warning, '', 'but with no warning this time');
+  }
 }
 
 
@@ -485,7 +484,6 @@ is_deeply($opt, {
 
 # Try parsing a named external file
 
-$@ = '';
 $opt = eval{ XMLin($XMLFile); };
 is($@, '', "XMLin didn't choke on named external file");
 is_deeply($opt, {
@@ -495,7 +493,6 @@ is_deeply($opt, {
 
 # Try parsing default external file (scriptname.xml in script directory)
 
-$@ = '';
 $opt = eval { XMLin(); };
 is($@, '', "XMLin didn't choke on un-named (default) external file");
 is_deeply($opt, {
@@ -505,7 +502,6 @@ is_deeply($opt, {
 
 # Try parsing named file in a directory in the searchpath
 
-$@ = '';
 $opt = eval {
   XMLin('test2.xml', searchpath => [
     'dir1', 'dir2', File::Spec->catdir('t', 'subdir'), @cont_key
@@ -520,7 +516,6 @@ is_deeply($opt, {
 
 # Ensure we get expected result if file does not exist
 
-$@ = '';
 $opt = undef;
 $opt = eval {
   XMLin('bogusfile.xml', searchpath => 't' ); # should 'die'
@@ -531,7 +526,6 @@ like($@, qr/Could not find bogusfile.xml in/, 'with the expected message');
 
 # same again, but with no searchpath
 
-$@ = '';
 $opt = undef;
 $opt = eval { XMLin('bogusfile.xml'); };
 is($opt, undef, 'nonexistant file not found in current directory');
@@ -540,17 +534,16 @@ like($@, qr/File does not exist: bogusfile.xml/, 'with the expected message');
 
 # Confirm searchpath is ignored if filename includes directory component
 
-$@ = '';
 $opt = undef;
 $opt = eval {
   XMLin(File::Spec->catfile('subdir', 'test2.xml'), searchpath => 't' );
 };
 is($opt, undef, 'search path ignored when pathname supplied');
+like($@, qr/Could not find/, 'failed with expected message');
 
 
 # Try parsing from an IO::Handle
 
-$@ = '';
 my $fh = new IO::File;
 $XMLFile = File::Spec->catfile('t', '1_XMLin.xml');  # t/1_XMLin.xml
 eval {
@@ -564,7 +557,6 @@ is($opt->{location}, 't/1_XMLin.xml', 'and it parsed the right file');
 # Try parsing from STDIN
 
 close(STDIN);
-$@ = '';
 eval {
   open(STDIN, $XMLFile) || die "$!";
   $opt = XMLin('-');
@@ -1219,13 +1211,11 @@ is_deeply($opt, {
 
 # Confirm only a hash is acceptable to grouptags and variables
 
-$@ = '';
 $_ = eval { $opt = XMLin($xml, grouptags  => [ 'dir' ]); };
 ok(!defined($_), 'grouptags requires a hash');
 like($@, qr/Illegal value for 'GroupTags' option - expected a hashref/,
 'with correct error message');
 
-$@ = '';
 $_ = eval { $opt = XMLin($xml, variables  => [ 'dir' ]); };
 ok(!defined($_), 'variables requires a hash');
 like($@, qr/Illegal value for 'Variables' option - expected a hashref/,
@@ -1253,12 +1243,10 @@ is_deeply($opt, {
 
 # Test option error handling
 
-$@='';
 $_ = eval { XMLin('<x y="z" />', rootname => 'fred') }; # not valid for XMLin()
 is($_, undef, 'invalid options are trapped');
 like($@, qr/Unrecognised option:/, 'with correct error message');
 
-$@='';
 $_ = eval { XMLin('<x y="z" />', 'searchpath') };
 is($_, undef, 'invalid number of options are trapped');
 like($@, qr/Options must be name=>value pairs \(odd number supplied\)/,
index 5069c8dbae4f7fc1fe7226fbdccf6dcf1f17de65..edee6f78a6d0ff74acda144f432fdfd1c7540434 100644 (file)
@@ -3,6 +3,8 @@ use strict;
 use warnings;
 use Test::More;
 
+use FileHandle;   # Workaround for test failures on RHEL
+
 plan tests => 201;
 
 
@@ -517,7 +519,7 @@ unlink($TestFile);
 ok(!-e $TestFile, 'output file does not exist');
 
 $xml = XMLout($hashref1);
-eval { XMLout($hashref1, outputfile => $TestFile); };
+XMLout($hashref1, outputfile => $TestFile);
 ok(-e $TestFile, 'created xml output file');
 is(ReadFile($TestFile), $xml, 'Contents match expectations');
 unlink($TestFile);
@@ -526,11 +528,9 @@ unlink($TestFile);
 # Test output to an IO handle
 
 ok(!-e $TestFile);
-eval {
-  open my $fh, '>', $TestFile or die "$!";
-  XMLout($hashref1, outputfile => $fh);
-  $fh->close();
-};
+open my $fh, '>', $TestFile or die "$!";
+XMLout($hashref1, outputfile => $fh);
+$fh->close();
 ok(-e $TestFile, 'create XML output file via IO::File');
 is(ReadFile($TestFile), $xml, 'Contents match expectations');
 unlink($TestFile);
@@ -646,7 +646,6 @@ like($_, qr{^\s*<(\w+)\s*>\s*<nnn>\s*<nnn>\s*</\1\s*>\s*$}, 'document OK');
 # Check undefined values generate warnings
 
 {
-  local($^W) = 1;
   my $warn = '';
   local $SIG{__WARN__} = sub { $warn = $_[0] };
   $ref = { 'one' => 1, 'two' => undef };
@@ -656,10 +655,15 @@ like($_, qr{^\s*<(\w+)\s*>\s*<nnn>\s*<nnn>\s*</\1\s*>\s*$}, 'document OK');
   like($warn, qr/Use of uninitialized value/,
     'caught warning re uninitialised value');
   like($_, $expect, 'undef maps to any empty attribute by default');
+}
 
+{
   # unless warnings are disabled
-  $^W = 0;
-  $warn = '';
+  no warnings;
+  my $warn = '';
+  local $SIG{__WARN__} = sub { $warn = $_[0] };
+  my $expect = qr/^<\w+(\s+one="1"|\s+two=""){2}/;
+
   $_ = XMLout($ref);
   is($warn, '', 'no warning re uninitialised value if warnings off');
   like($_, $expect, 'undef still maps to any empty attribute');
@@ -754,18 +758,15 @@ like($_, qr{^\s*<opt\s+one="1">text</opt>\s*$}s, 'even with "-" prefix');
 # Confirm content key works with undef values (and no warnings)
 
 {
-  $^W = 1;
   my $warn = '';
   local $SIG{__WARN__} = sub { $warn = $_[0] };
-  $_ = eval {
-    $ref = {
-      column => [
-        { name => 'title',   content => 'A Title' },
-        { name => 'sponsor', content => undef },
-      ],
-    };
-    XMLout($ref, suppress_empty => undef, content_key => 'content');
+  $ref = {
+    column => [
+      { name => 'title',   content => 'A Title' },
+      { name => 'sponsor', content => undef },
+    ],
   };
+  $_ = XMLout($ref, suppress_empty => undef, content_key => 'content');
   ok(!$warn,  'no warnings with suppress_empty => undef');
   like($_, qr{^<(\w+)>
       \s*<column\s+name="title"\s*>A\sTitle</column>
index a98c6b473b739e238d384a696a7cc574ff1d6758..d688226d443ac0b96c5af6f0b8f474fc68241e47 100644 (file)
@@ -17,8 +17,8 @@ unless(UNIVERSAL::can(Storable => 'lock_nstore')) {
 # Initialise filenames and check they're there
 
 my $SrcFile   = File::Spec->catfile('t', 'desertnet.src');
-my $XMLFile   = File::Spec->catfile('t', 'desertnet.xml');
-my $CacheFile = File::Spec->catfile('t', 'desertnet.stor');
+my $XMLFile   = File::Spec->catfile('t', 'desertnet3.xml');
+my $CacheFile = File::Spec->catfile('t', 'desertnet3.stor');
 
 unless(-e $SrcFile) {
   plan skip_all => 'test data missing';
index 2259eec4e64958d3fbad15c32cc913a7f9264bc0..4360ed7386935b07da571c6c3e2e33524601f697 100644 (file)
@@ -8,7 +8,7 @@ use File::Spec;
 # Initialise filenames and check they're there
 
 my $SrcFile   = File::Spec->catfile('t', 'desertnet.src');
-my $XMLFile   = File::Spec->catfile('t', 'desertnet.xml');
+my $XMLFile   = File::Spec->catfile('t', 'desertnet4.xml');
 
 unless(-e $SrcFile) {
   plan skip_all => 'test data missing';
@@ -146,6 +146,7 @@ my $opt2 = XMLin($XMLFile, cache => 'memshare');
 
 is($opt2->{three}, 3, 'cache was modified');
 
+unlink($XMLFile);
 
 exit(0);
 
index 4601a85a8327f4bda734f5113c4628ce497aa603..3720468226380836d22159c44d5064471ee263a9 100644 (file)
@@ -13,7 +13,7 @@ unless($INC{'Storable.pm'}) {
 # Initialise filenames and check they're there
 
 my $SrcFile   = File::Spec->catfile('t', 'desertnet.src');
-my $XMLFile   = File::Spec->catfile('t', 'desertnet.xml');
+my $XMLFile   = File::Spec->catfile('t', 'desertnet5.xml');
 
 unless(-e $SrcFile) {
   plan skip_all => 'test data missing';
index 8f708325b342f36be2026393668e15a14f4ca665..bc05af9cd5cba702e8d3dc89c0c16f7dbd97c909 100644 (file)
@@ -20,7 +20,7 @@ use TagsToUpper;
 # Initialise filenames and check they're there
 
 my $SrcFile   = File::Spec->catfile('t', 'desertnet.src');
-my $XMLFile   = File::Spec->catfile('t', 'desertnet.xml');
+my $XMLFile   = File::Spec->catfile('t', 'desertnet7.xml');
 my $CacheFile = File::Spec->catfile('t', 'desertnet.stor');
 
 unless(-e $SrcFile) {
index 9c83f3d7f4ff8a60bbf6fcd87c46c3cebd9e8eb6..7775c5dda0e1573b93d0b02c95f0aa66e82351d2 100644 (file)
@@ -122,16 +122,16 @@ $opt = {
 };
 
 $xml = XMLout($opt);
-like($xml, qr{
+like($xml, qr[
   ^\s*<opt
   (\s+{http://www.w3.org/2000/xmlns/}perl="http://www.perl.com/"
   |\s+{http://www.perl.com/}attr="value"
   |\s+bare="Beer!"){3}
   \s*>
-  \s*<{http://www.perl.com/}element\s*>data</{http://www.perl.com/}element\s*>
+  \s*<\{http://www.perl.com/\}element\s*>data</\{http://www.perl.com/\}element\s*>
   \s*</opt>
   \s*$
-}sx, 'clarkian names not converted to qnames on output by default');
+]sx, 'clarkian names not converted to qnames on output by default');
 
 
 # Confirm nsexpand option works on output
index faa4ce3dabed52188c3611caedec632304ac0241..86905ddfd26ed9616a630f98ff33a8f9385554e9 100644 (file)
@@ -6,10 +6,6 @@ use IO::File;
 use File::Spec;
 
 
-# The suppress-able warnings still check the global flag
-
-$^W = 1;
-
 # Initialise filenames and check they're there
 
 my $XMLFile = File::Spec->catfile('t', 'test1.xml');  # t/test1.xml
@@ -41,8 +37,7 @@ $ENV{XML_SIMPLE_PREFERRED_PARSER} = 'XML::Parser';
 {
   local($SIG{__WARN__}) = \&warn_handler;
 
-  $@ = '';
-  $opt = eval { XMLin('<x y="z" />', nsexpand => 1) };
+  $opt = XMLin('<x y="z" />', nsexpand => 1);
 }
 
 isnt($last_warning, '', "Parsing caused warning (as expected)");
@@ -56,9 +51,8 @@ is_deeply($opt, {y => 'z'}, "Parsing was successful");
 {
   local($SIG{__WARN__}) = \&warn_handler;
 
-  $@ = '';
   $last_warning = '';
-  $opt = eval { XMLin('<x y="z" />', ParserOpts => [ ParseParamEnt => 1 ]) };
+  $opt = XMLin('<x y="z" />', ParserOpts => [ ParseParamEnt => 1 ]);
 }
 
 isnt($last_warning, '', "Using ParserOpts caused warning (as expected)");
@@ -70,12 +64,11 @@ is_deeply($opt, {y => 'z'}, "Parsing was successful");
 # Check it doesn't happen if warnings disabled
 
 {
+  no warnings;
   local($SIG{__WARN__}) = \&warn_handler;
 
-  $@ = '';
   $last_warning = '';
-  local($^W) = 0;
-  $opt = eval { XMLin('<x y="z" />', ParserOpts => [ ParseParamEnt => 1 ]) };
+  $opt = XMLin('<x y="z" />', ParserOpts => [ ParseParamEnt => 1 ]);
 }
 
 is($last_warning, '', "ParserOpts warning uppressed successfully");
@@ -85,7 +78,6 @@ is_deeply($opt, {y => 'z'}, "Parsing was successful");
 
 # Try parsing a string
 
-$@ = '';
 $opt = eval {
   XMLin(q(<opt name1="value1" name2="value2"></opt>));
 };
@@ -101,7 +93,6 @@ is_deeply($opt, $expected, 'matches expectations (attributes)');
 
 # Try parsing a named external file
 
-$@ = '';
 $opt = eval{ XMLin($XMLFile); };
 is($@, '', "XML::Parser didn't choke on named external file");
 is_deeply($opt, {
@@ -111,7 +102,6 @@ is_deeply($opt, {
 
 # Try parsing from an IO::Handle
 
-$@ = '';
 my $fh = new IO::File;
 $XMLFile = File::Spec->catfile('t', '1_XMLin.xml');  # t/1_XMLin.xml
 eval {
index 9b66c2d22058d67f638dd940f9890ce63807945d..729a29a5118193bd45cda67a9b544c8a6979a249 100644 (file)
@@ -12,7 +12,6 @@ SKIP: {
 
   skip "Tie::IxHash not installed", 3 if $@;
 
-  $@ = '';
   eval <<'EOF';
 
     package SimpleOrder;
index d46a95569460d78eacded2a41c8ead9ccbddce0c..cdd6a6cb24b9197cc51b799fc661b00887775290 100644 (file)
@@ -7,9 +7,8 @@ BEGIN {
   }
 }
 
+# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
 use Test::More;
-
-eval "use Test::Pod 1.41";
-plan skip_all => "Test::Pod 1.41 required for testing POD" if $@;
+use Test::Pod 1.41;
 
 all_pod_files_ok();