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