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

Unified Diff: third_party/JSON/JSON-2.59/t/xe03_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/JSON/JSON-2.59/t/xe02_bool.t ('k') | third_party/JSON/JSON-2.59/t/xe04support_by_pp.t » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/JSON/JSON-2.59/t/xe03_bool2.t
diff --git a/third_party/JSON/JSON-2.59/t/xe03_bool2.t b/third_party/JSON/JSON-2.59/t/xe03_bool2.t
new file mode 100644
index 0000000000000000000000000000000000000000..7d68b32d9b0e416a56af75443e9a7104a347fcfa
--- /dev/null
+++ b/third_party/JSON/JSON-2.59/t/xe03_bool2.t
@@ -0,0 +1,47 @@
+use Test::More;
+
+BEGIN { plan tests => 26 };
+
+BEGIN { $ENV{PERL_JSON_BACKEND} = 1; }
+use JSON;
+
+SKIP: {
+ skip "can't use JSON::XS.", 26, unless( JSON->backend->is_xs );
+
+is(to_json([JSON::true]), q|[true]|);
+is(to_json([JSON::false]), q|[false]|);
+is(to_json([JSON::null]), q|[null]|);
+
+my $jsontext = q|[true,false,null]|;
+my $obj = from_json($jsontext);
+
+isa_ok($obj->[0], 'JSON::Boolean');
+isa_ok($obj->[1], 'JSON::Boolean');
+ok(!defined $obj->[2], 'null is undef');
+
+ok($obj->[0] == 1);
+ok($obj->[0] != 0);
+ok($obj->[1] == 0);
+ok($obj->[1] != 1);
+
+ok($obj->[0] eq 'true', 'eq true');
+ok($obj->[0] ne 'false', 'ne false');
+ok($obj->[1] eq 'false', 'eq false');
+ok($obj->[1] ne 'true', 'ne true');
+
+ok($obj->[0] eq $obj->[0]);
+ok($obj->[0] ne $obj->[1]);
+
+ok(JSON::true eq 'true');
+ok(JSON::true ne 'false');
+ok(JSON::true ne 'null');
+ok(JSON::false eq 'false');
+ok(JSON::false ne 'true');
+ok(JSON::false ne 'null');
+ok(!defined JSON::null);
+
+is(from_json('[true]' )->[0], JSON::true);
+is(from_json('[false]')->[0], JSON::false);
+is(from_json('[null]' )->[0], JSON::null);
+
+}
« no previous file with comments | « third_party/JSON/JSON-2.59/t/xe02_bool.t ('k') | third_party/JSON/JSON-2.59/t/xe04support_by_pp.t » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698