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