Sha256: 58d2b12c7f3a08dc458d4a414bfd61d795169c37cb29590bd503a4c88f0301f6

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

#! /usr/bin/env escript

main([]) ->
    code:add_pathz("ebin/"),
    check_good(),
    check_errors().

check_good() ->
    lists:map(fun
        ({J, E}) ->
             E = ejson:decode(J),
            J = ejson:encode(E);
        ({J, E, J2}) ->
            E = ejson:decode(J),
            J2 = ejson:encode(E)
        end,
    good()).

check_errors() ->
    lists:map(fun(E) ->
        ok = case (catch ejson:decode(E)) of
            {invalid_json, _} -> ok;
            Error ->
                io:format("Error: ~p~n", [E]),
                Error
        end
    end, errors()).

good() ->
    [
        {<<"[]">>, []},
        {<<"[\t[\n]\r]">>, [[]], <<"[[]]">>},
        {<<"[\t123, \r true\n]">>, [123, true], <<"[123,true]">>},
        {<<"[1,\"foo\"]">>, [1, <<"foo">>]},
        {<<"[1199344435545.0,1]">>, [1199344435545.0,1]},
        {<<"[\"\\u00A1\",\"\\u00FC\"]">>, [<<194, 161>>, <<195, 188>>]}
    ].

errors() ->
    [
        <<"[">>,
        <<"]">>,
        <<"[,]">>,
        <<"[123">>,
        <<"[123,]">>,
        <<"[32 true]">>
    ].

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capricorn-2.0.11 erlang/lib/ejson/test/arrays.escript
capricorn-2.0.10 erlang/lib/ejson/test/arrays.escript
capricorn-2.0.9 erlang/lib/ejson/test/arrays.escript