summaryrefslogtreecommitdiff
path: root/t/15_prefix.t
diff options
context:
space:
mode:
Diffstat (limited to 't/15_prefix.t')
-rw-r--r--t/15_prefix.t19
1 files changed, 19 insertions, 0 deletions
diff --git a/t/15_prefix.t b/t/15_prefix.t
new file mode 100644
index 0000000..a9c5b2e
--- /dev/null
+++ b/t/15_prefix.t
@@ -0,0 +1,19 @@
+# copied over from JSON::XS and modified to use JSON
+
+use strict;
+use Test::More;
+BEGIN { plan tests => 4 };
+
+BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; }
+
+use JSON;
+
+my $pp = JSON->new->latin1->allow_nonref;
+
+eval { $pp->decode ("[] ") };
+ok (!$@);
+eval { $pp->decode ("[] x") };
+ok ($@);
+ok (2 == ($pp->decode_prefix ("[][]"))[1]);
+ok (3 == ($pp->decode_prefix ("[1] t"))[1]);
+