Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: third_party/JSON/JSON-2.59/t/20_unknown.t

Issue 15736030: Add JSON.pm to third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix permissions and shebangs Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/JSON/JSON-2.59/t/19_incr.t ('k') | third_party/JSON/JSON-2.59/t/21_evans_bugrep.t » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 use strict;
3
4 use Test::More;
5 BEGIN { plan tests => 10 };
6 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
7
8
9 use strict;
10 use JSON;
11
12 my $json = JSON->new;
13
14 eval q| $json->encode( [ sub {} ] ) |;
15 ok( $@ =~ /encountered CODE/, $@ );
16
17 eval q| $json->encode( [ \-1 ] ) |;
18 ok( $@ =~ /cannot encode reference to scalar/, $@ );
19
20 eval q| $json->encode( [ \undef ] ) |;
21 ok( $@ =~ /cannot encode reference to scalar/, $@ );
22
23 eval q| $json->encode( [ \{} ] ) |;
24 ok( $@ =~ /cannot encode reference to scalar/, $@ );
25
26 $json->allow_unknown;
27
28 is( $json->encode( [ sub {} ] ), '[null]' );
29 is( $json->encode( [ \-1 ] ), '[null]' );
30 is( $json->encode( [ \undef ] ), '[null]' );
31 is( $json->encode( [ \{} ] ), '[null]' );
32
33
34 SKIP: {
35
36 skip "this test is for Perl 5.8 or later", 2 if( $] < 5.008 );
37
38 $json->allow_unknown(0);
39
40 my $fh;
41 open( $fh, '>hoge.txt' ) or die $!;
42
43 eval q| $json->encode( [ $fh ] ) |;
44 ok( $@ =~ /encountered GLOB/, $@ );
45
46 $json->allow_unknown(1);
47
48 is( $json->encode( [ $fh ] ), '[null]' );
49
50 close $fh;
51
52 unlink('hoge.txt');
53
54 }
OLDNEW
« no previous file with comments | « third_party/JSON/JSON-2.59/t/19_incr.t ('k') | third_party/JSON/JSON-2.59/t/21_evans_bugrep.t » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698