X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FJSON-Diffable.git;a=blobdiff_plain;f=t%2Fbasic.t;fp=t%2Fbasic.t;h=cd9fb7f98277c75649123607f2e0cb3ecfeb030b;hp=0000000000000000000000000000000000000000;hb=87d44e9091f62669416e25bde3b4879b3038eeb7;hpb=8add33092ff92b914e4e01c144539161e5431968 diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..cd9fb7f --- /dev/null +++ b/t/basic.t @@ -0,0 +1,42 @@ +use strictures 1; +use Test::More; + +use JSON::Diffable qw( encode_json decode_json ); + +my $data = { + foo => [23, { bar => 19, baz => undef }, 42], + bar => { x => undef, y => 17, z => [3..5] }, + baz => [], + qux => {}, +}; +my $json = encode_json($data); + +is "$json\n", <<'ENDJSON', 'encode'; +{ + "bar": { + "x": null, + "y": 17, + "z": [ + 3, + 4, + 5, + ], + }, + "baz": [ + ], + "foo": [ + 23, + { + "bar": 19, + "baz": null, + }, + 42, + ], + "qux": { + }, +} +ENDJSON + +is_deeply decode_json($json), $data, 'decode'; + +done_testing;