1BEGIN {
2  unshift @INC, sub {
3    my $file = $_[1];
4    die "Skipping $file in this test" if $file =~ m!Sereal\W+Encoder\.pm$!;
5  };
6}
7
8use Mojo::Util 'md5_sum';
9use JSON::Validator;
10use JSON::Validator::Util qw(data_checksum);
11use Test::More;
12
13my $d_hash  = {foo => {}, bar => {}};
14my $d_hash2 = {bar => {}, foo => {}};
15my $d_undef = {foo => undef};
16my $d_obj   = {foo => JSON::Validator::Error->new};
17my $d_array  = ['foo', 'bar'];
18my $d_array2 = ['bar', 'foo'];
19
20ok !$INC{'Sereal/Encoder.pm'}, 'Sereal::Encoder was not loaded';
21
22isnt data_checksum($d_array), data_checksum($d_array2), 'data_checksum array';
23is data_checksum($d_hash),    data_checksum($d_hash2),  'data_checksum hash field order';
24isnt data_checksum($d_hash),  data_checksum($d_undef),  'data_checksum hash not undef';
25isnt data_checksum($d_hash),  data_checksum($d_obj),    'data_checksum hash not object';
26isnt data_checksum($d_obj),   data_checksum($d_undef),  'data_checksum object not undef';
27isnt data_checksum(3.14), md5_sum(3.15),         'data_checksum numeric';
28is data_checksum(3.14),   data_checksum('3.14'), 'data_checksum numeric like string';
29
30done_testing;
31