Permalink
Browse files

Undo the previous change and fix the test.

The previous change didn't feel right, so this rolls it back and fixes the
problem at the level of the test, instead.
  • Loading branch information...
1 parent f6cee93 commit 33617691326a0bc01efea624e05c65047f1c6154 @rjray committed Jun 6, 2013
Showing with 18 additions and 3 deletions.
  1. +2 −2 lib/RPC/XML.pm
  2. +16 −1 t/15_serialize.t
View
@@ -844,7 +844,7 @@ sub as_string
("<member><name>$_</name><value>",
$clean{$_},
'</value></member>')
- } (sort keys %clean)),
+ } (keys %clean)),
'</struct>';
}
@@ -856,7 +856,7 @@ sub serialize
my $key;
print {$fh} '<struct>';
- for (sort keys %{$self})
+ for (keys %{$self})
{
($key = $_) =~ s/$RPC::XML::XMLRE/$RPC::XML::XMLMAP{$1}/ge;
utf8::downgrade($key);
View
@@ -96,7 +96,22 @@ seek $ofh, 0, 0;
$data = '';
read $ofh, $data, -s $ofh;
-is($data, $faux_res->as_string, 'Fault-response content is correct');
+# There have been some changes to how Perl handles iteration of hash keys.
+# As a result, this test has started failing a lot because of the order of
+# keys when serialized doesn't match the order of keys from as_string(). So
+# to get around this, just compare it to both variations that can occur.
+my $variant1 = '<?xml version="1.0" encoding="us-ascii"?><methodResponse>' .
+ '<fault><value><struct><member><name>faultString</name><value><string>' .
+ 'test</string></value></member><member><name>faultCode</name><value>' .
+ '<int>1</int></value></member></struct></value></fault></methodResponse>';
+my $variant2 = '<?xml version="1.0" encoding="us-ascii"?><methodResponse>' .
+ '<fault><value><struct><member><name>faultCode</name><value><int>1</int>' .
+ '</value></member><member><name>faultString</name><value><string>test' .
+ '</string></value></member></struct></value></fault></methodResponse>';
+ok(
+ ($data eq $variant1) || ($data eq $variant2),
+ 'Fault-response content is correct'
+);
close $ofh;
unlink $tmpfile;

0 comments on commit 3361769

Please sign in to comment.