Permalink
Browse files

Merge pull request #34 from aidy/master

Fix is_bool
  • Loading branch information...
2 parents 186a277 + 3d75df2 commit 4c7b77b3e441cd1b6a2f37cda908dd268017172f @charsbar charsbar committed Jul 21, 2017
Showing with 3 additions and 2 deletions.
  1. +1 −1 lib/JSON/PP.pm
  2. +2 −1 t/003_types.t
View
@@ -1405,7 +1405,7 @@ BEGIN {
$JSON::PP::true = do { bless \(my $dummy = 1), "JSON::PP::Boolean" };
$JSON::PP::false = do { bless \(my $dummy = 0), "JSON::PP::Boolean" };
-sub is_bool { defined $_[0] and UNIVERSAL::isa($_[0], "JSON::PP::Boolean"); }
+sub is_bool { ref $_[0] and $_[0]->isa("JSON::PP::Boolean"); }
sub true { $JSON::PP::true }
sub false { $JSON::PP::false }
View
@@ -2,7 +2,7 @@
use strict;
use Test::More;
-BEGIN { plan tests => 76 };
+BEGIN { plan tests => 77 };
BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }
@@ -21,6 +21,7 @@ ok ($false == !$true);
ok (JSON::PP::is_bool $false);
ok (++$false == 1);
ok (!JSON::PP::is_bool $false);
+ok (!JSON::PP::is_bool "JSON::PP::Boolean");
ok (JSON::PP->new->allow_nonref (1)->decode ('5') == 5);
ok (JSON::PP->new->allow_nonref (1)->decode ('-5') == -5);

0 comments on commit 4c7b77b

Please sign in to comment.