1 | use Test::More; |
1 | use Test::More; |
2 | |
2 | |
3 | # copied over from JSON::PC and modified to use JSON::XS |
3 | # copied over from JSON::PC and modified to use JSON::XS |
4 | |
4 | |
5 | use strict; |
5 | use strict; |
6 | BEGIN { plan tests => 22 }; |
6 | BEGIN { plan tests => 21 }; |
7 | use JSON::XS; |
7 | use JSON::XS; |
8 | |
8 | |
9 | my ($js,$obj); |
9 | my ($js,$obj); |
10 | |
10 | |
11 | my $pc = new JSON::XS; |
11 | my $pc = new JSON::XS; |
… | |
… | |
83 | |
83 | |
84 | $obj = { foo => sub { "bar"; } }; |
84 | $obj = { foo => sub { "bar"; } }; |
85 | eval q{ $js = $pc->encode($obj) }; |
85 | eval q{ $js = $pc->encode($obj) }; |
86 | like($@, qr/JSON can only/i, 'invalid value (coderef)'); |
86 | like($@, qr/JSON can only/i, 'invalid value (coderef)'); |
87 | |
87 | |
88 | |
|
|
89 | $obj = { foo => *STDERR }; |
|
|
90 | $js = $pc->encode($obj); |
|
|
91 | is($js, '{"foo":"*main::STDERR"}', "type blog"); |
|
|
92 | |
|
|
93 | $obj = { foo => \*STDERR }; |
88 | $obj = { foo => \*STDERR }; |
94 | eval q{ $js = $pc->encode($obj) }; |
89 | eval q{ $js = $pc->encode($obj) }; |
95 | like($@, qr/JSON can only/i, 'invalid value (ref of type blog)'); |
90 | like($@, qr/JSON can only/i, 'invalid value (ref of type blog)'); |
96 | |
91 | |
97 | #$obj = { foo => bless {}, "Hoge" }; |
92 | #$obj = { foo => bless {}, "Hoge" }; |