make this test function properly when JSON backends aren't installed
[gitmo/MooseX-Storage.git] / t / 300_overloaded.t
CommitLineData
049541bd 1use strict;
2use warnings;
3use Test::More;
9d3c60f5 4use Test::Fatal;
049541bd 5
0b173188 6use Test::Requires {
7 'JSON::Any' => 0.01, # skip all if not installed
8};
049541bd 9
10{
11 package Thing;
12 use Moose;
13 use MooseX::Storage;
14
15 use overload
16 q{""} => 'as_string',
17 fallback => 1;
18
19 with Storage('format' => 'JSON');
20
21 has foo => ( is => 'ro' );
22
23 sub as_string { shift->freeze }
24
25 no Moose;
26}
27
28my $i = Thing->new(foo => "bar");
29
9d3c60f5 30is( exception {
049541bd 31 $i . "";
9d3c60f5 32}, undef, 'Can stringify without deep recursion');
049541bd 33
34done_testing;
35