65
65
module OCConf : Lin .Spec = struct
66
66
(* a path and an open channel to that file; we need to keep the path
67
67
to cleanup after the test run *)
68
- type t = string * Out_channel .t
68
+ type t = Out_channel .t
69
+ let path = ref " "
69
70
70
- let init () = Filename. open_temp_file " lin-dsl- " " "
71
- let cleanup ( path , chan ) =
72
- Out_channel. close chan ;
73
- Sys. remove path
71
+ let init () =
72
+ let p,ch = Filename. open_temp_file " lin-dsl- " " " in
73
+ path := p ;
74
+ ch
74
75
75
- (* turn [f: Out_channel.t -> ...] into [lift f: t -> ...] *)
76
- let lift f (_ , chan ) = f chan
76
+ let cleanup chan =
77
+ Out_channel. close chan;
78
+ Sys. remove ! path
77
79
78
80
open Lin
79
- let int ,int64 ,string ,bytes = nat_small,nat64_small,string_small,bytes_small
81
+ let int ,int64 = nat_small,nat64_small
82
+
83
+ (* disable string and bytes char shrinking as too many shrinking candidates
84
+ triggers long Out_channel shrink runs on Mingw + Cygwin *)
85
+ let string =
86
+ let string = QCheck. (set_shrink Shrink. (string ~shrink: nil) string_small) in
87
+ gen_deconstructible string (print Lin. string ) String. equal
88
+ let bytes =
89
+ let bytes = QCheck. (set_shrink Shrink. (bytes ~shrink: nil) bytes_small) in
90
+ gen_deconstructible bytes (print Lin. bytes) Bytes. equal
91
+
80
92
let api = [
81
93
(* Only one t is tested, so skip stdout, stderr and opening functions *)
82
94
@@ -89,21 +101,21 @@ module OCConf : Lin.Spec = struct
89
101
(* val_ "Out_channel.with_open_text" Out_channel.with_open_text (string @-> (t @-> 'a) @-> returning 'a) ; *)
90
102
(* val_ "Out_channel.with_open_gen" Out_channel.with_open_gen (open_flag list @-> int @-> string @-> (t @-> 'a) @-> returning 'a) ; *)
91
103
92
- val_ " Out_channel.seek" (lift Out_channel. seek) (t @-> int64 @-> returning_or_exc unit ) ;
93
- val_freq 3 " Out_channel.pos" (lift Out_channel. pos) (t @-> returning_or_exc int64 ) ;
94
- val_freq 3 " Out_channel.length" (lift Out_channel. length) (t @-> returning_or_exc int64 ) ;
95
- val_ " Out_channel.close" (lift Out_channel. close) (t @-> returning_or_exc unit ) ;
96
- val_ " Out_channel.close_noerr" (lift Out_channel. close_noerr) (t @-> returning unit ) ;
97
- val_ " Out_channel.flush" (lift Out_channel. flush) (t @-> returning_or_exc unit ) ;
98
- val_ " Out_channel.flush_all" Out_channel. flush_all (unit @-> returning_or_exc unit ) ;
99
- val_ " Out_channel.output_char" (lift Out_channel. output_char) (t @-> char @-> returning_or_exc unit ) ;
100
- val_ " Out_channel.output_byte" (lift Out_channel. output_byte) (t @-> int @-> returning_or_exc unit ) ;
101
- val_ " Out_channel.output_string" (lift Out_channel. output_string) (t @-> string @-> returning_or_exc unit ) ;
102
- val_ " Out_channel.output_bytes" (lift Out_channel. output_bytes) (t @-> bytes @-> returning_or_exc unit ) ;
103
- val_ " Out_channel.output" (lift Out_channel. output) (t @-> bytes @-> int @-> int @-> returning_or_exc unit ) ;
104
- val_ " Out_channel.output_substring" (lift Out_channel. output_substring) (t @-> string @-> int @-> int @-> returning_or_exc unit ) ;
105
- val_ " Out_channel.set_binary_mode" (lift Out_channel. set_binary_mode) (t @-> bool @-> returning_or_exc unit ) ;
106
- val_ " Out_channel.set_buffered" (lift Out_channel. set_buffered) (t @-> bool @-> returning_or_exc unit ) ;
107
- val_ " Out_channel.is_buffered" (lift Out_channel. is_buffered) (t @-> returning_or_exc bool ) ;
104
+ val_freq 10 " Out_channel.seek" Out_channel. seek (t @-> int64 @-> returning_or_exc unit ) ;
105
+ val_freq 20 " Out_channel.pos" Out_channel. pos (t @-> returning_or_exc int64 ) ;
106
+ val_freq 20 " Out_channel.length" Out_channel. length (t @-> returning_or_exc int64 ) ;
107
+ val_freq 10 " Out_channel.close" Out_channel. close (t @-> returning_or_exc unit ) ;
108
+ val_freq 10 " Out_channel.close_noerr" Out_channel. close_noerr (t @-> returning unit ) ;
109
+ val_freq 10 " Out_channel.flush" Out_channel. flush (t @-> returning_or_exc unit ) ;
110
+ (* val_freq 1 "Out_channel.flush_all" Out_channel.flush_all (unit @-> returning_or_exc unit) ;*)
111
+ val_freq 10 " Out_channel.output_char" Out_channel. output_char (t @-> char @-> returning_or_exc unit ) ;
112
+ val_freq 10 " Out_channel.output_byte" Out_channel. output_byte (t @-> int @-> returning_or_exc unit ) ;
113
+ val_freq 10 " Out_channel.output_string" Out_channel. output_string (t @-> string @-> returning_or_exc unit ) ;
114
+ val_freq 10 " Out_channel.output_bytes" Out_channel. output_bytes (t @-> bytes @-> returning_or_exc unit ) ;
115
+ val_freq 10 " Out_channel.output" Out_channel. output (t @-> bytes @-> int @-> int @-> returning_or_exc unit ) ;
116
+ val_freq 10 " Out_channel.output_substring" Out_channel. output_substring (t @-> string @-> int @-> int @-> returning_or_exc unit ) ;
117
+ val_freq 10 " Out_channel.set_binary_mode" Out_channel. set_binary_mode (t @-> bool @-> returning_or_exc unit ) ;
118
+ val_freq 10 " Out_channel.set_buffered" Out_channel. set_buffered (t @-> bool @-> returning_or_exc unit ) ;
119
+ val_freq 10 " Out_channel.is_buffered" Out_channel. is_buffered (t @-> returning_or_exc bool ) ;
108
120
]
109
121
end
0 commit comments