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

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

Issue 16539003: Revert 205057 "Add JSON.pm to third_party" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
OLDNEW
(Empty)
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use Test::More;
6 BEGIN { plan tests => 10 };
7 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
8
9
10 use strict;
11 use JSON;
12
13 my $json = JSON->new;
14
15 eval q| $json->encode( [ sub {} ] ) |;
16 ok( $@ =~ /encountered CODE/, $@ );
17
18 eval q| $json->encode( [ \-1 ] ) |;
19 ok( $@ =~ /cannot encode reference to scalar/, $@ );
20
21 eval q| $json->encode( [ \undef ] ) |;
22 ok( $@ =~ /cannot encode reference to scalar/, $@ );
23
24 eval q| $json->encode( [ \{} ] ) |;
25 ok( $@ =~ /cannot encode reference to scalar/, $@ );
26
27 $json->allow_unknown;
28
29 is( $json->encode( [ sub {} ] ), '[null]' );
30 is( $json->encode( [ \-1 ] ), '[null]' );
31 is( $json->encode( [ \undef ] ), '[null]' );
32 is( $json->encode( [ \{} ] ), '[null]' );
33
34
35 SKIP: {
36
37 skip "this test is for Perl 5.8 or later", 2 if( $] < 5.008 );
38
39 $json->allow_unknown(0);
40
41 my $fh;
42 open( $fh, '>hoge.txt' ) or die $!;
43
44 eval q| $json->encode( [ $fh ] ) |;
45 ok( $@ =~ /encountered GLOB/, $@ );
46
47 $json->allow_unknown(1);
48
49 is( $json->encode( [ $fh ] ), '[null]' );
50
51 close $fh;
52
53 unlink('hoge.txt');
54
55 }
OLDNEW
« no previous file with comments | « trunk/src/third_party/JSON/JSON-2.59/t/19_incr.t ('k') | trunk/src/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