summaryrefslogtreecommitdiff
path: root/cpan/JSON-PP/t/107_allow_singlequote.t
diff options
context:
space:
mode:
Diffstat (limited to 'cpan/JSON-PP/t/107_allow_singlequote.t')
-rw-r--r--cpan/JSON-PP/t/107_allow_singlequote.t20
1 files changed, 20 insertions, 0 deletions
diff --git a/cpan/JSON-PP/t/107_allow_singlequote.t b/cpan/JSON-PP/t/107_allow_singlequote.t
new file mode 100644
index 0000000000..217caba5a9
--- /dev/null
+++ b/cpan/JSON-PP/t/107_allow_singlequote.t
@@ -0,0 +1,20 @@
+
+use Test::More;
+use strict;
+BEGIN { plan tests => 4 };
+BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }
+use JSON::PP;
+#########################
+
+my $json = JSON::PP->new->allow_nonref;
+
+eval q| $json->decode("{'foo':'bar'}") |;
+
+ok($@); # in XS and PP, the error message differs.
+
+$json->allow_singlequote;
+
+is($json->decode(q|{'foo':"bar"}|)->{foo}, 'bar');
+is($json->decode(q|{'foo':'bar'}|)->{foo}, 'bar');
+is($json->allow_barekey->decode(q|{foo:'bar'}|)->{foo}, 'bar');
+