Commit | Line | Data |
---|---|---|
049541bd | 1 | use strict; |
2 | use warnings; | |
3 | use Test::More; | |
9d3c60f5 | 4 | use Test::Fatal; |
049541bd | 5 | |
0b173188 | 6 | use 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 | ||
28 | my $i = Thing->new(foo => "bar"); | |
29 | ||
9d3c60f5 | 30 | is( exception { |
049541bd | 31 | $i . ""; |
9d3c60f5 | 32 | }, undef, 'Can stringify without deep recursion'); |
049541bd | 33 | |
34 | done_testing; | |
35 |