Commit | Line | Data |
9ff679e4 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | |
b5f363ac |
8 | BEGIN { |
9ff679e4 |
9 | local $@; |
10 | plan skip_all => "MooseX::Storage::Format::JSONpm required for this test" |
11 | unless eval "require MooseX::Storage::Format::JSONpm; 1"; |
12 | } |
13 | |
14 | plan tests => 3; |
15 | use_ok('MooseX::Storage'); |
16 | |
17 | { |
18 | |
19 | package Foo; |
20 | use Moose; |
21 | use MooseX::Storage; |
22 | |
23 | with Storage(format => [ JSONpm => { json_opts => { pretty => 1 } } ] ); |
24 | # with Storage(format => 'JSONpm'); |
25 | |
26 | has 'string' => ( is => 'ro', isa => 'Str' ); |
27 | has 'float' => ( is => 'ro', isa => 'Num' ); |
28 | } |
29 | |
30 | { |
31 | my $foo = Foo->new( |
32 | string => 'foo', |
33 | float => 10.5, |
34 | ); |
35 | isa_ok( $foo, 'Foo' ); |
36 | |
37 | my $json = $foo->freeze; |
38 | |
39 | isnt( |
40 | index($json, "\n"), |
41 | -1, |
42 | "there are newlines in our JSON, because it is pretty", |
43 | ) or diag $json; |
44 | |
45 | } |
46 | |