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

Side by Side Diff: third_party/JSON/JSON-2.59/t/e03_bool2.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/e02_bool.t ('k') | third_party/JSON/JSON-2.59/t/e04_sortby.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 use Test::More;
2
3 BEGIN { plan tests => 26 };
4
5 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
6 use JSON;
7
8 is(to_json([JSON::true]), q|[true]|);
9 is(to_json([JSON::false]), q|[false]|);
10 is(to_json([JSON::null]), q|[null]|);
11
12 my $jsontext = q|[true,false,null]|;
13 my $obj = from_json($jsontext);
14
15 isa_ok($obj->[0], 'JSON::Boolean');
16 isa_ok($obj->[1], 'JSON::Boolean');
17 ok(!defined $obj->[2], 'null is undef');
18
19 ok($obj->[0] == 1);
20 ok($obj->[0] != 0);
21 ok($obj->[1] == 0);
22 ok($obj->[1] != 1);
23
24 ok($obj->[0] eq 'true', 'eq true');
25 ok($obj->[0] ne 'false', 'ne false');
26 ok($obj->[1] eq 'false', 'eq false');
27 ok($obj->[1] ne 'true', 'ne true');
28
29 ok($obj->[0] eq $obj->[0]);
30 ok($obj->[0] ne $obj->[1]);
31
32 ok(JSON::true eq 'true');
33 ok(JSON::true ne 'false');
34 ok(JSON::true ne 'null');
35 ok(JSON::false eq 'false');
36 ok(JSON::false ne 'true');
37 ok(JSON::false ne 'null');
38 ok(!defined JSON::null);
39
40 is(from_json('[true]' )->[0], JSON::true);
41 is(from_json('[false]')->[0], JSON::false);
42 is(from_json('[null]' )->[0], JSON::null);
43
OLDNEW
« no previous file with comments | « third_party/JSON/JSON-2.59/t/e02_bool.t ('k') | third_party/JSON/JSON-2.59/t/e04_sortby.t » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698