瀏覽代碼

moving proper tests to eunit running

pull/8/merge^2
Dmitry Groshev 13 年之前
父節點
當前提交
7ea6a51567
共有 3 個文件被更改,包括 90 次插入26 次删除
  1. +1
    -1
      rebar.config
  2. +0
    -25
      test/jiffy_SUITE.erl
  3. +89
    -0
      test/proper_tests.erl

+ 1
- 1
rebar.config 查看文件

@ -16,7 +16,7 @@
{"darwin10.*-32$", "LDFLAGS", "-arch i386"} {"darwin10.*-32$", "LDFLAGS", "-arch i386"}
]}. ]}.
{eunit_opts, [{file, "test/props.erl"}]}.
{eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.
{deps, [{proper_stdlib, ".*", {deps, [{proper_stdlib, ".*",
{git, "https://github.com/spawngrid/proper_stdlib.git", "master"}}, {git, "https://github.com/spawngrid/proper_stdlib.git", "master"}},

+ 0
- 25
test/jiffy_SUITE.erl 查看文件

@ -1,25 +0,0 @@
-module(jiffy_SUITE).
-include_lib("proper/include/proper.hrl").
-include_lib("proper_stdlib/include/proper_ct.hrl").
-compile(export_all).
all() -> proper_ct:testcases(?MODULE).
init_per_testcase(tc_prop_foo, Config) ->
[{proper, [{numtests, 1000}]} | Config].
-type json_any() :: json_list()
| json_dict()
| json_number()
| json_string()
| json_null().
-type json_list() :: list(json_any()).
-type json_dict() :: {[{json_key(), json_any()}]}.
-type json_key() :: binary().
-type json_number() :: integer() | float().
-type json_string() :: binary().
-type json_null() :: null.
prop_foo() ->
?FORALL(Data, json_any(),
Data == jiffy:decode(jiffy:encode(Data))).

+ 89
- 0
test/proper_tests.erl 查看文件

@ -0,0 +1,89 @@
-module(proper_tests).
-include_lib("proper/include/proper.hrl").
%%-include_lib("proper_stdlib/include/proper_ct.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].
-type json_any() :: json_list()
| json_dict()
| json_number()
| json_string()
| json_null().
-type json_list() :: list(json_any()).
-type json_dict() :: {[{json_key(), json_any()}]}.
-type json_key() :: binary().
-type json_number() :: integer() | float().
-type json_string() :: binary().
-type json_null() :: null.
%% Atomic types
json_null() ->
null.
json_string() ->
?LET(Str, proper_stdgen:utf8_bin(),
binary:replace(Str, <<"\"">>, <<"\\\"">>, [global])). %good enough
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(0) ->
json_atomic();
json_object(S) ->
frequency([{1, json_object(0)},
{3, json_list()},
{9, ?LAZY(
?LETSHRINK(
[Node],
[{list({json_string(), json_object(S - 1)})}],
Node
))}]).
json_list() ->
list(json_object()).
tree(G) ->
?SIZED(S, tree(S, G)).
tree(0, _) ->
leaf;
tree(S, G) ->
frequency([
{1, tree(0, G)},
{9, ?LAZY(
?LETSHRINK(
[L, R],
[tree(S div 2, G), tree(S div 2, G)],
{node, G, L, R}
))}
]).
prop_foo() ->
%% ?FORALL(Data, json_any(),
%% Data == jiffy:decode(jiffy:encode(Data))).
?FORALL(Data, json_object(),
begin
%io:format(user, "Data: ~p~n", [Data]),
Data == jiffy:decode(jiffy:encode(Data))
end).
proper_test_() ->
{timeout, 600,
?_assertEqual([], proper:module(proper_tests, [{to_file, user},
{numtests, 10}]))}.

Loading…
取消
儲存