Commit | Line | Data |
049541bd |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | use Test::Exception; |
5 | |
6 | BEGIN { |
7 | eval { require JSON::Any } or do { |
8 | plan skip_all => "JSON::Any is required for this test"; |
9 | exit 0; |
10 | } |
11 | } |
12 | |
13 | { |
14 | package Thing; |
15 | use Moose; |
16 | use MooseX::Storage; |
17 | |
18 | use overload |
19 | q{""} => 'as_string', |
20 | fallback => 1; |
21 | |
22 | with Storage('format' => 'JSON'); |
23 | |
24 | has foo => ( is => 'ro' ); |
25 | |
26 | sub as_string { shift->freeze } |
27 | |
28 | no Moose; |
29 | } |
30 | |
31 | my $i = Thing->new(foo => "bar"); |
32 | |
33 | lives_ok { |
34 | $i . ""; |
35 | } 'Can stringify without deep recursion'; |
36 | |
37 | done_testing; |
38 | |