basic tests
[scpubgit/JSON-Diffable.git] / t / basic.t
CommitLineData
87d44e90 1use strictures 1;
2use Test::More;
3
4use JSON::Diffable qw( encode_json decode_json );
5
6my $data = {
7 foo => [23, { bar => 19, baz => undef }, 42],
8 bar => { x => undef, y => 17, z => [3..5] },
9 baz => [],
10 qux => {},
11};
12my $json = encode_json($data);
13
14is "$json\n", <<'ENDJSON', 'encode';
15{
16 "bar": {
17 "x": null,
18 "y": 17,
19 "z": [
20 3,
21 4,
22 5,
23 ],
24 },
25 "baz": [
26 ],
27 "foo": [
28 23,
29 {
30 "bar": 19,
31 "baz": null,
32 },
33 42,
34 ],
35 "qux": {
36 },
37}
38ENDJSON
39
40is_deeply decode_json($json), $data, 'decode';
41
42done_testing;