From 12442c5e6e0ad585b1c3337eb06fd72ce7f9b357 Mon Sep 17 00:00:00 2001 From: Slaven Rezic Date: Sun, 2 Dec 2018 11:02:13 +0100 Subject: [PATCH] fix tests for JSON::XS 4.0 (RT #127741) --- t/x02_error.t | 9 +++++++-- t/xe20_croak_message.t | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/t/x02_error.t b/t/x02_error.t index 336674d..e82cc47 100644 --- a/t/x02_error.t +++ b/t/x02_error.t @@ -1,6 +1,6 @@ use strict; use Test::More; -BEGIN { plan tests => 31 }; +BEGIN { plan tests => 32 }; BEGIN { $ENV{PERL_JSON_BACKEND} ||= 1; } @@ -28,7 +28,12 @@ eval { JSON->new->allow_nonref (1)->decode ('"\u1234\udc00"') }; ok $@ =~ /missi eval { JSON->new->allow_nonref->decode ('"\ud800"') }; ok $@ =~ /missing low /; eval { JSON->new->allow_nonref (1)->decode ('"\ud800\u1234"') }; ok $@ =~ /surrogate pair /; -eval { JSON->new->decode ('null') }; ok $@ =~ /allow_nonref/; +eval { JSON->new->allow_nonref (0)->decode ('null') }; ok $@ =~ /allow_nonref/; +SKIP: { + skip "test only for older JSON::XS (< 4.0)", 1 + if ($JSON::BackendModule ne 'JSON::XS' || $JSON::XS::VERSION >= 4.0); + eval { JSON->new->decode ('null') }; ok $@ =~ /allow_nonref/; +} eval { JSON->new->allow_nonref (1)->decode ('+0') }; ok $@ =~ /malformed/; eval { JSON->new->allow_nonref->decode ('.2') }; ok $@ =~ /malformed/; eval { JSON->new->allow_nonref (1)->decode ('bare') }; ok $@ =~ /malformed/; diff --git a/t/xe20_croak_message.t b/t/xe20_croak_message.t index 88888ad..65f2ea3 100644 --- a/t/xe20_croak_message.t +++ b/t/xe20_croak_message.t @@ -13,7 +13,7 @@ use JSON -support_by_pp; SKIP: { skip "can't use JSON::XS.", 1, unless( JSON->backend->is_xs ); - my $json = JSON->new; + my $json = JSON->new->allow_nonref(0); eval q{ $json->encode( undef ) }; like( $@, qr/line 1\./ ); -- 2.1.4