From: Robert 'phaylon' Sedlacek Date: Wed, 30 May 2012 23:47:48 +0000 (+0000) Subject: basic tests X-Git-Tag: v0.000001~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=87d44e9091f62669416e25bde3b4879b3038eeb7;p=scpubgit%2FJSON-Diffable.git basic tests --- 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;