Permalink
Browse files

triq_tests: Added a test demonstrating the alleged need for aggressiv…

…e list shortening.

Also, repeating the test in list_shrink_test() a number of times; the previous lack of repetition happened to hide a bug in triq:shrink_loop().
  • Loading branch information...
1 parent 914394b commit b0d0652ea717693da63707e17e97792855d5fbbb Erik Søe Sørensen committed with Jan 5, 2011
Showing with 18 additions and 4 deletions.
  1. +18 −4 src/triq_tests.erl
View
@@ -128,10 +128,24 @@ tuple_failure_test() ->
list_shrink_test() ->
%% test that a list shrinks to the empty list
- [[]] = triq:counterexample(
- ?FORALL(_, list(int()), false)
- ).
-
+ true = lists:all(fun(_)->
+ [[]] == triq:counterexample(
+ ?FORALL(_, list(int()), false)
+ )
+ end, lists:seq(1,100)).
+
+list_shrink2_test() ->
+ %% test that a list doesn't easily end in a local 'smallest counterexample'
+ true = lists:all(fun(_)->
+ [[]] == triq:counterexample(
+ ?FORALL(L, list(oneof([a,b])),
+ not is_pairs_list(L))
+ )
+ end, lists:seq(1,100)).
+
+is_pairs_list([]) -> true;
+is_pairs_list([X,X|T]) -> is_pairs_list(T);
+is_pairs_list(_) -> false.
oneof_test() ->
[{X,Y}] = triq:counterexample(

0 comments on commit b0d0652

Please sign in to comment.