OLD | NEW |
(Empty) | |
| 1 # copied over from JSON::PC and modified to use JSON |
| 2 # copied over from JSON::XS and modified to use JSON |
| 3 |
| 4 use Test::More; |
| 5 use strict; |
| 6 BEGIN { plan tests => 8 }; |
| 7 |
| 8 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; } |
| 9 |
| 10 use JSON; |
| 11 |
| 12 ######################### |
| 13 my ($js,$obj); |
| 14 my $pc = new JSON; |
| 15 |
| 16 $js = q|[-12.34]|; |
| 17 $obj = $pc->decode($js); |
| 18 is($obj->[0], -12.34, 'digit -12.34'); |
| 19 $js = $pc->encode($obj); |
| 20 is($js,'[-12.34]', 'digit -12.34'); |
| 21 |
| 22 $js = q|[-1.234e5]|; |
| 23 $obj = $pc->decode($js); |
| 24 is($obj->[0], -123400, 'digit -1.234e5'); |
| 25 $js = $pc->encode($obj); |
| 26 is($js,'[-123400]', 'digit -1.234e5'); |
| 27 |
| 28 $js = q|[1.23E-4]|; |
| 29 $obj = $pc->decode($js); |
| 30 is($obj->[0], 0.000123, 'digit 1.23E-4'); |
| 31 $js = $pc->encode($obj); |
| 32 |
| 33 if ( $js =~ /\[1/ ) { # for 5.6.2 on Darwin 8.10.0 |
| 34 like($js, qr/[1.23[eE]-04]/, 'digit 1.23E-4'); |
| 35 } |
| 36 else { |
| 37 is($js,'[0.000123]', 'digit 1.23E-4'); |
| 38 } |
| 39 |
| 40 |
| 41 |
| 42 $js = q|[1.01e+67]|; # 30 -> 67 ... patched by H.Merijn Brand |
| 43 $obj = $pc->decode($js); |
| 44 is($obj->[0], 1.01e+67, 'digit 1.01e+67'); |
| 45 $js = $pc->encode($obj); |
| 46 like($js,qr/\[1.01[Ee]\+0?67\]/, 'digit 1.01e+67'); |
| 47 |
OLD | NEW |