Skip to content

Commit

Permalink
Undo the previous change and fix the test.
Browse files Browse the repository at this point in the history
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
rjray committed Jun 6, 2013
1 parent f6cee93 commit 3361769
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/RPC/XML.pm
Expand Up @@ -844,7 +844,7 @@ sub as_string
("<member><name>$_</name><value>",
$clean{$_},
'</value></member>')
} (sort keys %clean)),
} (keys %clean)),
'</struct>';
}

Expand All @@ -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);
Expand Down
17 changes: 16 additions & 1 deletion t/15_serialize.t
Expand Up @@ -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;
Expand Down

0 comments on commit 3361769

Please sign in to comment.