[OpenSRF-GIT] OpenSRF branch rel_2_2 updated. osrf_rel_2_2_1-3-g899661b

Evergreen Git git at git.evergreen-ils.org
Tue Dec 3 14:52:37 EST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".

The branch, rel_2_2 has been updated
       via  899661bbfba59f719650077875afa813cc50f044 (commit)
       via  98fd4b223def201382b4b4c330c4a0a1fc376e3d (commit)
       via  77d2bfe7d7dbe7815e980bb5e6e9be9a14b9992f (commit)
      from  01f2fe871a10bb5facf3388b3d9d8b0be7f512d8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 899661bbfba59f719650077875afa813cc50f044
Author: Jeff Godin <jgodin at tadl.org>
Date:   Tue Dec 3 13:52:39 2013 -0500

    Add some additional boolean-related JSON tests
    
    Add some additional boolean-related JSON tests, enable use strict /
    use warnings for JSON tests.
    
    Signed-off-by: Jeff Godin <jgodin at tadl.org>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/src/perl/t/09-Utils-JSON.t b/src/perl/t/09-Utils-JSON.t
index d074d5e..ce94012 100644
--- a/src/perl/t/09-Utils-JSON.t
+++ b/src/perl/t/09-Utils-JSON.t
@@ -1,6 +1,8 @@
 #!perl -T
+use strict;
+use warnings;
 
-use Test::More tests => 49;
+use Test::More tests => 54;
 
 use OpenSRF::Utils::JSON;
 
@@ -19,6 +21,7 @@ is ($OpenSRF::Utils::JSON::JSON_PAYLOAD_KEY, '__p');
 # start with the simplest bits possible
 is (OpenSRF::Utils::JSON::true, 1);
 is (OpenSRF::Utils::JSON->true, 1);
+is (OpenSRF::Utils::JSON::false, 0);
 is (OpenSRF::Utils::JSON->false, 0);
 
 
@@ -28,7 +31,7 @@ my $testmap =  { hints   => { osrfException =>
                               { hint => 'osrfException',
                                 name => 'OpenSRF::DomainObject::oilsException' }
                             },
-                 classes => { OpenSRF::DomainObject::oilsException =>
+                 classes => { 'OpenSRF::DomainObject::oilsException' =>
                               { hint => 'osrfException',
                                 name => 'OpenSRF::DomainObject::oilsException' }
                             }
@@ -77,7 +80,11 @@ is (OpenSRF::Utils::JSON->perl2JSONObject(3),     3,     "Returns argument unles
 is (OpenSRF::Utils::JSON->perl2JSONObject('foo'), 'foo', "Returns argument unless it's a ref");
 
 ok (JSON::XS::is_bool(OpenSRF::Utils::JSON->true), 'OpenSRF::Utils::JSON->true is a Boolean according to JSON::XS');
-is (OpenSRF::Utils::JSON->perl2JSONObject(OpenSRF::Utils::JSON->true), '1', "Returns argument if it's a Boolean according to JSON");
+ok (JSON::XS::is_bool(OpenSRF::Utils::JSON->false), 'OpenSRF::Utils::JSON->false is a Boolean according to JSON::XS');
+ok (!JSON::XS::is_bool 1, "1 is not a boolean according to JSON::XS");
+ok (!JSON::XS::is_bool 0, "0 is not a boolean according to JSON::XS");
+is (OpenSRF::Utils::JSON->perl2JSONObject(OpenSRF::Utils::JSON->true), '1', "Returns argument if it's a Boolean according to JSON::XS");
+is (OpenSRF::Utils::JSON->perl2JSONObject(OpenSRF::Utils::JSON->false), '0', "Returns argument if it's a Boolean according to JSON::XS");
 
 my $hashref = { foo => 'bar' };
 is (UNIVERSAL::isa($hashref,'HASH'), 1);
@@ -114,13 +121,13 @@ is (OpenSRF::Utils::JSON->JSONObject2Perl($coderef), $coderef, "Returns argument
 
 is_deeply (OpenSRF::Utils::JSON->JSONObject2Perl([11, 12]), [11, 12], "Arrayrefs get reconstructed as themselves");
 is_deeply (OpenSRF::Utils::JSON->JSONObject2Perl([11, OpenSRF::Utils::JSON->true, 12]), [11, OpenSRF::Utils::JSON->true, 12],
-           "Even when they contain JSON::XS  Booleans; those just don't get recursed upon");
+           "Even when they contain JSON::XS Booleans; those just don't get recursed upon");
            # note: [11, 1, 12] doesn't work here, even though you can do math on J::X Booleans
 
 is_deeply (OpenSRF::Utils::JSON->JSONObject2Perl($hashref), { foo => 'bar' }, "Hashrefs without the class flag also get turned into themselves");
 is_deeply (OpenSRF::Utils::JSON->JSONObject2Perl({ foo => OpenSRF::Utils::JSON->true, bar => 'baz' }), 
            { foo => OpenSRF::Utils::JSON->true, bar => 'baz'},
-           "Even when they contain JSON::XS  Booleans; those just don't get recursed upon");
+           "Even when they contain JSON::XS Booleans; those just don't get recursed upon");
 
 my $vivobj = OpenSRF::Utils::JSON->JSONObject2Perl($jsonobj);
 is (ref $vivobj, 'OpenSRF::DomainObject::oilsException');

commit 98fd4b223def201382b4b4c330c4a0a1fc376e3d
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Dec 3 09:57:39 2013 -0500

    LP#1257264: Use the built-in JSON-y test for bools
    
    This removes a dependency on internal details of JSON::XS's
    implementation of Boolean types which changed with the release
    of JSON::XS 3.0.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Jeff Godin <jgodin at tadl.org>

diff --git a/src/perl/lib/OpenSRF/Utils/JSON.pm b/src/perl/lib/OpenSRF/Utils/JSON.pm
index 58a7a02..a83e9d1 100644
--- a/src/perl/lib/OpenSRF/Utils/JSON.pm
+++ b/src/perl/lib/OpenSRF/Utils/JSON.pm
@@ -160,13 +160,13 @@ sub JSONObject2Perl {
         # is a hash, but no class marker; simply revivify innards
         for my $k (keys %$obj) {
             $obj->{$k} = $pkg->JSONObject2Perl($obj->{$k})
-              unless ref $obj->{$k} eq 'JSON::XS::Boolean';
+              unless JSON::XS::is_bool $obj->{$k};
         }
     } elsif ( ref $obj eq 'ARRAY' ) {
         # not a hash; an array. revivify.
         for my $i (0..scalar(@$obj) - 1) {
             $obj->[$i] = $pkg->JSONObject2Perl($obj->[$i])
-              unless (ref $obj->[$i] eq 'JSON::XS::Boolean');
+              unless JSON::XS::is_bool $obj->[$i];
               # FIXME? This does nothing except leave any Booleans in
               # place, without recursively calling this sub on
               # them. I'm not sure if that's what's supposed to
@@ -205,8 +205,7 @@ sub perl2JSONObject {
     my ($pkg, $obj) = @_;
     my $ref = ref $obj;
 
-    return $obj unless $ref;
-    return $obj if $ref eq 'JSON::XS::Boolean';
+    return $obj if !$ref or JSON::XS::is_bool $obj;
 
     my $jsonobj;
 

commit 77d2bfe7d7dbe7815e980bb5e6e9be9a14b9992f
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Tue Dec 3 09:43:54 2013 -0800

    LP#1257264: make test cases for JSON::XS Boolean-ness more generic
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Jeff Godin <jgodin at tadl.org>

diff --git a/src/perl/t/09-Utils-JSON.t b/src/perl/t/09-Utils-JSON.t
index 7b5908b..d074d5e 100644
--- a/src/perl/t/09-Utils-JSON.t
+++ b/src/perl/t/09-Utils-JSON.t
@@ -76,8 +76,8 @@ is (OpenSRF::Utils::JSON->perl2JSONObject(),      undef, "Returns argument unles
 is (OpenSRF::Utils::JSON->perl2JSONObject(3),     3,     "Returns argument unless it's a ref");
 is (OpenSRF::Utils::JSON->perl2JSONObject('foo'), 'foo', "Returns argument unless it's a ref");
 
-is (ref OpenSRF::Utils::JSON->true, 'JSON::XS::Boolean');
-is (OpenSRF::Utils::JSON->perl2JSONObject(OpenSRF::Utils::JSON->true), '1', "Returns argument if it's a JSON::XS::Boolean");
+ok (JSON::XS::is_bool(OpenSRF::Utils::JSON->true), 'OpenSRF::Utils::JSON->true is a Boolean according to JSON::XS');
+is (OpenSRF::Utils::JSON->perl2JSONObject(OpenSRF::Utils::JSON->true), '1', "Returns argument if it's a Boolean according to JSON");
 
 my $hashref = { foo => 'bar' };
 is (UNIVERSAL::isa($hashref,'HASH'), 1);
@@ -114,13 +114,13 @@ is (OpenSRF::Utils::JSON->JSONObject2Perl($coderef), $coderef, "Returns argument
 
 is_deeply (OpenSRF::Utils::JSON->JSONObject2Perl([11, 12]), [11, 12], "Arrayrefs get reconstructed as themselves");
 is_deeply (OpenSRF::Utils::JSON->JSONObject2Perl([11, OpenSRF::Utils::JSON->true, 12]), [11, OpenSRF::Utils::JSON->true, 12],
-           "Even when they contain JSON::XS::Booleans; those just don't get recursed upon");
-           # note: [11, 1, 12] doesn't work here, even though you can do math on J:X:Booleans
+           "Even when they contain JSON::XS  Booleans; those just don't get recursed upon");
+           # note: [11, 1, 12] doesn't work here, even though you can do math on J::X Booleans
 
 is_deeply (OpenSRF::Utils::JSON->JSONObject2Perl($hashref), { foo => 'bar' }, "Hashrefs without the class flag also get turned into themselves");
 is_deeply (OpenSRF::Utils::JSON->JSONObject2Perl({ foo => OpenSRF::Utils::JSON->true, bar => 'baz' }), 
            { foo => OpenSRF::Utils::JSON->true, bar => 'baz'},
-           "Even when they contain JSON::XS::Booleans; those just don't get recursed upon");
+           "Even when they contain JSON::XS  Booleans; those just don't get recursed upon");
 
 my $vivobj = OpenSRF::Utils::JSON->JSONObject2Perl($jsonobj);
 is (ref $vivobj, 'OpenSRF::DomainObject::oilsException');

-----------------------------------------------------------------------

Summary of changes:
 src/perl/lib/OpenSRF/Utils/JSON.pm |    7 +++----
 src/perl/t/09-Utils-JSON.t         |   21 ++++++++++++++-------
 2 files changed, 17 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
OpenSRF


More information about the opensrf-commits mailing list