Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #40292] [TODO] Add JSON tests

2 views
Skip to first unread message

Will Coleda

unread,
Sep 7, 2006, 12:30:37 AM9/7/06
to bugs-bi...@rt.perl.org
# New Ticket Created by Will Coleda
# Please include the string: [perl #40292]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40292 >


There is now a "JSON" compiler: perldoc compilers/json/JSON.pir

We need more tests (t/compilers/json/to_parrot.t) that test the
_dumper() output of a PMC generated by converting from a JSON string.

E.g.:

""

Would convert to an empty string, which would then be dumped as:

"JSON" => ""

See http://www.json.org/ for a description of the JSON grammar: all
elements of that grammar should be tested.

For failing tests, TODO them, and I'll be happy to fix the compiler.
Unless you beat me to it, which is fine.

As of the opening of this ticket, expect arrays and objects to fail
(need TGE support), true/false/null to work, and strings & numbers to
partially work.

Regards.

--
Will "Coke" Coleda
wi...@coleda.com


Will Coleda via RT

unread,
Sep 8, 2006, 12:20:55 PM9/8/06
to perl6-i...@perl.org
Thanks, applied, along with the previous patch.

Nuno Carvalho

unread,
Sep 15, 2006, 8:53:06 AM9/15/06
to perl6-i...@perl.org
Hi again,

Added some more simple tests to file 't/compilers/json/to_parrot.t'
related to backslashing testing. All the new tests pass. Attached to
this message you can find the patch file.

Best regards,
./smash

to_parrot.t.patch

Nuno Carvalho

unread,
Sep 15, 2006, 9:06:34 AM9/15/06
to perl6-i...@perl.org
Hi again,

Sorry, there was a problem with the last diff. Here's the most updated
patch, attached to this file, please igore the previous patch. Sorry
again.

Best regards,
./smash

to_parrot.t.patch

Will Coleda

unread,
Sep 15, 2006, 9:14:08 AM9/15/06
to parrotbug...@parrotcode.org
Thanks, applied, with one minor tweak.

> Index: t/compilers/json/to_parrot.t
> ===================================================================
> --- t/compilers/json/to_parrot.t (revision 14622)
> +++ t/compilers/json/to_parrot.t (working copy)
> @@ -6,7 +6,7 @@
> use lib qw( t . lib ../lib ../../lib );
>
> use Test::More;
> -use Parrot::Test tests => 52;
> +use Parrot::Test tests => 60;
>
> =head1 NAME
>
> @@ -34,6 +34,56 @@
> "JSON" => "json"
> OUT
>
> +json_isnt('a', 'strings need quotes');
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash "');
> +"\"json\""
> +JSON
> +"JSON" => "\"json\""
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash \\');
> +"\\json\\"
> +JSON
> +"JSON" => "\\json\\"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with / (no backslash
> required)');
> +"/json/"
> +JSON
> +"JSON" => "/json/"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash b');
> +"\bjson\b"
> +JSON
> +"JSON" => "\bjson\b"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash f');
> +"\fjson\f"
> +JSON
> +"JSON" => "\fjson\f"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash n');
> +"\njson\n"
> +JSON
> +"JSON" => "\njson\n"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash r');
> +"\rjson\r"
> +JSON
> +"JSON" => "\rjson\r"
> +OUT
> +
> +json_dump_is(<<'JSON', <<'OUT', 'string with backslash t');
> +"\tjson\t"
> +JSON
> +"JSON" => "\tjson\t"
> +OUT
> +
> json_dump_is(<<'JSON', <<'OUT', 'number int');
> 1
> JSON
> @@ -628,7 +678,6 @@
> ]
> OUT
>
> -json_isnt('a', 'strings need quotes');
>
> # XXX Need many more tests, exercising all aspects of http://
> www.json.org/

0 new messages