From: Grant M. <gr...@us...> - 2002-10-17 07:29:50
|
Update of /cvsroot/perl-xml/xml-simple/t In directory usw-pr-cvs1:/tmp/cvs-serv26769/t Modified Files: 1_XMLin.t Added Files: 9_Strict.t Log Message: - added 'strict mode' and bumped version to 2.00 --- NEW FILE: 9_Strict.t --- # $Id: 9_Strict.t,v 1.1 2002/10/17 07:29:44 grantm Exp $ # vim: syntax=perl use strict; use Test::More; plan tests => 13; ############################################################################## # T E S T R O U T I N E S ############################################################################## eval "use XML::Simple qw(:strict);"; ok(!$@, 'XML::Simple loads ok with qw(:strict)'); # Check that the basic functionality still works my $xml = q(<opt name1="value1" name2="value2"></opt>); $@ = ''; my $opt = eval { XMLin($xml, forcearray => 1, keyattr => {}); }; is($@, '', 'XMLin() did not fail'); my $keys = join(' ', sort keys %$opt); is($keys, 'name1 name2', 'and managed to produce the expected results'); # Confirm that forcearray cannot be omitted eval { $opt = XMLin($xml, keyattr => {}); }; isnt($@, '', 'omitting forcearray was a fatal error'); like($@, qr/No value specified for 'forcearray'/, 'with the correct error message'); # Confirm that keyattr cannot be omitted eval { $opt = XMLin($xml, forcearray => []); }; isnt($@, '', 'omitting keyattr was a fatal error'); like($@, qr/No value specified for 'keyattr'/, 'with the correct error message'); # Confirm that element names from keyattr cannot be omitted from forcearray eval { $opt = XMLin($xml, keyattr => { part => 'partnum' }, forcearray => 0); }; isnt($@, '', 'omitting forcearray for elements in keyattr was a fatal error'); like($@, qr/<part> set in keyattr but not in forcearray/, 'with the correct error message'); eval { $opt = XMLin($xml, keyattr => { part => 'partnum' }, forcearray => ['x','y']); }; isnt($@, '', 'omitting keyattr elements from forcearray was a fatal error'); like($@, qr/<part> set in keyattr but not in forcearray/, 'with the correct error message'); # Confirm that missing key attributes are detected $xml = q( <opt> <part partnum="12345" desc="Thingy" /> <part partnum="67890" desc="Wotsit" /> <part desc="Fnurgle" /> </opt> ); eval { $opt = XMLin($xml, keyattr => { part => 'partnum' }, forcearray => 1); }; isnt($@, '', 'key attribute missing from names element was a fatal error'); like($@, qr/<part> element has no 'partnum' key attribute/, 'with the correct error message'); exit(0); Index: 1_XMLin.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/1_XMLin.t,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- 1_XMLin.t 16 Oct 2002 09:43:35 -0000 1.5 +++ 1_XMLin.t 17 Oct 2002 07:29:44 -0000 1.6 @@ -21,8 +21,8 @@ $@ = ''; eval "use XML::Simple;"; is($@, '', 'Module compiled OK'); -unless($XML::Simple::VERSION eq '1.08_01') { - diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 1.08_01)"); +unless($XML::Simple::VERSION eq '2.00') { + diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 2.00)"); } |