19
19
% %
20
20
-module (queue_prop ).
21
21
22
- -compile (export_all ).
23
-
24
- -proptest (eqc ).
25
- -proptest ([triq , proper ]).
26
-
27
- -ifndef (EQC ).
28
- -ifndef (PROPER ).
29
- -ifndef (TRIQ ).
30
- -define (EQC , true ).
31
- -endif .
32
- -endif .
33
- -endif .
34
-
35
- -ifdef (EQC ).
36
- -include_lib (" eqc/include/eqc.hrl" ).
37
- -define (MOD_eqc ,eqc ).
38
-
39
- -else .
40
- -ifdef (PROPER ).
41
- -include_lib (" proper/include/proper.hrl" ).
42
- -define (MOD_eqc ,proper ).
43
-
44
- -else .
45
- -ifdef (TRIQ ).
46
- -define (MOD_eqc ,triq ).
47
- -include_lib (" triq/include/triq.hrl" ).
48
-
49
- -endif .
50
- -endif .
51
- -endif .
22
+ -include_lib (" common_test/include/ct_property_test.hrl" ).
52
23
53
24
% %%%%%%%%%%%%%%%%%
54
25
% %% Properties %%%
@@ -72,7 +43,7 @@ prop_is_queue() ->
72
43
prop_list_conversion () ->
73
44
? FORALL (
74
45
List ,
75
- list (),
46
+ ct_proper_ext : safe_list (),
76
47
begin
77
48
Queue = queue :from_list (List ),
78
49
queue :is_queue (Queue ) andalso
@@ -83,7 +54,7 @@ prop_list_conversion() ->
83
54
prop_from_list_invalid () ->
84
55
? FORALL (
85
56
NonList ,
86
- ? SUCHTHAT (T , term (), not is_list (T )),
57
+ ? SUCHTHAT (T , ct_proper_ext : safe_any (), not is_list (T )),
87
58
expect_badarg (fun queue :from_list /1 , [NonList ])
88
59
).
89
60
@@ -93,7 +64,8 @@ prop_to_list_invalid() ->
93
64
prop_all () ->
94
65
? FORALL (
95
66
{L , Q },
96
- oneof ([list_queue (atom ()), list_queue (term ())]),
67
+ oneof ([list_queue (ct_proper_ext :safe_atom ()),
68
+ list_queue (ct_proper_ext :safe_any ())]),
97
69
begin
98
70
lists :all (fun is_atom /1 , L ) =:= queue :all (fun is_atom /1 , Q )
99
71
end
@@ -129,7 +101,7 @@ prop_daeh_invalid() ->
129
101
prop_delete () ->
130
102
? FORALL (
131
103
{X , {L , Q }},
132
- {term (), list_queue ()},
104
+ {ct_proper_ext : safe_any (), list_queue ()},
133
105
begin
134
106
R1 = if
135
107
L =:= [] ->
@@ -150,7 +122,7 @@ prop_delete_invalid() ->
150
122
prop_delete_r () ->
151
123
? FORALL (
152
124
{X , {L , Q }},
153
- {term (), list_queue ()},
125
+ {ct_proper_ext : safe_any (), list_queue ()},
154
126
begin
155
127
R1 = if
156
128
L =:= [] ->
@@ -327,7 +299,7 @@ prop_head_invalid() ->
327
299
prop_in () ->
328
300
? FORALL (
329
301
L ,
330
- list (),
302
+ ct_proper_ext : safe_list (),
331
303
begin
332
304
Q = lists :foldl (
333
305
fun (I , Acc ) ->
@@ -410,7 +382,7 @@ prop_liat_invalid() ->
410
382
prop_member () ->
411
383
? FORALL (
412
384
{X , {L , Q }},
413
- {term (), list_queue ()},
385
+ {ct_proper_ext : safe_any (), list_queue ()},
414
386
begin
415
387
% all members of L are members of Q
416
388
lists :all (
@@ -526,7 +498,7 @@ prop_reverse_invalid() ->
526
498
prop_snoc () ->
527
499
? FORALL (
528
500
L ,
529
- list (),
501
+ ct_proper_ext : safe_list (),
530
502
begin
531
503
Q = lists :foldl (
532
504
fun (I , Acc ) ->
@@ -542,7 +514,7 @@ prop_snoc() ->
542
514
prop_snoc_invalid () ->
543
515
? FORALL (
544
516
{I , NonQueue },
545
- {term (), non_queue ()},
517
+ {ct_proper_ext : safe_any (), non_queue ()},
546
518
expect_badarg (fun queue :snoc /2 , [NonQueue , I ])
547
519
).
548
520
@@ -568,7 +540,7 @@ prop_split_invalid() ->
568
540
{non_queue (), 0 },
569
541
? SUCHTHAT (
570
542
{Q1 , N1 },
571
- {queue (), term ()},
543
+ {queue (), ct_proper_ext : safe_any ()},
572
544
not (is_integer (N1 ) andalso N1 >= 0 andalso N1 =< queue :len (Q1 ))
573
545
)
574
546
]
@@ -588,23 +560,23 @@ prop_ops() ->
588
560
{Ops , {L , Q }},
589
561
{
590
562
list (
591
- oneof ([{cons , term ()},
563
+ oneof ([{cons , ct_proper_ext : safe_any ()},
592
564
daeh ,
593
565
drop ,
594
566
drop_r ,
595
567
get ,
596
568
get_r ,
597
569
head ,
598
- {in , term ()},
599
- {in_r , term ()},
570
+ {in , ct_proper_ext : safe_any ()},
571
+ {in_r , ct_proper_ext : safe_any ()},
600
572
init ,
601
573
liat ,
602
574
last ,
603
575
out ,
604
576
out_r ,
605
577
peek ,
606
578
peek_r ,
607
- {snoc , term ()},
579
+ {snoc , ct_proper_ext : safe_any ()},
608
580
tail ])
609
581
),
610
582
list_queue ()
@@ -785,7 +757,7 @@ common_drop_tail(Fn) ->
785
757
common_in_r_cons (Fn ) ->
786
758
? FORALL (
787
759
L ,
788
- list (),
760
+ ct_proper_ext : safe_list (),
789
761
begin
790
762
Q = lists :foldl (
791
763
fun (I , Acc ) ->
@@ -815,7 +787,7 @@ common_invalid_pred(Fn) ->
815
787
common_invalid_term (Fn ) ->
816
788
? FORALL (
817
789
{I , NonQueue },
818
- {term (), non_queue ()},
790
+ {ct_proper_ext : safe_any (), non_queue ()},
819
791
expect_badarg (Fn , [I , NonQueue ])
820
792
).
821
793
@@ -824,7 +796,7 @@ common_invalid_term(Fn) ->
824
796
% %%%%%%%%%%%%%%%%%
825
797
826
798
list_queue () ->
827
- list_queue (term ()).
799
+ list_queue (ct_proper_ext : safe_any ()).
828
800
829
801
list_queue (Type ) ->
830
802
? LET (
@@ -841,7 +813,7 @@ list_queue(Type) ->
841
813
).
842
814
843
815
queue () ->
844
- queue (term ()).
816
+ queue (ct_proper_ext : safe_any ()).
845
817
846
818
queue (Type ) ->
847
819
? LET (List , list (Type ), queue :from_list (List )).
@@ -857,7 +829,7 @@ queue(Type) ->
857
829
non_queue () ->
858
830
? SUCHTHAT (
859
831
T ,
860
- term (),
832
+ ct_proper_ext : safe_any (),
861
833
not (
862
834
is_tuple (T ) andalso
863
835
tuple_size (T ) =:= 2 andalso
@@ -869,7 +841,7 @@ non_queue() ->
869
841
non_fun (Arity ) ->
870
842
? SUCHTHAT (
871
843
T ,
872
- term (),
844
+ ct_proper_ext : safe_any (),
873
845
not is_function (T , Arity )
874
846
).
875
847
0 commit comments