@@ -1119,6 +1119,54 @@ options_test_() ->
11191119 ? FORALL (_ ,? SIZED (Size ,integer (Size ,Size )),false ),
11201120 [{start_size ,12 }])].
11211121
1122+ seeded_test_ () ->
1123+ Seed = os :timestamp (),
1124+ BaseOpts = [noshrink , {start_size ,65536 }, quiet ],
1125+ Seeded = fun (Prop ) ->
1126+ R = proper :counterexample (Prop , [{seed ,Seed }|BaseOpts ]),
1127+ proper :clean_garbage (),
1128+ R
1129+ end ,
1130+ NoSeed = fun (Prop ) ->
1131+ R = proper :counterexample (Prop , BaseOpts ),
1132+ proper :clean_garbage (),
1133+ R
1134+ end ,
1135+ ReSeeded = fun (Prop ) ->
1136+ OtherSeed = os :timestamp (),
1137+ R = proper :counterexample (Prop , [{seed ,OtherSeed }|BaseOpts ]),
1138+ proper :clean_garbage (),
1139+ R
1140+ end ,
1141+ [[? _assert (state_is_clean ()),
1142+ ? _assertMatch ({Name ,{_ ,Equals }} when Equals > 6 , {Name ,equaltimes (Seeded ,Prop ,Check ,10 )}),
1143+ ? _assert (state_is_clean ()),
1144+ ? _assertMatch ({Name ,{_ ,Equals }} when Equals < 4 , {Name ,equaltimes (NoSeed ,Prop ,Check ,10 )}),
1145+ ? _assert (state_is_clean ()),
1146+ ? _assertMatch ({Name ,{_ ,Equals }} when Equals < 4 , {Name ,equaltimes (ReSeeded ,Prop ,Check ,10 )}),
1147+ ? _assert (state_is_clean ())]
1148+ % % For each of these properties...
1149+ || {Name ,Prop } <- [{forall ,? FORALL (_ , integer (), false )},
1150+ {trapexit ,? FORALL (_ , integer (), ? TRAPEXIT (false ))},
1151+ {targeted ,? FORALL_TARGETED (I , integer (), begin ? MAXIMIZE (I ),false end )}],
1152+ % % Ensure that, using a large enough size and at least 60% of the time:
1153+ % % * provided a seed, another run gives the same counterexample;
1154+ % % * when not provided a seed: run gives out differing results to the seeded one;
1155+ % % * and similarly when given a different seed.
1156+ Check <- [Seeded (Prop )]].
1157+
1158+ equaltimes (Runner , Prop , Expected , Max ) ->
1159+ equaltimes (Runner , Prop , Expected , Max , Max , []).
1160+ equaltimes (_ , _ , _ , Max , 0 , Unexpecteds ) ->
1161+ {Unexpecteds , Max - length (Unexpecteds )};
1162+ equaltimes (Runner , Prop , Expected , Max , N , Acc ) ->
1163+ case Runner (Prop ) of
1164+ Expected ->
1165+ equaltimes (Runner , Prop , Expected , Max , N - 1 , Acc );
1166+ Got ->
1167+ equaltimes (Runner , Prop , Expected , Max , N - 1 , [Got |Acc ])
1168+ end .
1169+
11221170setup_prop () ->
11231171 ? SETUP (fun () ->
11241172 put (setup_token , true ),
0 commit comments