Update of /cvsroot/perl-xml/xml-simple/t
In directory sc8-pr-cvs1:/tmp/cvs-serv2803/t
Modified Files:
0_Config.t 1_XMLin.t 3_Storable.t 4_MemShare.t 5_MemCopy.t
6_ObjIntf.t 7_SaxStuff.t 8_Namespaces.t 9_Strict.t
Log Message:
- enable warnings
Index: 0_Config.t
===================================================================
RCS file: /cvsroot/perl-xml/xml-simple/t/0_Config.t,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
Index: 1_XMLin.t
===================================================================
RCS file: /cvsroot/perl-xml/xml-simple/t/1_XMLin.t,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- 1_XMLin.t 16 Apr 2003 10:17:29 -0000 1.12
+++ 1_XMLin.t 18 May 2003 08:43:13 -0000 1.13
@@ -6,6 +6,8 @@
use IO::File;
use File::Spec;
+$^W = 1;
+
# Initialise filenames and check they're there
@@ -15,14 +17,16 @@
plan skip_all => 'Test data missing';
}
-plan tests => 95;
+plan tests => 98;
+my $last_warning = '';
+
$@ = '';
eval "use XML::Simple;";
is($@, '', 'Module compiled OK');
-unless($XML::Simple::VERSION eq '2.05') {
- diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 2.05)");
+unless($XML::Simple::VERSION eq '2.06') {
+ diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 2.06)");
}
@@ -352,11 +356,23 @@
]
};
+$last_warning = '';
$opt = XMLin($xml, @cont_key);
is_deeply($opt, $target, "did not fold on default key with non-scalar value");
+is($last_warning, '', 'no warning issued');
-$opt = XMLin($xml, keyattr => { item => 'name' }, @cont_key);
-is_deeply($opt, $target, "did not fold on specific key with non-scalar value");
+{
+ local($SIG{__WARN__}) = \&warn_handler;
+
+ $last_warning = '';
+ $opt = XMLin($xml, keyattr => { item => 'name' }, @cont_key);
+ is_deeply($opt, $target, "did not fold on specific key with non-scalar value");
+ isnt($last_warning, '', 'warning issued as expected');
+ like($last_warning,
+ qr{<item> element has non-scalar 'name' key attribute},
+ 'text in warning is correct'
+ );
+}
# Make sure that the root element name is preserved if we ask for it
@@ -1218,3 +1234,7 @@
exit(0);
+
+sub warn_handler {
+ $last_warning = $_[0];
+}
Index: 3_Storable.t
===================================================================
RCS file: /cvsroot/perl-xml/xml-simple/t/3_Storable.t,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- 3_Storable.t 10 Apr 2003 10:20:08 -0000 1.6
+++ 3_Storable.t 18 May 2003 08:43:13 -0000 1.7
@@ -5,6 +5,9 @@
use Test::More;
use File::Spec;
+$^W = 1;
+
+
eval { require Storable; };
unless($INC{'Storable.pm'}) {
plan skip_all => 'no Storable.pm';
Index: 4_MemShare.t
===================================================================
RCS file: /cvsroot/perl-xml/xml-simple/t/4_MemShare.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- 4_MemShare.t 16 Oct 2002 09:43:35 -0000 1.3
+++ 4_MemShare.t 18 May 2003 08:43:13 -0000 1.4
@@ -5,6 +5,9 @@
use Test::More;
use File::Spec;
+$^W = 1;
+
+
# Initialise filenames and check they're there
my $SrcFile = File::Spec->catfile('t', 'desertnet.src');
Index: 5_MemCopy.t
===================================================================
RCS file: /cvsroot/perl-xml/xml-simple/t/5_MemCopy.t,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- 5_MemCopy.t 16 Oct 2002 09:43:35 -0000 1.4
+++ 5_MemCopy.t 18 May 2003 08:43:13 -0000 1.5
@@ -5,6 +5,9 @@
use Test::More;
use File::Spec;
+$^W = 1;
+
+
eval { require Storable; };
unless($INC{'Storable.pm'}) {
plan skip_all => 'no Storable.pm';
Index: 6_ObjIntf.t
===================================================================
RCS file: /cvsroot/perl-xml/xml-simple/t/6_ObjIntf.t,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- 6_ObjIntf.t 10 Apr 2003 10:20:08 -0000 1.5
+++ 6_ObjIntf.t 18 May 2003 08:43:13 -0000 1.6
@@ -2,6 +2,9 @@
# vim: syntax=perl
use strict;
+
+$^W = 1;
+
use Test::More tests => 33;
##############################################################################
Index: 7_SaxStuff.t
===================================================================
RCS file: /cvsroot/perl-xml/xml-simple/t/7_SaxStuff.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- 7_SaxStuff.t 16 Oct 2002 09:43:35 -0000 1.2
+++ 7_SaxStuff.t 18 May 2003 08:43:13 -0000 1.3
@@ -6,6 +6,9 @@
use File::Spec;
use IO::File;
+$^W = 1;
+
+
BEGIN {
unshift @INC, File::Spec->catfile('t', 'lib');
Index: 8_Namespaces.t
===================================================================
RCS file: /cvsroot/perl-xml/xml-simple/t/8_Namespaces.t,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- 8_Namespaces.t 16 Oct 2002 09:43:35 -0000 1.4
+++ 8_Namespaces.t 18 May 2003 08:43:14 -0000 1.5
@@ -6,6 +6,9 @@
use File::Spec;
use IO::File;
+$^W = 1;
+
+
eval { require XML::SAX; };
if($@) {
plan skip_all => 'no XML::SAX';
Index: 9_Strict.t
===================================================================
RCS file: /cvsroot/perl-xml/xml-simple/t/9_Strict.t,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- 9_Strict.t 10 Apr 2003 10:20:10 -0000 1.4
+++ 9_Strict.t 18 May 2003 08:43:14 -0000 1.5
@@ -4,7 +4,9 @@
use strict;
use Test::More;
-plan tests => 37;
+$^W = 1;
+
+plan tests => 38;
##############################################################################
@@ -140,6 +142,7 @@
# Confirm that keyattr cannot be omitted
+$@ = '';
eval {
XMLout($ref, rootname => 'list');
};
@@ -149,6 +152,16 @@
'with the correct error message');
+# Confirm that forcearray can be omitted (only rqd on input)
+
+$@ = '';
+eval {
+ XMLout($ref, keyattr => {x => 'y'});
+};
+
+is($@, '', 'omitting forcearray was not a fatal error on output');
+
+
##############################################################################
# Now repeat all that using the OO syntax
##############################################################################
@@ -160,12 +173,12 @@
my $xs = XML::Simple->new(forcearray => 1, keyattr => {});
$@ = '';
-my $opt = eval {
+$opt = eval {
$xs->XMLin($xml);
};
is($@, '', '$xs->XMLin() did not fail');
-my $keys = join(' ', sort keys %$opt);
+$keys = join(' ', sort keys %$opt);
is($keys, 'name1 name2', 'and managed to produce the expected results');
|