1
2use Test::More;
3use strict;
4
5BEGIN { plan tests => 90 };
6
7BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }
8
9BEGIN {
10    use lib qw(t);
11    use _unicode_handling;
12}
13
14use JSON;
15
16my @simples = 
17    qw/utf8 indent canonical space_before space_after allow_nonref shrink allow_blessed
18        convert_blessed relaxed
19     /;
20
21if ($JSON::can_handle_UTF16_and_utf8) {
22    unshift @simples, 'ascii';
23    unshift @simples, 'latin1';
24}
25
26SKIP: {
27    skip "UNICODE handling is disabale.", 14 unless $JSON::can_handle_UTF16_and_utf8;
28}
29
30my $json = new JSON;
31
32for my $name (@simples) {
33    my $method = 'get_' . $name;
34    ok(! $json->$method(), $method . ' default');
35    $json->$name();
36    ok($json->$method(), $method . ' set true');
37    $json->$name(0);
38    ok(! $json->$method(), $method . ' set false');
39    $json->$name();
40    ok($json->$method(), $method . ' set true again');
41}
42
43
44ok($json->get_max_depth == 512, 'get_max_depth default');
45$json->max_depth(7);
46ok($json->get_max_depth == 7, 'get_max_depth set 7 => 7');
47$json->max_depth();
48ok($json->get_max_depth != 0, 'get_max_depth no arg');
49
50
51ok($json->get_max_size == 0, 'get_max_size default');
52$json->max_size(7);
53ok($json->get_max_size == 7, 'get_max_size set 7 => 7');
54$json->max_size();
55ok($json->get_max_size == 0, 'get_max_size no arg');
56
57
58for my $name (@simples) {
59    $json->$name();
60    ok($json->property($name), $name);
61    $json->$name(0);
62    ok(! $json->property($name), $name);
63    $json->$name();
64    ok($json->property($name), $name);
65}
66
67
68