-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
10,236 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
%%% Copyright 2010 Manolis Papadakis (manopapad@gmail.com) | ||
%%% and Kostis Sagonas (kostis@cs.ntua.gr) | ||
%%% | ||
%%% This file is part of PropEr. | ||
%%% | ||
%%% PropEr is free software: you can redistribute it and/or modify | ||
%%% it under the terms of the GNU General Public License as published by | ||
%%% the Free Software Foundation, either version 3 of the License, or | ||
%%% (at your option) any later version. | ||
%%% | ||
%%% PropEr is distributed in the hope that it will be useful, | ||
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
%%% GNU General Public License for more details. | ||
%%% | ||
%%% You should have received a copy of the GNU General Public License | ||
%%% along with PropEr. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
%%% @author Manolis Papadakis <manopapad@gmail.com> | ||
%%% @copyright 2010 Manolis Papadakis and Kostis Sagonas | ||
%%% @version {@version} | ||
%%% @doc This module tests whether properties are auto-exported when including | ||
%%% proper.hrl | ||
|
||
-module(auto_export_test1). | ||
-export([]). | ||
|
||
-include_lib("proper/include/proper.hrl"). | ||
|
||
prop_1() -> ?FORALL(_, integer(), true). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
%%% Copyright 2010 Manolis Papadakis (manopapad@gmail.com) | ||
%%% and Kostis Sagonas (kostis@cs.ntua.gr) | ||
%%% | ||
%%% This file is part of PropEr. | ||
%%% | ||
%%% PropEr is free software: you can redistribute it and/or modify | ||
%%% it under the terms of the GNU General Public License as published by | ||
%%% the Free Software Foundation, either version 3 of the License, or | ||
%%% (at your option) any later version. | ||
%%% | ||
%%% PropEr is distributed in the hope that it will be useful, | ||
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
%%% GNU General Public License for more details. | ||
%%% | ||
%%% You should have received a copy of the GNU General Public License | ||
%%% along with PropEr. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
%%% @author Manolis Papadakis <manopapad@gmail.com> | ||
%%% @copyright 2010 Manolis Papadakis and Kostis Sagonas | ||
%%% @version {@version} | ||
%%% @doc This module tests whether auto-exporting is disabled when compiling | ||
%%% with PROPER_NOTRANS enabled. | ||
|
||
-module(auto_export_test2). | ||
|
||
-define(PROPER_NOTRANS, true). | ||
|
||
-include_lib("proper/include/proper.hrl"). | ||
|
||
prop_1() -> ?FORALL(_, integer(), true). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
-module(command_props). | ||
|
||
-include_lib("proper/include/proper.hrl"). | ||
|
||
lofl_check(Lofl, NumLists, ListLen, ListElems) -> | ||
lofl_check(Lofl, NumLists, ListLen, ListElems, 0). | ||
|
||
lofl_check([], NumLists, _ListLen, _ListElems, Acc) -> | ||
Acc =:= NumLists; | ||
lofl_check([List|Rest], NumLists, ListLen, ListElems, Acc) -> | ||
list_check(List, ListLen, ListElems) | ||
andalso lofl_check(Rest, NumLists, ListLen, ListElems, Acc + 1). | ||
|
||
list_check([], 0, _Elems) -> | ||
true; | ||
list_check([], _Left, _Elems) -> | ||
false; | ||
list_check([X|Rest], Left, Elems) -> | ||
lists:member(X, Elems) | ||
andalso list_check(Rest, Left - 1, Elems). | ||
|
||
pow(X, Y) -> | ||
pow_tr(X, Y, 1). | ||
|
||
pow_tr(_X, 0, Acc) -> | ||
Acc; | ||
pow_tr(X, Y, Acc) -> | ||
pow_tr(X, Y - 1, X * Acc). | ||
|
||
no_duplicates(L) -> length(L) =:= length(lists:usort(L)). | ||
|
||
short_list(ElemType) -> | ||
resize(10, list(ElemType)). | ||
|
||
short_ne_list(ElemType) -> | ||
non_empty(short_list(ElemType)). | ||
|
||
short_ne_nd_list(ElemType) -> | ||
?LET(L, | ||
resize(7, non_empty(list(ElemType))), | ||
lists:usort(L)). | ||
|
||
num_sels(N, Len) -> | ||
fact(Len) div fact(N) div fact(Len - N). | ||
|
||
fact(0) -> | ||
1; | ||
fact(N) when N >= 1 -> | ||
N * fact(N-1). | ||
|
||
prop_all_selections_are_produced() -> | ||
?FORALL(List, | ||
short_ne_list(integer()), | ||
begin | ||
Len = length(List), | ||
?FORALL(N, | ||
range(0,Len), | ||
begin | ||
AllSels = proper_statem:all_selections(N, List), | ||
NumAllSels = num_sels(N, Len), | ||
lofl_check(AllSels, NumAllSels, N, List) | ||
end) | ||
end). | ||
|
||
prop_index() -> | ||
?FORALL(List, short_ne_nd_list(integer()), | ||
?FORALL(X, union(List), | ||
lists:nth(proper_statem:index(X,List),List) =:= X)). | ||
|
||
prop_all_insertions() -> | ||
?FORALL(List, short_list(integer()), | ||
begin | ||
Len = length(List), | ||
?FORALL(Limit, range(1,Len+1), | ||
?FORALL(X, integer(), | ||
begin | ||
AllIns = proper_statem:all_insertions(X,Limit,List), | ||
length(AllIns) =:= Limit | ||
end)) | ||
end | ||
). | ||
|
||
prop_insert_all() -> | ||
?FORALL(List, short_ne_nd_list(integer()), | ||
begin | ||
Len = length(List), | ||
{L1,L2} = lists:split(Len div 2, List), | ||
AllIns = proper_statem:insert_all(L1,L2), | ||
?WHENFAIL(io:format("~nList: ~w, L1: ~w, L2: ~w~nAllIns: ~w~n", | ||
[List,L1,L2,AllIns]), | ||
lists:all( fun(L) -> | ||
length(L)=:=Len andalso no_duplicates(L) | ||
andalso lists:subtract(L,L2) =:= L1 | ||
end, AllIns)) | ||
end). | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
%%% Copyright 2010 Manolis Papadakis (manopapad@gmail.com) | ||
%%% and Kostis Sagonas (kostis@cs.ntua.gr) | ||
%%% | ||
%%% This file is part of PropEr. | ||
%%% | ||
%%% PropEr is free software: you can redistribute it and/or modify | ||
%%% it under the terms of the GNU General Public License as published by | ||
%%% the Free Software Foundation, either version 3 of the License, or | ||
%%% (at your option) any later version. | ||
%%% | ||
%%% PropEr is distributed in the hope that it will be useful, | ||
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
%%% GNU General Public License for more details. | ||
%%% | ||
%%% You should have received a copy of the GNU General Public License | ||
%%% along with PropEr. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
%%% @author Manolis Papadakis <manopapad@gmail.com> | ||
%%% @copyright 2010 Manolis Papadakis and Kostis Sagonas | ||
%%% @version {@version} | ||
%%% @doc This module tests whether parsing of native types is disabled when | ||
%%% compiling with PROPER_NOTRANS enabled. | ||
|
||
-module(no_native_parse_test). | ||
-export([prop_1/0]). | ||
|
||
-define(PROPER_NOTRANS, true). | ||
|
||
-include_lib("proper/include/proper.hrl"). | ||
|
||
prop_1() -> ?FORALL(_, types_test1:exp1(), true). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
%%% Copyright 2010 Manolis Papadakis (manopapad@gmail.com) | ||
%%% and Kostis Sagonas (kostis@cs.ntua.gr) | ||
%%% | ||
%%% This file is part of PropEr. | ||
%%% | ||
%%% PropEr is free software: you can redistribute it and/or modify | ||
%%% it under the terms of the GNU General Public License as published by | ||
%%% the Free Software Foundation, either version 3 of the License, or | ||
%%% (at your option) any later version. | ||
%%% | ||
%%% PropEr is distributed in the hope that it will be useful, | ||
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
%%% GNU General Public License for more details. | ||
%%% | ||
%%% You should have received a copy of the GNU General Public License | ||
%%% along with PropEr. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
%%% @author Manolis Papadakis <manopapad@gmail.com> | ||
%%% @copyright 2010 Manolis Papadakis and Kostis Sagonas | ||
%%% @version {@version} | ||
%%% @doc This module tests whether native types are parsed outside of ?FORALLs. | ||
|
||
-module(no_out_of_forall_test). | ||
-export([]). | ||
|
||
-include_lib("proper/include/proper.hrl"). | ||
|
||
foo() -> ?LET(X, types_test1:exp1(), {42,X}). | ||
|
||
prop_1() -> ?FORALL(_, foo(), true). |
Oops, something went wrong.