| File: | t/020_json__010_basic.t |
| Coverage: | 93.3% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | #!perl | ||||||
| 2 | |||||||
| 3 | 1 1 1 | 5990 3 28 | use strict; | ||||
| 4 | 1 1 1 | 3 1 32 | use warnings; | ||||
| 5 | |||||||
| 6 | 1 1 1 | 1451 143604 2 | use Test::Most; | ||||
| 7 | 1 1 1 | 26565 6741 5 | use JSON; | ||||
| 8 | 1 1 1 | 613 2 1349 | use JSON::DJARE::Writer; | ||||
| 9 | |||||||
| 10 | 1 | 62820 | my $writer = JSON::DJARE::Writer->new( | ||||
| 11 | djare_version => '0.0.2', | ||||||
| 12 | meta_version => '0.1.1', | ||||||
| 13 | meta_from => 'foo', | ||||||
| 14 | ); | ||||||
| 15 | |||||||
| 16 | 1 | 1 | for my $type (qw/data error/) { | ||||
| 17 | 2 | 141 | my $json_method = "${type}_json"; | ||||
| 18 | 2 | 5 | my $minimal = $writer->to_json( $writer->$type('foo') ); | ||||
| 19 | |||||||
| 20 | 2 | 5 | is( | ||||
| 21 | $minimal, | ||||||
| 22 | $writer->$json_method('foo'), | ||||||
| 23 | "$type: Same result from both ways of getting json" | ||||||
| 24 | ); | ||||||
| 25 | |||||||
| 26 | ok( | ||||||
| 27 | ( exists decode_json($minimal)->{'meta'} ) | ||||||
| 28 | 2 | 422 | && ( exists decode_json($minimal)->{$type} ), | ||||
| 29 | "$type: sensible JSON produced" | ||||||
| 30 | ); | ||||||
| 31 | } | ||||||
| 32 | |||||||
| 33 | 1 | 128 | done_testing(); | ||||