Blame t/117_numbers.t

Packit a557cb
use Test::More;
Packit a557cb
use strict;
Packit a557cb
BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; }
Packit a557cb
use JSON;
Packit a557cb
Packit a557cb
BEGIN { plan skip_all => "requires $JSON::BackendModule 2.90 or newer" if JSON->backend->is_pp and eval $JSON::BackendModule->VERSION < 2.90 }
Packit a557cb
BEGIN { plan skip_all => "not for $JSON::BackendModule" if $JSON::BackendModule eq 'JSON::XS' }
Packit a557cb
Packit a557cb
BEGIN { plan tests => 3 }
Packit a557cb
Packit a557cb
# TODO ("inf"/"nan" representations are not portable)
Packit a557cb
# is encode_json([9**9**9]), '["inf"]';
Packit a557cb
# is encode_json([-sin(9**9**9)]), '["nan"]';
Packit a557cb
Packit a557cb
my $num = 3;
Packit a557cb
my $str = "$num";
Packit a557cb
is encode_json({test => [$num, $str]}), '{"test":[3,"3"]}';
Packit a557cb
$num = 3.21;
Packit a557cb
$str = "$num";
Packit a557cb
is encode_json({test => [$num, $str]}), '{"test":[3.21,"3.21"]}';
Packit a557cb
$str = '0 but true';
Packit a557cb
$num = 1 + $str;
Packit a557cb
is encode_json({test => [$num, $str]}), '{"test":[1,"0 but true"]}';