#!perl -T
+use strict;
+use warnings;
-use Test::More tests => 49;
+use Test::More tests => 54;
use OpenSRF::Utils::JSON;
# 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);
{ hint => 'osrfException',
name => 'OpenSRF::DomainObject::oilsException' }
},
- classes => { OpenSRF::DomainObject::oilsException =>
+ classes => { 'OpenSRF::DomainObject::oilsException' =>
{ hint => 'osrfException',
name => 'OpenSRF::DomainObject::oilsException' }
}
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);
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');