Permalink
Browse files

Added fallback to overload

  • Loading branch information...
1 parent c49e10b commit bc4edb64b5ba31512f45748ae58e0d85e7dadd35 @vti committed May 24, 2010
Showing with 8 additions and 2 deletions.
  1. +1 −1 lib/Mojo/JSON/Any.pm
  2. +1 −1 lib/Mojo/JSON/XS.pm
  3. +6 −0 t/json.t
View
@@ -3,7 +3,7 @@ package Mojo::JSON::Any;
use strict;
use warnings;
-our $VERSION = '0.990102';
+our $VERSION = '0.990103';
use Mojo::JSON;
View
@@ -112,7 +112,7 @@ use warnings;
use base 'Mojo::Base';
use overload (
'0+' => sub { $_[0]->{_value} },
- '""' => sub { $_[0]->{_value} }
+ '""' => sub { $_[0]->{_value} }, fallback => 1
);
sub new { shift->SUPER::new(_value => shift) }
View
@@ -19,6 +19,12 @@ use_ok('Mojo::JSON::Any');
my $json = Mojo::JSON::Any->new;
isa_ok($json, 'Mojo::JSON::XS');
+# Test if overload behaves correctly
+ok($json->true == $json->true);
+ok($json->true != $json->false);
+ok($json->true eq $json->true);
+ok($json->true ne $json->false);
+
# Decode array
my $array = $json->decode('[]');
is_deeply($array, [], 'decode []');

0 comments on commit bc4edb6

Please sign in to comment.