Subject: | JSON 2.04 and bundled JSON cause test failures |
Upon upgrading to JSON 2.04 and JSON::Any 1.15, I noticed that
Catalyst::View::JSON has test failures due to the inc-bundled version of
JSON:
[16:34:31 dwc@adora ~/Catalyst-View-JSON-0.21]$ make test
cp lib/Catalyst/View/JSON.pm blib/lib/Catalyst/View/JSON.pm
cp lib/Catalyst/Helper/View/JSON.pm blib/lib/Catalyst/Helper/View/JSON.pm
PERL_DL_NONLAZY=1 /usr/bin/perl5.8.8 "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'inc', 'blib/lib', 'blib/arch')" t/*.t
t/00_compile....ok
t/01_server.....Couldn't instantiate component "TestApp::View::JSON",
""-support_by_pp" is not exported by the JSON module
"-no_export" is not exported by the JSON module
Can't continue after import errors at
/usr/lib/perl5/vendor_perl/5.8.8/JSON/Any.pm line 41" at
/usr/lib/perl5/vendor_perl/5.8.8/Catalyst/Test.pm line 90
Compilation failed in require at
/usr/lib/perl5/vendor_perl/5.8.8/Catalyst/Test.pm line 90.
BEGIN failed--compilation aborted at t/01_server.t line 9.
# Looks like your test died before it could output anything.
t/01_server.....dubious
Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 1-38
Failed 38/38 tests, 0.00% okay
Failed Test Stat Wstat Total Fail List of Failed
-------------------------------------------------------------------------------
t/01_server.t 255 65280 38 76 1-38
Failed 1/2 test scripts. 38/39 subtests failed.
Files=2, Tests=39, 1 wallclock secs ( 0.56 cusr + 0.08 csys = 0.64 CPU)
Failed 1/2 test programs. 38/39 subtests failed.
make: *** [test_dynamic] Error 255
(See also the three most recent cpan-testers reports.)
Attached is a patch to update the bundled version and to update the
tests to reflect the deprecation of JSON::jsonToObj in favor
JSON::from_json.
Subject: | catalyst-view-json-0.21-update-bundled-json.patch |
=== Makefile.PL
==================================================================
--- Makefile.PL (revision 16898)
+++ Makefile.PL (local)
@@ -4,9 +4,9 @@
all_from 'lib/Catalyst/View/JSON.pm';
build_requires 'Test::More';
-build_requires $_ for qw( JSON JSON::Parser JSON::Converter );
+build_requires 'JSON', 2.04;
-requires 'JSON::Any', 1.11;
+requires 'JSON::Any', 1.15;
requires 'Catalyst', 5.60;
auto_include;
=== t/01_server.t
==================================================================
--- t/01_server.t (revision 16898)
+++ t/01_server.t (local)
@@ -34,7 +34,7 @@
is( $response->code, 200, 'Response Code' );
is_deeply( [ $response->content_type ], [ 'application/json', 'charset=utf-8' ] );
- my $data = JSON::jsonToObj($response->content);
+ my $data = JSON::from_json($response->content);
is $data->{json_foo}, "bar";
is_deeply $data->{json_baz}, [ 1, 2, 3 ];
ok ! $data->{foo}, "doesn't return stash that doesn't match json_";
@@ -48,7 +48,7 @@
is( $response->code, 200, 'Response Code' );
is_deeply( [ $response->content_type ], [ 'application/json', 'charset=utf-8' ] );
- my $data = JSON::jsonToObj($response->content);
+ my $data = JSON::from_json($response->content);
is_deeply( $data, [1, 2, 3] );
}
@@ -63,7 +63,7 @@
my $body = $response->content;
ok $body =~ s/^foobar\((.*?)\);$/$1/sg, "wrapped in a callback";
- my $data = JSON::jsonToObj($body);
+ my $data = JSON::from_json($body);
is $data->{json_foo}, "bar";
is_deeply $data->{json_baz}, [ 1, 2, 3 ];
ok ! $data->{foo}, "doesn't return stash that doesn't match json_";