diff options
author | Hyunjee Kim <hj0426.kim@samsung.com> | 2020-03-17 09:38:42 +0900 |
---|---|---|
committer | Hyunjee Kim <hj0426.kim@samsung.com> | 2020-03-17 10:32:30 +0900 |
commit | 8d2a41273a56a33a291d292c1fbee03cce290694 (patch) | |
tree | d2e93626e62e86e0be5696b4ce240d0af7376a6a /t/e01_property.t | |
parent | c5bbcb68877d7b8bdb968a69aa62b3b90853cb3f (diff) | |
download | perl-json-8d2a41273a56a33a291d292c1fbee03cce290694.tar.gz perl-json-8d2a41273a56a33a291d292c1fbee03cce290694.tar.bz2 perl-json-8d2a41273a56a33a291d292c1fbee03cce290694.zip |
Imported Upstream version 4.02upstream/4.02
Change-Id: I549bbbd41e3db39e6fd6f2b1f2c4c94b94071018
Signed-off-by: Hyunjee Kim <hj0426.kim@samsung.com>
Diffstat (limited to 't/e01_property.t')
-rw-r--r-- | t/e01_property.t | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/t/e01_property.t b/t/e01_property.t new file mode 100644 index 0000000..ce3125c --- /dev/null +++ b/t/e01_property.t @@ -0,0 +1,65 @@ + +use Test::More; +use strict; + +BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } + +use JSON; + +my @simples = + qw/ascii latin1 utf8 indent canonical space_before space_after allow_nonref shrink allow_blessed + convert_blessed relaxed + /; + +my $json = new JSON; + +# JSON::XS/JSON::PP 4.0 allow nonref by default +my $allow_nonref_by_default = $json->allow_nonref; + +my $has_allow_tags = 0; +if ($json->can('allow_tags') and !ref $json->allow_tags) { + push @simples, 'allow_tags'; + $has_allow_tags = 1; +} + +plan tests => 90 + $has_allow_tags * 7; + +for my $name (@simples) { + my $method = 'get_' . $name; + if ($name eq 'allow_nonref' and $allow_nonref_by_default) { + ok( $json->$method(), $method . ' default'); + } else { + ok(! $json->$method(), $method . ' default'); + } + $json->$name(); + ok($json->$method(), $method . ' set true'); + $json->$name(0); + ok(! $json->$method(), $method . ' set false'); + $json->$name(); + ok($json->$method(), $method . ' set true again'); +} + +ok($json->get_max_depth == 512, 'get_max_depth default'); +$json->max_depth(7); +ok($json->get_max_depth == 7, 'get_max_depth set 7 => 7'); +$json->max_depth(); +ok($json->get_max_depth != 0, 'get_max_depth no arg'); + + +ok($json->get_max_size == 0, 'get_max_size default'); +$json->max_size(7); +ok($json->get_max_size == 7, 'get_max_size set 7 => 7'); +$json->max_size(); +ok($json->get_max_size == 0, 'get_max_size no arg'); + + +for my $name (@simples) { + $json->$name(); + ok($json->property($name), $name); + $json->$name(0); + ok(! $json->property($name), $name); + $json->$name(); + ok($json->property($name), $name); +} + + |