GitHub Merge Button 13 anni fa
parent
commit
cfeeb4c39c
91 ha cambiato i file con 132 aggiunte e 15 eliminazioni
  1. +3
    -0
      .gitignore
  2. +9
    -3
      Makefile
  3. BIN
      rebar
  4. +7
    -0
      rebar.config
  5. +104
    -0
      test/proper_tests.erl
  6. +2
    -2
      test_etap/001-yajl-tests.t
  7. +1
    -3
      test_etap/002-literals.t
  8. +1
    -1
      test_etap/003-numbers.t
  9. +1
    -1
      test_etap/004-strings.t
  10. +1
    -1
      test_etap/005-arrays.t
  11. +1
    -1
      test_etap/006-maps.t
  12. +1
    -1
      test_etap/007-compound.t
  13. +1
    -2
      test_etap/008-halfword.t
  14. +0
    -0
      test_etap/cases/array.erl
  15. +0
    -0
      test_etap/cases/array.json
  16. +0
    -0
      test_etap/cases/array_close.erl
  17. +0
    -0
      test_etap/cases/array_close.json
  18. +0
    -0
      test_etap/cases/array_open.erl
  19. +0
    -0
      test_etap/cases/array_open.json
  20. +0
    -0
      test_etap/cases/bogus_char.erl
  21. +0
    -0
      test_etap/cases/bogus_char.json
  22. +0
    -0
      test_etap/cases/codepoints_from_unicode_org.erl
  23. +0
    -0
      test_etap/cases/codepoints_from_unicode_org.json
  24. +0
    -0
      test_etap/cases/deep_arrays.erl
  25. +0
    -0
      test_etap/cases/deep_arrays.json
  26. +0
    -0
      test_etap/cases/difficult_json_c_test_case.erl
  27. +0
    -0
      test_etap/cases/difficult_json_c_test_case.json
  28. +0
    -0
      test_etap/cases/doubles.erl
  29. +0
    -0
      test_etap/cases/doubles.json
  30. +0
    -0
      test_etap/cases/empty_array.erl
  31. +0
    -0
      test_etap/cases/empty_array.json
  32. +0
    -0
      test_etap/cases/empty_string.erl
  33. +0
    -0
      test_etap/cases/empty_string.json
  34. +0
    -0
      test_etap/cases/escaped_bulgarian.erl
  35. +0
    -0
      test_etap/cases/escaped_bulgarian.json
  36. +0
    -0
      test_etap/cases/escaped_foobar.erl
  37. +0
    -0
      test_etap/cases/escaped_foobar.json
  38. +0
    -0
      test_etap/cases/false.erl
  39. +0
    -0
      test_etap/cases/false.json
  40. +0
    -0
      test_etap/cases/false_then_garbage.erl
  41. +0
    -0
      test_etap/cases/false_then_garbage.json
  42. +0
    -0
      test_etap/cases/four_byte_utf8.erl
  43. +0
    -0
      test_etap/cases/four_byte_utf8.json
  44. +0
    -0
      test_etap/cases/integers.erl
  45. +0
    -0
      test_etap/cases/integers.json
  46. +0
    -0
      test_etap/cases/invalid_utf8.erl
  47. +0
    -0
      test_etap/cases/invalid_utf8.json
  48. +0
    -0
      test_etap/cases/isolated_surrogate_marker.erl
  49. +0
    -0
      test_etap/cases/isolated_surrogate_marker.json
  50. +0
    -0
      test_etap/cases/leading_zero_in_number.erl
  51. +0
    -0
      test_etap/cases/leading_zero_in_number.json
  52. +0
    -0
      test_etap/cases/lonely_minus_sign.erl
  53. +0
    -0
      test_etap/cases/lonely_minus_sign.json
  54. +0
    -0
      test_etap/cases/lonely_number.erl
  55. +0
    -0
      test_etap/cases/lonely_number.json
  56. +0
    -0
      test_etap/cases/map_close.erl
  57. +0
    -0
      test_etap/cases/map_close.json
  58. +0
    -0
      test_etap/cases/map_open.erl
  59. +0
    -0
      test_etap/cases/map_open.json
  60. +0
    -0
      test_etap/cases/missing_integer_after_decimal_point.erl
  61. +0
    -0
      test_etap/cases/missing_integer_after_decimal_point.json
  62. +0
    -0
      test_etap/cases/missing_integer_after_exponent.erl
  63. +0
    -0
      test_etap/cases/missing_integer_after_exponent.json
  64. +0
    -0
      test_etap/cases/non_utf8_char_in_string.erl
  65. +0
    -0
      test_etap/cases/non_utf8_char_in_string.json
  66. +0
    -0
      test_etap/cases/null.erl
  67. +0
    -0
      test_etap/cases/null.json
  68. +0
    -0
      test_etap/cases/null_then_garbage.erl
  69. +0
    -0
      test_etap/cases/null_then_garbage.json
  70. +0
    -0
      test_etap/cases/nulls_and_bools.erl
  71. +0
    -0
      test_etap/cases/nulls_and_bools.json
  72. +0
    -0
      test_etap/cases/simple.erl
  73. +0
    -0
      test_etap/cases/simple.json
  74. +0
    -0
      test_etap/cases/string_invalid_escape.erl
  75. +0
    -0
      test_etap/cases/string_invalid_escape.json
  76. +0
    -0
      test_etap/cases/string_invalid_hex_char.erl
  77. +0
    -0
      test_etap/cases/string_invalid_hex_char.json
  78. +0
    -0
      test_etap/cases/string_with_escapes.erl
  79. +0
    -0
      test_etap/cases/string_with_escapes.json
  80. +0
    -0
      test_etap/cases/string_with_invalid_newline.erl
  81. +0
    -0
      test_etap/cases/string_with_invalid_newline.json
  82. +0
    -0
      test_etap/cases/three_byte_utf8.erl
  83. +0
    -0
      test_etap/cases/three_byte_utf8.json
  84. +0
    -0
      test_etap/cases/true.erl
  85. +0
    -0
      test_etap/cases/true.json
  86. +0
    -0
      test_etap/cases/true_then_garbage.erl
  87. +0
    -0
      test_etap/cases/true_then_garbage.json
  88. +0
    -0
      test_etap/cases/unescaped_bulgarian.erl
  89. +0
    -0
      test_etap/cases/unescaped_bulgarian.json
  90. +0
    -0
      test_etap/etap.erl
  91. +0
    -0
      test_etap/util.erl

+ 3
- 0
.gitignore Vedi File

@ -2,3 +2,6 @@
*.o
*.so
ebin/jiffy.app
.eunit
deps
logs

+ 9
- 3
Makefile Vedi File

@ -2,10 +2,16 @@
all: build
%.beam: %.erl
erlc -o test/ $<
erlc -o test_etap/ $<
build: c_src/decoder.c
./rebar compile
check: test/etap.beam test/util.beam
prove test/*.t
check: test_etap/etap.beam test_etap/util.beam
prove test_etap/*.t
clean:
rm -rf logs .eunit
eunit:
./rebar eunit skip_deps=true

BIN
rebar Vedi File


+ 7
- 0
rebar.config Vedi File

@ -15,3 +15,10 @@
{"darwin10.*-32$", "CXXFLAGS", "-m32"},
{"darwin10.*-32$", "LDFLAGS", "-arch i386"}
]}.
{eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.
{deps, [{proper_stdlib, ".*",
{git, "https://github.com/spawngrid/proper_stdlib.git", "master"}},
{proper, ".*",
{git, "https://github.com/manopapad/proper.git", "master"}}]}.

+ 104
- 0
test/proper_tests.erl Vedi File

@ -0,0 +1,104 @@
-module(proper_tests).
-include_lib("proper/include/proper.hrl").
-include_lib("eunit/include/eunit.hrl").
-export([proper_test_/0]).
all() -> proper_ct:testcases(?MODULE).
init_per_testcase(tc_prop_foo, Config) ->
[{proper, [{numtests, 1000}]} | Config].
%% Helper funs
escaped_char() ->
?LET(C, char(),
case C == $" of
true -> "\\\"";
false -> C
end).
escaped_utf8_bin() ->
?SUCHTHAT(Bin,
?LET(S, ?SUCHTHAT(L, list(escaped_char()), L /= []),
unicode:characters_to_binary(S, unicode, utf8)),
is_binary(Bin)).
%% Atomic types
json_null() ->
null.
json_string() ->
escaped_utf8_bin().
json_number() ->
oneof([integer(), float()]).
json_boolean() ->
oneof([true, false]).
json_atomic() ->
oneof([json_null(),
json_string(),
json_number(),
json_boolean()]).
%% Compound types
json_object() ->
?SIZED(S, json_object(S)).
json_object(S) when S =< 0 ->
json_atomic();
json_object(S) ->
frequency([{1, json_object(0)},
{3, ?LAZY(json_list(S))},
{3, ?LAZY(
?LETSHRINK(
[ObjectSize],
[integer(1, S)],
?LETSHRINK(
[Object],
[{vector(ObjectSize,
{json_string(),
json_object(S - ObjectSize)})}],
Object
)))}]).
json_list(S) ->
?LETSHRINK([ListSize],
[integer(1, S)],
vector(ListSize, json_object(S - ListSize))).
json_list() ->
list(json_object()).
prop_encode_decode() ->
?FORALL(Data, json_object(),
begin
%% io:format(user, "Data: ~p~n", [Data]),
Data == jiffy:decode(jiffy:encode(Data))
end).
prop_encode_not_crash() ->
?FORALL(Data, any(),
begin
catch jiffy:encode(Data),
true
end).
prop_decode_not_crash_bin() ->
?FORALL(Data, binary(),
begin
catch jiffy:decode(Data),
true
end).
prop_decode_not_crash_any() ->
?FORALL(Data, any(),
begin
catch jiffy:decode(Data),
true
end).
proper_test_() ->
{timeout, 3600,
?_assertEqual([], proper:module(proper_tests, [{to_file, user},
{numtests, 5000}]))}.

test/001-yajl-tests.t → test_etap/001-yajl-tests.t Vedi File

@ -3,7 +3,7 @@
% See the LICENSE file for more information.
main([]) ->
code:add_pathz("test"),
code:add_pathz("test_etap"),
code:add_pathz("ebin"),
Cases = read_cases(),
@ -18,7 +18,7 @@ test({Name, Json, Erl}) ->
etap:is(jiffy:decode(Json), Erl, Name).
read_cases() ->
CasesPath = filename:join(["test", "cases", "*.json"]),
CasesPath = filename:join(["test_etap", "cases", "*.json"]),
FileNames = lists:sort(filelib:wildcard(CasesPath)),
lists:map(fun(F) -> make_pair(F) end, FileNames).

test/002-literals.t → test_etap/002-literals.t Vedi File

@ -4,7 +4,7 @@
main([]) ->
code:add_pathz("ebin"),
code:add_pathz("test"),
code:add_pathz("test_etap"),
etap:plan(6),
etap:is(jiffy:decode(<<"true">>), true, "DEC: true -> true"),
@ -17,5 +17,3 @@ main([]) ->
etap:is(jiffy:encode(null), <<"null">>, "ENC: null -> null"),
etap:end_tests().

test/003-numbers.t → test_etap/003-numbers.t Vedi File

@ -4,7 +4,7 @@
main([]) ->
code:add_pathz("ebin"),
code:add_pathz("test"),
code:add_pathz("test_etap"),
etap:plan(59),
util:test_good(good()),

test/004-strings.t → test_etap/004-strings.t Vedi File

@ -4,7 +4,7 @@
main([]) ->
code:add_pathz("ebin"),
code:add_pathz("test"),
code:add_pathz("test_etap"),
etap:plan(83),
util:test_good(good()),

test/005-arrays.t → test_etap/005-arrays.t Vedi File

@ -4,7 +4,7 @@
main([]) ->
code:add_pathz("ebin"),
code:add_pathz("test"),
code:add_pathz("test_etap"),
etap:plan(18),
util:test_good(good()),

test/006-maps.t → test_etap/006-maps.t Vedi File

@ -4,7 +4,7 @@
main([]) ->
code:add_pathz("ebin"),
code:add_pathz("test"),
code:add_pathz("test_etap"),
etap:plan(15),
util:test_good(good()),

test/007-compound.t → test_etap/007-compound.t Vedi File

@ -4,7 +4,7 @@
main([]) ->
code:add_pathz("ebin"),
code:add_pathz("test"),
code:add_pathz("test_etap"),
etap:plan(12),
util:test_good(good()),

test/008-halfword.t → test_etap/008-halfword.t Vedi File

@ -4,7 +4,7 @@
main([]) ->
code:add_pathz("ebin"),
code:add_pathz("test"),
code:add_pathz("test_etap"),
etap:plan(unknown),
@ -12,4 +12,3 @@ main([]) ->
etap:is(jiffy:decode(<<"1">>) == 1, true, "1 == 1"),
etap:end_tests().

test/cases/array.erl → test_etap/cases/array.erl Vedi File


test/cases/array.json → test_etap/cases/array.json Vedi File


test/cases/array_close.erl → test_etap/cases/array_close.erl Vedi File


test/cases/array_close.json → test_etap/cases/array_close.json Vedi File


test/cases/array_open.erl → test_etap/cases/array_open.erl Vedi File


test/cases/array_open.json → test_etap/cases/array_open.json Vedi File


test/cases/bogus_char.erl → test_etap/cases/bogus_char.erl Vedi File


test/cases/bogus_char.json → test_etap/cases/bogus_char.json Vedi File


test/cases/codepoints_from_unicode_org.erl → test_etap/cases/codepoints_from_unicode_org.erl Vedi File


test/cases/codepoints_from_unicode_org.json → test_etap/cases/codepoints_from_unicode_org.json Vedi File


test/cases/deep_arrays.erl → test_etap/cases/deep_arrays.erl Vedi File


test/cases/deep_arrays.json → test_etap/cases/deep_arrays.json Vedi File


test/cases/difficult_json_c_test_case.erl → test_etap/cases/difficult_json_c_test_case.erl Vedi File


test/cases/difficult_json_c_test_case.json → test_etap/cases/difficult_json_c_test_case.json Vedi File


test/cases/doubles.erl → test_etap/cases/doubles.erl Vedi File


test/cases/doubles.json → test_etap/cases/doubles.json Vedi File


test/cases/empty_array.erl → test_etap/cases/empty_array.erl Vedi File


test/cases/empty_array.json → test_etap/cases/empty_array.json Vedi File


test/cases/empty_string.erl → test_etap/cases/empty_string.erl Vedi File


test/cases/empty_string.json → test_etap/cases/empty_string.json Vedi File


test/cases/escaped_bulgarian.erl → test_etap/cases/escaped_bulgarian.erl Vedi File


test/cases/escaped_bulgarian.json → test_etap/cases/escaped_bulgarian.json Vedi File


test/cases/escaped_foobar.erl → test_etap/cases/escaped_foobar.erl Vedi File


test/cases/escaped_foobar.json → test_etap/cases/escaped_foobar.json Vedi File


test/cases/false.erl → test_etap/cases/false.erl Vedi File


test/cases/false.json → test_etap/cases/false.json Vedi File


test/cases/false_then_garbage.erl → test_etap/cases/false_then_garbage.erl Vedi File


test/cases/false_then_garbage.json → test_etap/cases/false_then_garbage.json Vedi File


test/cases/four_byte_utf8.erl → test_etap/cases/four_byte_utf8.erl Vedi File


test/cases/four_byte_utf8.json → test_etap/cases/four_byte_utf8.json Vedi File


test/cases/integers.erl → test_etap/cases/integers.erl Vedi File


test/cases/integers.json → test_etap/cases/integers.json Vedi File


test/cases/invalid_utf8.erl → test_etap/cases/invalid_utf8.erl Vedi File


test/cases/invalid_utf8.json → test_etap/cases/invalid_utf8.json Vedi File


test/cases/isolated_surrogate_marker.erl → test_etap/cases/isolated_surrogate_marker.erl Vedi File


test/cases/isolated_surrogate_marker.json → test_etap/cases/isolated_surrogate_marker.json Vedi File


test/cases/leading_zero_in_number.erl → test_etap/cases/leading_zero_in_number.erl Vedi File


test/cases/leading_zero_in_number.json → test_etap/cases/leading_zero_in_number.json Vedi File


test/cases/lonely_minus_sign.erl → test_etap/cases/lonely_minus_sign.erl Vedi File


test/cases/lonely_minus_sign.json → test_etap/cases/lonely_minus_sign.json Vedi File


test/cases/lonely_number.erl → test_etap/cases/lonely_number.erl Vedi File


test/cases/lonely_number.json → test_etap/cases/lonely_number.json Vedi File


test/cases/map_close.erl → test_etap/cases/map_close.erl Vedi File


test/cases/map_close.json → test_etap/cases/map_close.json Vedi File


test/cases/map_open.erl → test_etap/cases/map_open.erl Vedi File


test/cases/map_open.json → test_etap/cases/map_open.json Vedi File


test/cases/missing_integer_after_decimal_point.erl → test_etap/cases/missing_integer_after_decimal_point.erl Vedi File


test/cases/missing_integer_after_decimal_point.json → test_etap/cases/missing_integer_after_decimal_point.json Vedi File


test/cases/missing_integer_after_exponent.erl → test_etap/cases/missing_integer_after_exponent.erl Vedi File


test/cases/missing_integer_after_exponent.json → test_etap/cases/missing_integer_after_exponent.json Vedi File


test/cases/non_utf8_char_in_string.erl → test_etap/cases/non_utf8_char_in_string.erl Vedi File


test/cases/non_utf8_char_in_string.json → test_etap/cases/non_utf8_char_in_string.json Vedi File


test/cases/null.erl → test_etap/cases/null.erl Vedi File


test/cases/null.json → test_etap/cases/null.json Vedi File


test/cases/null_then_garbage.erl → test_etap/cases/null_then_garbage.erl Vedi File


test/cases/null_then_garbage.json → test_etap/cases/null_then_garbage.json Vedi File


test/cases/nulls_and_bools.erl → test_etap/cases/nulls_and_bools.erl Vedi File


test/cases/nulls_and_bools.json → test_etap/cases/nulls_and_bools.json Vedi File


test/cases/simple.erl → test_etap/cases/simple.erl Vedi File


test/cases/simple.json → test_etap/cases/simple.json Vedi File


test/cases/string_invalid_escape.erl → test_etap/cases/string_invalid_escape.erl Vedi File


test/cases/string_invalid_escape.json → test_etap/cases/string_invalid_escape.json Vedi File


test/cases/string_invalid_hex_char.erl → test_etap/cases/string_invalid_hex_char.erl Vedi File


test/cases/string_invalid_hex_char.json → test_etap/cases/string_invalid_hex_char.json Vedi File


test/cases/string_with_escapes.erl → test_etap/cases/string_with_escapes.erl Vedi File


test/cases/string_with_escapes.json → test_etap/cases/string_with_escapes.json Vedi File


test/cases/string_with_invalid_newline.erl → test_etap/cases/string_with_invalid_newline.erl Vedi File


test/cases/string_with_invalid_newline.json → test_etap/cases/string_with_invalid_newline.json Vedi File


test/cases/three_byte_utf8.erl → test_etap/cases/three_byte_utf8.erl Vedi File


test/cases/three_byte_utf8.json → test_etap/cases/three_byte_utf8.json Vedi File


test/cases/true.erl → test_etap/cases/true.erl Vedi File


test/cases/true.json → test_etap/cases/true.json Vedi File


test/cases/true_then_garbage.erl → test_etap/cases/true_then_garbage.erl Vedi File


test/cases/true_then_garbage.json → test_etap/cases/true_then_garbage.json Vedi File


test/cases/unescaped_bulgarian.erl → test_etap/cases/unescaped_bulgarian.erl Vedi File


test/cases/unescaped_bulgarian.json → test_etap/cases/unescaped_bulgarian.json Vedi File


test/etap.erl → test_etap/etap.erl Vedi File


test/util.erl → test_etap/util.erl Vedi File


Caricamento…
Annulla
Salva