Add some tests and move some docs
This commit is contained in:
parent
ebe84167e7
commit
abfbba3c10
7 changed files with 179 additions and 129 deletions
|
|
@ -137,7 +137,7 @@ is ref $v, 'HASH';
|
|||
is keys %$v, 1;
|
||||
is $v->{a}, 1;
|
||||
|
||||
sub large($s) {
|
||||
sub complete($s) {
|
||||
$v = json_parse $s;
|
||||
is ref $v, 'HASH';
|
||||
is keys %$v, 3;
|
||||
|
|
@ -163,11 +163,32 @@ sub large($s) {
|
|||
is ref $v->{'ë'}, 'ARRAY';
|
||||
is scalar $v->{'ë'}->@*, 0;
|
||||
}
|
||||
large '{"a":[1,0.1,true,null,{}],"":-0,"ë":[]}';
|
||||
large ' {
|
||||
complete '{"a":[1,0.1,true,null,{}],"":-0,"ë":[]}';
|
||||
complete ' {
|
||||
"a" : [ 1 , 0.1 , true , null , { } ] ,
|
||||
"" : -0 ,
|
||||
"ë" : [ ]
|
||||
} ';
|
||||
|
||||
|
||||
# Test large inputs to cover some buffer handling special cases.
|
||||
for (2000..2100, 4000..4200, 8100..8200, 12200..12300, 16300..16400) {
|
||||
my $s = 'a'x$_;
|
||||
is json_parse("\"$s\""), $s
|
||||
}
|
||||
|
||||
# 500 depth
|
||||
{
|
||||
$v = json_parse('['x500 . ']'x500);
|
||||
my $i = 0;
|
||||
while (ref $v) { $v = $v->[0]; $i++ }
|
||||
is $i, 500;
|
||||
}
|
||||
{
|
||||
$v = json_parse('{"":'x500 . 1 . '}'x500);
|
||||
my $i = 0;
|
||||
while (ref $v) { $v = $v->{''}; $i++ }
|
||||
is $i, 500;
|
||||
}
|
||||
|
||||
done_testing;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue