"Fossies" - the Fresh Open Source Software Archive

Member "perl-5.32.1/cpan/JSON-PP/t/009_pc_extra_number.t" (18 Dec 2020, 752 Bytes) of package /linux/misc/perl-5.32.1.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # copied over from JSON::PC and modified to use JSON::PP
    2 # copied over from JSON::XS and modified to use JSON::PP
    3 
    4 use Test::More;
    5 use strict;
    6 BEGIN { plan tests => 6 };
    7 BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }
    8 
    9 use JSON::PP;
   10 use utf8;
   11 
   12 #########################
   13 my ($js,$obj);
   14 my $pc = new JSON::PP;
   15 
   16 $js  = '{"foo":0}';
   17 $obj = $pc->decode($js);
   18 is($obj->{foo}, 0, "normal 0");
   19 
   20 $js  = '{"foo":0.1}';
   21 $obj = $pc->decode($js);
   22 is($obj->{foo}, 0.1, "normal 0.1");
   23 
   24 
   25 $js  = '{"foo":10}';
   26 $obj = $pc->decode($js);
   27 is($obj->{foo}, 10, "normal 10");
   28 
   29 $js  = '{"foo":-10}';
   30 $obj = $pc->decode($js);
   31 is($obj->{foo}, -10, "normal -10");
   32 
   33 
   34 $js  = '{"foo":0, "bar":0.1}';
   35 $obj = $pc->decode($js);
   36 is($obj->{foo},0,  "normal 0");
   37 is($obj->{bar},0.1,"normal 0.1");
   38