Debian Codegraph @

t/rt_116998_wrong_character_offset.t

raw
1 use strict;
2 use warnings;
3 use Test::More;
4 BEGIN { plan tests => 4 };
5 BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; }
6 use JSON;
7
8 SKIP: { skip "requires $JSON::BackendModule 2.90 or newer", 1 if $JSON::BackendModulePP and eval $JSON::BackendModulePP->VERSION < 2.90;
9 eval { decode_json(qq({"foo":{"bar":42})) };
10 like $@ => qr/offset 17/; # 16
11 }
12
13 eval { decode_json(qq(["foo",{"bar":42})) };
14 like $@ => qr/offset 17/;
15
16 SKIP: { skip "requires $JSON::BackendModule 2.90 or newer", 1 if $JSON::BackendModulePP and eval $JSON::BackendModulePP->VERSION < 2.90;
17 eval { decode_json(qq(["foo",{"bar":42}"])) };
18 like $@ => qr/offset 17/; # 18
19 }
20
21 eval { decode_json(qq({"foo":{"bar":42}"})) };
22 like $@ => qr/offset 17/;
23