Skip Menu |

This queue is for tickets about the JSON CPAN distribution.

Report information
The Basics
Id: 15128
Status: resolved
Priority: 0/
Queue: JSON

People
Owner: Nobody in particular
Requestors: gerryster [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: hash order assumption in t/rpc04-json_opt.t fails
Distribution: JSON-1.00.tar.gz Perl verion: This is perl, v5.8.1-RC3 built for darwin-thread-multi-2level (with 1 registered patch, see perl -V for more detail) OS: Darwin 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC Power Macintosh powerpc (Mac OS 10.3.9) Line 23 of t/rpc04-json_opt.t assumes an order of an unordered hash: is($q->param('json'),'{"params":[true,false,null],"id":"httpReq","method":"echo"}' ); When I run a make test, I get: t/rpc04-json_opt.....NOK 1 # Failed test (t/rpc04-json_opt.t at line 23) # got: '{"id":"httpReq","method":"echo","params":[true,false,null]}' # expected: '{"params":[true,false,null],"id":"httpReq","method":"echo"}' I think the issue is that the sub objToJson has no way of knowing (or should it know) the order of the keys on an incomming hash. This is also the reason that the 1.00 tests failed on 5.8.1 on Freebsd 5.4-stable (i386-freebsd).
Subject: Re: hash order assumption in t/rpc04-json_opt.t fails
From: Peter (Stig) Edwards
Show quoted text
> Distribution: JSON-1.00.tar.gz
...cut... Show quoted text
> Line 23 of t/rpc04-json_opt.t assumes an order of an unordered hash:
...cut... Show quoted text
> This is also the reason that the 1.00 tests failed on 5.8.1 on Freebsd > 5.4-stable (i386-freebsd).
FYI - this test (rpc04-json.t) for this version (1.00) also fails on 5.8.1 built for VMS_AXP. I used the following workaround, I'm sure there is a better workaround. #is($q->param('json'), '{"params": [true,false,null],"id":"httpReq","method":"echo"}'); # Replaced with line below due to dependency on hash key order. Peter (Stig) Edwards 20051105 is(substr($q->param('json'),0,1).join(',"',sort {($a=~/"*(.*)/) cmp ($b=~/"*(.*)/)} (split /,"/,substr($q->param('json'),1,-1))).substr($q- Show quoted text
>param('json'\
),-1), '{"id":"httpReq","method":"echo","params":[true,false,null]}'); Cheers, Peter (Stig) Edwards