summaryrefslogtreecommitdiff
path: root/t/09_pc_extra_number.t
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2013-10-31 10:38:22 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2013-10-31 10:38:22 +0000
commite84b6340760ed17a22ced0ca110a94fa8322b35e (patch)
tree4f3deee75d0ae93c776d515c200a40d71cc8a247 /t/09_pc_extra_number.t
downloadJSON-tarball-master.tar.gz
Diffstat (limited to 't/09_pc_extra_number.t')
-rw-r--r--t/09_pc_extra_number.t39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/09_pc_extra_number.t b/t/09_pc_extra_number.t
new file mode 100644
index 0000000..ce60ee5
--- /dev/null
+++ b/t/09_pc_extra_number.t
@@ -0,0 +1,39 @@
+# copied over from JSON::PC and modified to use JSON
+# copied over from JSON::XS and modified to use JSON
+
+use Test::More;
+use strict;
+BEGIN { plan tests => 6 };
+
+BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
+
+use JSON;
+
+
+#########################
+my ($js,$obj);
+my $pc = new JSON;
+
+$js = '{"foo":0}';
+$obj = $pc->decode($js);
+is($obj->{foo}, 0, "normal 0");
+
+$js = '{"foo":0.1}';
+$obj = $pc->decode($js);
+is($obj->{foo}, 0.1, "normal 0.1");
+
+
+$js = '{"foo":10}';
+$obj = $pc->decode($js);
+is($obj->{foo}, 10, "normal 10");
+
+$js = '{"foo":-10}';
+$obj = $pc->decode($js);
+is($obj->{foo}, -10, "normal -10");
+
+
+$js = '{"foo":0, "bar":0.1}';
+$obj = $pc->decode($js);
+is($obj->{foo},0, "normal 0");
+is($obj->{bar},0.1,"normal 0.1");
+