diff --git a/t/xe01_property.t b/t/xe01_property.t deleted file mode 100644 index 6b894cd..0000000 --- a/t/xe01_property.t +++ /dev/null @@ -1,56 +0,0 @@ - -use Test::More; -use strict; - -BEGIN { plan tests => 90 }; - -BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } - - -use JSON; - -SKIP: { - skip "can't use JSON::XS.", 90, unless( JSON->backend->is_xs ); - -my @simples = - qw/ascii latin1 utf8 indent canonical space_before space_after allow_nonref shrink allow_blessed - convert_blessed relaxed - /; - -my $json = new JSON; - -for my $name (@simples) { - my $method = 'get_' . $name; - ok(! $json->$method(), $method . ' default'); - $json->$name(); - ok($json->$method(), $method . ' set true'); - $json->$name(0); - ok(! $json->$method(), $method . ' set false'); - $json->$name(); - ok($json->$method(), $method . ' set true again'); -} - - -ok($json->get_max_depth == 512, 'get_max_depth default'); -$json->max_depth(7); -ok($json->get_max_depth == 7, 'get_max_depth set 7 => 7'); -$json->max_depth(); -ok($json->get_max_depth != 0, 'get_max_depth no arg'); - -ok($json->get_max_size == 0, 'get_max_size default'); -$json->max_size(7); -ok($json->get_max_size == 7, 'get_max_size set 7 => 7'); -$json->max_size(); -ok($json->get_max_size == 0, 'get_max_size no arg'); - - -for my $name (@simples) { - $json->$name(); - ok($json->property($name), $name); - $json->$name(0); - ok(! $json->property($name), $name); - $json->$name(); - ok($json->property($name), $name); -} - -} diff --git a/t/xe02_bool.t b/t/xe02_bool.t deleted file mode 100644 index 1f0ddae..0000000 --- a/t/xe02_bool.t +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/perl -w - -use strict; - -use Test::More; -use strict; - -BEGIN { plan tests => 11 }; - -BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } - -use JSON; - -SKIP: { - skip "can't use JSON::XS.", 11, unless( JSON->backend->is_xs ); - -my $json = new JSON; - -is($json->encode([!1]), '[""]'); -is($json->encode([!!2]), '["1"]'); - -is($json->encode([ 'a' eq 'b' ]), '[""]'); -is($json->encode([ 'a' eq 'a' ]), '["1"]'); - -is($json->encode([ ('a' eq 'b') + 1 ]), '[1]'); -is($json->encode([ ('a' eq 'a') + 1 ]), '[2]'); - -ok(JSON::true eq 'true'); -ok(JSON::true eq '1'); -ok(JSON::true == 1); -isa_ok(JSON::true, JSON->backend . '::Boolean'); -isa_ok(JSON::true, 'JSON::Boolean'); - -} diff --git a/t/xe03_bool2.t b/t/xe03_bool2.t deleted file mode 100644 index 7d68b32..0000000 --- a/t/xe03_bool2.t +++ /dev/null @@ -1,47 +0,0 @@ -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); - -} diff --git a/t/xe04support_by_pp.t b/t/xe04support_by_pp.t deleted file mode 100644 index f8c8873..0000000 --- a/t/xe04support_by_pp.t +++ /dev/null @@ -1,22 +0,0 @@ -use strict; -use Test::More; -BEGIN { plan tests => 3 }; - -BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } - -use JSON -support_by_pp; - -SKIP: { - skip "can't use JSON::XS.", 3, unless( JSON->backend->is_xs ); - -my $json = new JSON; - - -is($json->escape_slash(0)->allow_nonref->encode("/"), '"/"'); -is($json->escape_slash(1)->allow_nonref->encode("/"), '"\/"'); -is($json->escape_slash(0)->allow_nonref->encode("/"), '"/"'); - - -} -__END__ - diff --git a/t/xe05_indent_length.t b/t/xe05_indent_length.t deleted file mode 100644 index fc28fa3..0000000 --- a/t/xe05_indent_length.t +++ /dev/null @@ -1,76 +0,0 @@ -use strict; -use Test::More; -BEGIN { plan tests => 7 }; - -BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } - -use JSON -support_by_pp; - -SKIP: { - skip "can't use JSON::XS.", 7, unless( JSON->backend->is_xs ); - -my $json = new JSON; - - -is($json->indent_length(2)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[1,{"foo":"bar"},"1","/"]|); - -is($json->indent->encode([1,{foo => 'bar'}, "1", "/"]), qq|[ - 1, - { - "foo":"bar" - }, - "1", - "/" -] -|); - - -is($json->escape_slash(1)->pretty->indent_length(2)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[ - 1, - { - "foo" : "bar" - }, - "1", - "\\/" -] -|); - - -is($json->escape_slash(1)->pretty->indent_length(3)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[ - 1, - { - "foo" : "bar" - }, - "1", - "\\/" -] -|); - -is($json->escape_slash(1)->pretty->indent_length(15)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[ - 1, - { - "foo" : "bar" - }, - "1", - "\\/" -] -|); - - -is($json->indent_length(0)->encode([1,{foo => 'bar'}, "1", "/"]), qq|[ -1, -{ -"foo" : "bar" -}, -"1", -"\\/" -] -|); - -is($json->indent(0)->space_before(0)->space_after(0)->escape_slash(0) - ->encode([1,{foo => 'bar'}, "1", "/"]), qq|[1,{"foo":"bar"},"1","/"]|); - - -} - - diff --git a/t/xe08_decode.t b/t/xe08_decode.t deleted file mode 100644 index ed78fbb..0000000 --- a/t/xe08_decode.t +++ /dev/null @@ -1,45 +0,0 @@ -# -# decode on Perl 5.005, 5.6, 5.8 or later -# -use strict; -use Test::More; - -BEGIN { plan tests => 6 }; - -BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } - -use JSON; - -BEGIN { - use lib qw(t); - use _unicode_handling; -} - -no utf8; - -SKIP: { - skip "can't use JSON::XS.", 6, unless( JSON->backend->is_xs ); - -my $json = JSON->new->allow_nonref; - - -is($json->decode(q|"ü"|), "ü"); # utf8 -is($json->decode(q|"\u00fc"|), "\xfc"); # latin1 -is($json->decode(q|"\u00c3\u00bc"|), "\xc3\xbc"); # utf8 - -my $str = 'あ'; # Japanese 'a' in utf8 - -is($json->decode(q|"\u00e3\u0081\u0082"|), $str); - -utf8::decode($str); # usually UTF-8 flagged on, but no-op for 5.005. - -is($json->decode(q|"\u3042"|), $str); - - -my $utf8 = $json->decode(q|"\ud808\udf45"|); # chr 12345 - -utf8::encode($utf8); # UTf-8 flaged off - -is($utf8, "\xf0\x92\x8d\x85"); - -} diff --git a/t/xe10_bignum.t b/t/xe10_bignum.t deleted file mode 100644 index d72b8ad..0000000 --- a/t/xe10_bignum.t +++ /dev/null @@ -1,36 +0,0 @@ - -use strict; -use Test::More; -BEGIN { plan tests => 6 }; - -BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } - -use JSON -support_by_pp; - -eval q| require Math::BigInt |; - - -SKIP: { - skip "can't use JSON::XS.", 6, unless( JSON->backend->is_xs ); - skip "Can't load Math::BigInt.", 6 if ($@); - -my $json = new JSON; -print $json->backend, "\n"; - -$json->allow_nonref->allow_bignum(1); -$json->convert_blessed->allow_blessed; - -my $num = $json->decode(q|100000000000000000000000000000000000000|); - -isa_ok($num, 'Math::BigInt'); -is($num, '100000000000000000000000000000000000000'); -is($json->encode($num), '100000000000000000000000000000000000000'); - -$num = $json->decode(q|2.0000000000000000001|); - -isa_ok($num, 'Math::BigFloat'); -is($num, '2.0000000000000000001'); -is($json->encode($num), '2.0000000000000000001'); - - -} diff --git a/t/xe11_conv_blessed_univ.t b/t/xe11_conv_blessed_univ.t deleted file mode 100644 index 8ccc0c1..0000000 --- a/t/xe11_conv_blessed_univ.t +++ /dev/null @@ -1,48 +0,0 @@ - -use strict; -use Test::More; -BEGIN { plan tests => 3 }; - -BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } - -use JSON -convert_blessed_universally; - -SKIP: { - skip "can't use JSON::XS.", 3, unless( JSON->backend->is_xs ); - -my $obj = Test->new( [ 1, 2, {foo => 'bar'} ] ); - -$obj->[3] = Test2->new( { a => 'b' } ); - -my $json = JSON->new->allow_blessed->convert_blessed; - -is( $json->encode( $obj ), '[1,2,{"foo":"bar"},"hoge"]' ); - -$json->convert_blessed(0); - -is( $json->encode( $obj ), 'null' ); - -$json->allow_blessed(0)->convert_blessed(1); - -is( $json->encode( $obj ), '[1,2,{"foo":"bar"},"hoge"]' ); - -} - -package Test; - -sub new { - bless $_[1], $_[0]; -} - - - -package Test2; - -sub new { - bless $_[1], $_[0]; -} - -sub TO_JSON { - "hoge"; -} - diff --git a/t/xe12_boolean.t b/t/xe12_boolean.t deleted file mode 100644 index 1d790d5..0000000 --- a/t/xe12_boolean.t +++ /dev/null @@ -1,35 +0,0 @@ - -use strict; -use Test::More; - -BEGIN { plan tests => 4 }; - -BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } - -use JSON -support_by_pp; - -BEGIN { - use lib qw(t); - use _unicode_handling; -} - - -SKIP: { - skip "can't use JSON::XS.", 4, unless( JSON->backend->is_xs ); - -my $json = new JSON; -my $bool = $json->allow_nonref->decode('true'); - -# it's normal -isa_ok( $bool, 'JSON::Boolean' ); -is( $json->encode([ JSON::true ]), '[true]' ); - -# make XS non support flag enable! -$bool = $json->allow_singlequote->decode('true'); - -isa_ok( $bool, 'JSON::Boolean' ); -is( $json->encode([ JSON::true ]), '[true]' ); - -} - -__END__ diff --git a/t/xe19_xs_and_suportbypp.t b/t/xe19_xs_and_suportbypp.t deleted file mode 100644 index f8ed824..0000000 --- a/t/xe19_xs_and_suportbypp.t +++ /dev/null @@ -1,34 +0,0 @@ -#! perl - -# https://rt.cpan.org/Public/Bug/Display.html?id=52847 - -use strict; -use Test::More; - -BEGIN { plan tests => 2 }; -BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } - -use JSON -support_by_pp; - -SKIP: { - skip "can't use JSON::XS.", 2, unless( JSON->backend->is_xs ); - - my $json = JSON->new->allow_barekey; - - for (1..2) { - is_deeply( test($json, q!{foo:"foo"}! ), {foo=>'foo'} ); - JSON->new->allow_singlequote(0); - } -} - - -sub test { - my ($coder, $str) = @_; - my $rv; - return $rv if eval { $rv = $coder->decode($str); 1 }; - chomp( my $e = $@ ); - return "died with \"$e\""; -}; - - - diff --git a/t/xe20_croak_message.t b/t/xe20_croak_message.t deleted file mode 100644 index 07ea8e6..0000000 --- a/t/xe20_croak_message.t +++ /dev/null @@ -1,22 +0,0 @@ -#! perl - -# https://rt.cpan.org/Public/Bug/Display.html?id=61708 - -use strict; -use Test::More; - -BEGIN { plan tests => 1 }; -BEGIN { $ENV{PERL_JSON_BACKEND} = 1; } - -use JSON; # currently it can't pass with -support_by_pp; - - -SKIP: { - skip "can't use JSON::XS.", 1, unless( JSON->backend->is_xs ); - - my $json = JSON->new; - - eval q{ $json->encode( undef ) }; - like( $@, qr/line 1\./ ); -} -