Debian Codegraph @

t/16_tied.t

raw
1 # copied over from JSON::XS and modified to use JSON
2
3 use strict;
4 use warnings;
5 use Test::More;
6 BEGIN { plan tests => 2 };
7
8 BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; }
9
10 use JSON;
11 use Tie::Hash;
12 use Tie::Array;
13
14
15 my $js = JSON->new;
16
17 tie my %h, 'Tie::StdHash';
18 %h = (a => 1);
19
20 ok ($js->encode (\%h) eq '{"a":1}');
21
22 tie my @a, 'Tie::StdArray';
23 @a = (1, 2);
24
25 ok ($js->encode (\@a) eq '[1,2]');