Properly route WebView input events to the compositor
[chromium-blink-merge.git] / third_party / JSON / JSON-2.59 / t / 20_unknown.t
blob8bc81cbf1161bd9bf91974375cdc199965b0ed34
1 #!/usr/bin/perl -w
3 use strict;
5 use Test::More;
6 BEGIN { plan tests => 10 };
7 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
10 use strict;
11 use JSON;
13 my $json = JSON->new;
15 eval q| $json->encode( [ sub {} ] ) |;
16 ok( $@ =~ /encountered CODE/, $@ );
18 eval q| $json->encode( [ \-1 ] ) |;
19 ok( $@ =~ /cannot encode reference to scalar/, $@ );
21 eval q| $json->encode( [ \undef ] ) |;
22 ok( $@ =~ /cannot encode reference to scalar/, $@ );
24 eval q| $json->encode( [ \{} ] ) |;
25 ok( $@ =~ /cannot encode reference to scalar/, $@ );
27 $json->allow_unknown;
29 is( $json->encode( [ sub {} ] ), '[null]' );
30 is( $json->encode( [ \-1 ] ), '[null]' );
31 is( $json->encode( [ \undef ] ), '[null]' );
32 is( $json->encode( [ \{} ] ), '[null]' );
35 SKIP: {
37 skip "this test is for Perl 5.8 or later", 2 if( $] < 5.008 );
39 $json->allow_unknown(0);
41 my $fh;
42 open( $fh, '>hoge.txt' ) or die $!;
44 eval q| $json->encode( [ $fh ] ) |;
45 ok( $@ =~ /encountered GLOB/, $@ );
47 $json->allow_unknown(1);
49 is( $json->encode( [ $fh ] ), '[null]' );
51 close $fh;
53 unlink('hoge.txt');