1 |
root |
1.1 |
BEGIN { $| = 1; print "1..7\n"; } |
2 |
|
|
|
3 |
|
|
use JSON::XS; |
4 |
|
|
|
5 |
|
|
our $test; |
6 |
|
|
sub ok($;$) { |
7 |
|
|
print $_[0] ? "" : "not ", "ok ", ++$test, "\n"; |
8 |
|
|
} |
9 |
|
|
|
10 |
|
|
my $js = JSON::XS->new; |
11 |
|
|
|
12 |
root |
1.3 |
ok (ref $js->decode (("[" x 512) . ("]" x 512))); |
13 |
|
|
ok (ref $js->decode (("{\"\":" x 511) . "[]" . ("}" x 511))); |
14 |
root |
1.1 |
ok (ref $js->max_depth (32)->decode (("[" x 32) . ("]" x 32))); |
15 |
|
|
|
16 |
|
|
ok ($js->max_depth(1)->encode ([])); |
17 |
|
|
ok (!eval { $js->encode ([[]]), 1 }); |
18 |
|
|
|
19 |
|
|
ok ($js->max_depth(2)->encode ([{}])); |
20 |
|
|
ok (!eval { $js->encode ([[{}]]), 1 }); |
21 |
|
|
|