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
|
|
@ -68,7 +68,6 @@ my @errors = (
|
|||
do { my $o = {}; bless $o, 'MyToJSONSelf' }, qr/MyToJSONSelf::TO_JSON method returned same object as was passed instead of a new one/,
|
||||
);
|
||||
|
||||
plan tests => @tests*2 + @errors/2 + 10;
|
||||
|
||||
for my($in, $exp) (@tests) {
|
||||
my $out = json_format $in;
|
||||
|
|
@ -120,6 +119,25 @@ eval { json_format 'hello world', max_size => 8 };
|
|||
like $@, qr/maximum string length exceeded/;
|
||||
|
||||
|
||||
# Test large strings to cover some buffer handling special cases.
|
||||
for (2000..2100, 4000..4200, 8100..8200, 12200..12300, 16300..16400) {
|
||||
my $s = 'a'x$_;
|
||||
is json_format($s), "\"$s\"";
|
||||
}
|
||||
|
||||
# 500 depth
|
||||
{
|
||||
my $v = 1;
|
||||
$v = [$v] for (1..500);
|
||||
is json_format($v), '['x500 . 1 . ']'x500;
|
||||
}
|
||||
{
|
||||
my $v = 1;
|
||||
$v = {'',$v} for (1..500);
|
||||
is json_format($v), '{"":'x500 . 1 . '}'x500;
|
||||
}
|
||||
|
||||
|
||||
# http://e-choroba.eu/18-yapc slide 6
|
||||
|
||||
tie my $incs, 'MyIncrementer', 'Xa';
|
||||
|
|
@ -132,6 +150,9 @@ is json_format($incu), 4;
|
|||
is json_format($incu), 5;
|
||||
is json_format($incu), 6;
|
||||
|
||||
|
||||
done_testing;
|
||||
|
||||
package MyIncrementer;
|
||||
use Tie::Scalar;
|
||||
use parent -norequire => 'Tie::StdScalar';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue