Home | History | Annotate | Download | only in t
      1 
      2 use Test::More;
      3 use strict;
      4 
      5 BEGIN { plan tests => 90 };
      6 
      7 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
      8 
      9 BEGIN {
     10     use lib qw(t);
     11     use _unicode_handling;
     12 }
     13 
     14 use JSON;
     15 
     16 my @simples = 
     17     qw/utf8 indent canonical space_before space_after allow_nonref shrink allow_blessed
     18         convert_blessed relaxed
     19      /;
     20 
     21 if ($JSON::can_handle_UTF16_and_utf8) {
     22     unshift @simples, 'ascii';
     23     unshift @simples, 'latin1';
     24 }
     25 
     26 SKIP: {
     27     skip "UNICODE handling is disabale.", 14 unless $JSON::can_handle_UTF16_and_utf8;
     28 }
     29 
     30 my $json = new JSON;
     31 
     32 for 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 
     44 ok($json->get_max_depth == 512, 'get_max_depth default');
     45 $json->max_depth(7);
     46 ok($json->get_max_depth == 7, 'get_max_depth set 7 => 7');
     47 $json->max_depth();
     48 ok($json->get_max_depth != 0, 'get_max_depth no arg');
     49 
     50 
     51 ok($json->get_max_size == 0, 'get_max_size default');
     52 $json->max_size(7);
     53 ok($json->get_max_size == 7, 'get_max_size set 7 => 7');
     54 $json->max_size();
     55 ok($json->get_max_size == 0, 'get_max_size no arg');
     56 
     57 
     58 for 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