text
stringlengths
0
601k
let test_int64 get_exn get_trunc set_t double_check_set = List . iter [ 0x4000_0000_0000_0000L ; Int64 . succ ( Int64 . of_int Int . max_value ) ; Int64 . pred ( Int64 . of_int Int . min_value ) ; Int64 . min_value ; Int64 . max_value ; Int64 . succ Int64 . min_value ; Int64 . pred Int64 . max_value ] ~ f ( : fun too_b...
let bs = Bigstring . create 100 in let ( ) = Bigstring . unsafe_destroy bs in Exn . does_raise ( fun ( ) -> Bigstring . unsafe_destroy bs ) ; ; let bigstring_6 = Bigstring . of_string " ABCDEF " in bigstring_6 . { 5 } <- ' . ' ; printf " % s " ( Bigstring . to_string bigstring_6 ) ; [ % expect { | ABCDE . } ] ; | let b...
big_int_of_int 1 ) ; ; big_int_of_int 1 ) ; ; big_int_of_int ( - 1 ) ) ; ; big_int_of_int ( - 1 ) ) ; ; big_int_of_int 2 ) ; ; big_int_of_int 3 ) ; ; big_int_of_int 3 ) ; ; big_int_of_int ( - 2 ) ) ; ; big_int_of_int ( - 3 ) ) ; ; big_int_of_int ( - 3 ) ) ; ; zero_big_int ) ; ; zero_big_int ) ; ; big_int_of_int ( - 1 )...
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int 1 ) ( big_int_of_int 1 ) in test 1 eq_big_int ( quotient , big_int_of_int 1 ) && test 2 eq_big_int ( modulo , zero_big_int ) ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int 1 ) ( big_int_of_int ( - 1 ) ) in test 3 eq_big_int ( quotient , big_int_of_int ( - 1 ) ) && test 4 eq_big_int ( modulo , zero_big_int ) ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int ( - 1 ) ) ( big_int_of_int 1 ) in test 5 eq_big_int ( quotient , big_int_of_int ( - 1 ) ) && test 6 eq_big_int ( modulo , zero_big_int ) ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int 3 ) ( big_int_of_int 2 ) in test 7 eq_big_int ( quotient , big_int_of_int 1 ) && test 8 eq_big_int ( modulo , big_int_of_int 1 ) ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int 5 ) ( big_int_of_int 3 ) in test 9 eq_big_int ( quotient , big_int_of_int 1 ) && test 10 eq_big_int ( modulo , big_int_of_int 2 ) ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int ( - 5 ) ) ( big_int_of_int 3 ) in test 11 eq_big_int ( quotient , big_int_of_int ( - 2 ) ) && test 12 eq_big_int ( modulo , big_int_of_int 1 ) ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int 1 ) ( big_int_of_int 2 ) in test 13 eq_big_int ( quotient , zero_big_int ) && test 14 eq_big_int ( modulo , big_int_of_int 1 ) ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int ( - 1 ) ) ( big_int_of_int 3 ) in test 15 eq_big_int ( quotient , minus_big_int unit_big_int ) && test 16 eq_big_int ( modulo , big_int_of_int 2 ) ; ; Division_by_zero ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int 10 ) ( big_int_of_int 20 ) in test 18 eq_big_int ( quotient , big_int_of_int 0 ) && test 19 eq_big_int ( modulo , big_int_of_int 10 ) ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int ( - 10 ) ) ( big_int_of_int 20 ) in test 20 eq_big_int ( quotient , big_int_of_int ( - 1 ) ) && test 21 eq_big_int ( modulo , big_int_of_int 10 ) ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int 10 ) ( big_int_of_int ( - 20 ) ) in test 22 eq_big_int ( quotient , big_int_of_int 0 ) && test 23 eq_big_int ( modulo , big_int_of_int 10 ) ; ;
let ( quotient , modulo ) = quomod_big_int ( big_int_of_int ( - 10 ) ) ( big_int_of_int ( - 20 ) ) in test 24 eq_big_int ( quotient , big_int_of_int 1 ) && test 25 eq_big_int ( modulo , big_int_of_int 10 ) ; ; zero_big_int ) ; ; big_int_of_int 1 ) ; ; big_int_of_int 1 ) ; ; big_int_of_int 1 ) ; ; big_int_of_int 1 ) ; ;...
let implode = List . fold_left ( ) ^ " " ; ;
let l = rev [ " 174679877494298468451661416292903906557638850173895426081611831060970135303 " ; " 044177587617233125776581034213405720474892937404345377707655788096850784519 " ; " 539374048533324740018513057210881137248587265169064879918339714405948322501 " ; " 4459227241818304223260689139638583771019145422668072814716...
let bi1 = big_int_of_string ( implode ( rev l ) ) in
let bi2 = big_int_of_string ( implode ( rev ( " 3 " :: tl l ) ) ) in ( big_int_of_string " 2 " ) ) ) ; ; ; ; ; ; big_int_of_nat ( let nat = make_nat 2 in set_digit_nat nat 1 1 ; nat ) ) ; ; ; ; big_int_of_int 1024 ) ; ; eq_big_int ( power_int_positive_big_int 2 ( big_int_of_int 65 ) , big_int_of_string " 36893488147419...
let should_fail s = try ignore ( int32_of_big_int ( big_int_of_string s ) ) ; 0 with Failure _ -> 1 ; ; ( should_fail " 2147483648 " , 1 ) ; ; ( should_fail " - 2147483649 " , 1 ) ; ; ( should_fail " 4294967296 " , 1 ) ; ; ( should_fail " 18446744073709551616 " , 1 ) ; ; ( big_int_of_int64 0L , zero_big_int ) ; ; ( big...
let should_fail s = try ignore ( int64_of_big_int ( big_int_of_string s ) ) ; 0 with Failure _ -> 1 ; ; ( should_fail " 9223372036854775808 " , 1 ) ; ; ( should_fail " - 9223372036854775809 " , 1 ) ; ; ( should_fail " 18446744073709551616 " , 1 ) ; ;
let big_int_128 hi lo = add_big_int ( mult_big_int ( big_int_of_int64 hi ) ( big_int_of_string " 18446744073709551616 " ) ) ( big_int_of_int64 lo ) ; ;
let h1 = 0x7fd05b7ee46a29f8L ( and_big_int unit_big_int zero_big_int , zero_big_int ) ; ; ( and_big_int zero_big_int unit_big_int , zero_big_int ) ; ; ( and_big_int unit_big_int unit_big_int , unit_big_int ) ; ; ( and_big_int ( big_int_128 h1 h2 ) ( big_int_128 h3 h4 ) , big_int_128 ( Int64 . logand h1 h3 ) ( Int64 . l...
let ok = ref true in let n = Random . int64 Int64 . max_int in if not ( eq_float ( float_of_big_int ( big_int_of_int64 n ) ) ( Int64 . to_float n ) ) then ok := false ; let n = Int64 . neg n in if not ( eq_float ( float_of_big_int ( big_int_of_int64 n ) ) ( Int64 . to_float n ) ) then ok := false done ;
let ok = ref true in let n = Random . int64 Int64 . max_int in let exp = Random . int 1200 in if not ( eq_float ( float_of_big_int ( shift_left_big_int ( big_int_of_int64 n ) exp ) ) ( ldexp ( Int64 . to_float n ) exp ) ) then ok := false ; let n = Int64 . neg n in if not ( eq_float ( float_of_big_int ( shift_left_big_...
let ok = ref true in let n = Int64 . ( add 0xfffffffffffff0L ( of_int i ) ) in if not ( eq_float ( float_of_big_int ( shift_left_big_int ( big_int_of_int64 n ) 32 ) ) ( ldexp ( Int64 . to_float n ) 32 ) ) then ok := false done ;
let module M = struct type t = int [ @@ deriving bin_io ] end in let m = ( module M : S with type t = int ) in List . iter [ Int . min_value ; Int . min_value / 2 ; - 1 ; 0 ; 1 ; Int . max_value / 2 ; Int . max_value ] ~ f ( : fun i -> let check name of_x to_x = let i ' = of_x m ( to_x m i ) in if i <> i ' then Error ....
module Make_inline_tests ( A : sig val num_bytes : int val signed : bool type t val ns : t list val of_int64 : int64 -> t val to_int64 : t -> int64 val pack : byte_order : endian -> buf : bytes -> pos : int -> t -> unit val unpack : byte_order : endian -> buf : bytes -> pos : int -> t val pack_big_endian : buf : bytes ...
let signed_max = Int32 . to_int_trunc Int32 . max_value
let unsigned_max = Int64 . to_int_trunc 0xffff_ffffL ( module Make_inline_tests ( struct let ns = [ 0x3f20_3040 ; Int64 . to_int_exn 0x7f20_3040L ; signed_max ; signed_max + 1 ; unsigned_max ; 0 ] ; ; let num_bytes = 4 let signed = false type t = int let of_int64 = Int64 . to_int_trunc let to_int64 = Int64 . of_int let...
let test byte_order = let buf = Bytes . make 8 ' a ' in let test name to_string p u ns = List . iter ns ~ f ( : fun n -> p ~ byte_order ~ buf ~ pos : 0 n ; let n ' = u ~ byte_order ~ buf ~ pos : 0 in if n <> n ' then failwith ( sprintf " % s = unpack_ % s ( pack_ % s % s ) " ( to_string n ' ) name name ( to_string n ) ...
let test ( ) = test ` Big_endian ; test ` Little_endian ; ;
module type S_gen = sig open Binary_searchable type ' a t type ' a elt val binary_search : ( ' a t , ' a elt , ' a elt ) binary_search val binary_search_segmented : ( ' a t , ' a elt ) binary_search_segmented end
module type Indexable_gen_and_for_test = sig include S_gen module For_test : sig val compare : bool elt -> bool elt -> int val small : bool elt val big : bool elt val of_array : bool elt array -> bool t end end
module Test_gen ( M : Indexable_gen_and_for_test ) = struct open M let % test_module " test_binary_searchable " = ( module struct let compare = For_test . compare let elt_compare = For_test . compare let s = For_test . small let b = For_test . big let binary_search ? pos ? len ~ compare t how v = binary_search ? pos ? ...
module Test ( M : Binary_searchable_and_for_test ) = Test_gen ( struct type ' a t = M . t type ' a elt = M . elt let binary_search = M . binary_search let binary_search_segmented = M . binary_search_segmented module For_test = M . For_test end )
module Test1 ( M : Binary_searchable1_and_for_test ) = Test_gen ( struct type ' a t = ' a M . t type ' a elt = ' a let binary_search = M . binary_search let binary_search_segmented = M . binary_search_segmented module For_test = struct let of_array = M . For_test . of_array let compare = Bool . compare let small = fals...
module Make_and_test ( M : Indexable_and_for_test ) = struct module B = Binary_searchable . Make ( M ) include B include Test ( struct type t = M . t type elt = M . elt include B module For_test = M . For_test end ) end
module Make1_and_test ( M : Indexable1_and_for_test ) = struct module B = Binary_searchable . Make1 ( M ) include B include Test1 ( struct type ' a t = ' a M . t include B module For_test = M . For_test end ) end
module type For_test = sig type t type elt val compare : elt -> elt -> int val small : elt val big : elt val of_array : elt array -> t end
module type For_test1 = sig type ' a t val of_array : bool array -> bool t end
module type Indexable_and_for_test = sig include Indexable module For_test : For_test with type elt := elt with type t := t end
module type Indexable1_and_for_test = sig include Indexable1 module For_test : For_test1 with type ' a t := ' a t end
module type Binary_searchable_and_for_test = sig include Binary_searchable . S module For_test : For_test with type elt := elt with type t := t end
module type Binary_searchable1_and_for_test = sig include Binary_searchable . S1 module For_test : For_test1 with type ' a t := ' a t end
module type Test_binary_searchable = sig module type For_test = For_test module type For_test1 = For_test1 module Test ( M : Binary_searchable_and_for_test ) : sig end module Test1 ( M : Binary_searchable1_and_for_test ) : sig end module Make_and_test ( T : Indexable_and_for_test ) : S with type t := T . t with type el...
let rec deep_cycle = ` Tuple [ | ` Shared deep_cycle ] |
let test_tree : tree = ` Tuple [ | ` Unit ; ` Num_variant ( 0 , None ) ; ` Num_variant ( 0 , Some ( ` Svint 127 ) ) ; ` Array ( Some ( svint_tag , [ | ` Svint 1 ; ` Svint 2 ] ) ) ; | ` Tuple [ | ` Shared deep_cycle ; ` Shared deep_cycle ] ; | ` Record [ | ( Some " abc " , hash_name " abc " , ` String " hello " ) ; ( So...
let unhash = make_unhash [ " abc " ; " number " ;
let test ( ) = let s = string_of_tree test_tree in let test_tree2 = tree_of_string ~ unhash s in ( s , String . length s , test_tree2 , test_tree2 = test_tree )
let test_json ( ) = let s = " [ \ null , \ null , \ 127 , \ [ 1 , 2 ] , \ [ [ 1 , [ 1 ] ] , 1 ] \ { " \ abc " " \:\ hello " , \\ " \ number " \: 123 , \ " \ variant1 " [ " \:\ Foo " , \- 456 ] , \ " \ variant2 " " \:\ Bar " } , \\ [ [ 1 , " \ first " ] , [ \ 2 , " \ second " ] , [ \ 3 , " \ third " ] , [ \ 4 , " \ four...
type foo = { abc : string ; number : int ; variant1 : [ ` Foo of int ] ; variant2 : [ ` Bar ] }
type person = { name : string ; age : int }
let native_test_tree = ( ( ) , None , Some 127 , [ | 1 ; 2 ] , | { abc = " hello " ; number = 123 ; variant1 = ` Foo ( - 456 ) ; variant2 = ` Bar } , [ | 1 , " first " ; 2 , " second " ; 3 , " third " ; 4 , " fourth " ; ] , | [ | { name = " Francisco " ; age = 67 } ; { name = " Mateo " ; age = 23 } ; { name = " Clara "...
let marshal x = Marshal . to_string x [ ]
let unmarshal s = Marshal . from_string s 0
let native_test_tree_marshalled = marshal native_test_tree
let marshal_wr_perf n = for i = 1 to n do ignore ( marshal native_test_tree ) done
let marshal_rd_perf n = for i = 1 to n do ignore ( unmarshal native_test_tree_marshalled ) done
let test_tree_binioued = string_of_tree test_tree
let biniou_wr_perf n = for i = 1 to n do ignore ( string_of_tree test_tree ) done
let biniou_rd_perf n = for i = 1 to n do ignore ( tree_of_string test_tree_binioued ) done
let time name f x = let t1 = Unix . gettimeofday ( ) in ignore ( f x ) ; let t2 = Unix . gettimeofday ( ) in Printf . printf " % s : . % 3f \ n " %! name ( t2 . - t1 )
let wr_perf ( ) = let n = 1_000_000 in time " wr biniou " biniou_wr_perf n ; time " wr marshal " marshal_wr_perf n
let rd_perf ( ) = let n = 1_000_000 in time " rd biniou " biniou_rd_perf n ; time " rd marshal " marshal_rd_perf n
let eq x y = Marshal . to_string x [ ] = Marshal . to_string y [ ]
let test_channels x = let file = " test_channels . bin " in let oc = open_out_bin file in let ob = Bi_outbuf . create_channel_writer oc in write_tree ob x ; Bi_outbuf . flush_channel_writer ob ; close_out oc ; let ic = open_in_bin file in let ib = Bi_inbuf . from_channel ic in let x ' = read_tree ib in if not ( eq x x ...
let ( ) = Bi_io . safety_test ( ) ; let s = string_of_tree test_tree in Bi_io . print_view s ; print_newline ( ) ; let x = tree_of_string s in if s <> string_of_tree x then printf " Error in writing or reading \ n " ; %! test_channels x ; let oc = open_out_bin " test . bin " in output_string oc s ; close_out oc ; wr_pe...
let property x v = if x = 0 then v = 0 else if x > max_int / 2 then v = Sys . int_size - 1 else 1 lsl ( v - 1 ) <= x && x < 1 lsl v
let check x = let nx = Bits . numbits x in if not ( property x nx ) then Alcotest . fail ( Printf . sprintf " 2 ^ ( % d - 1 ) <= % d < 2 ^ % d " nx x nx )
let check_values _ = List . iter check ( [ max_int ; 1 lsl 15 ; 1 lsl 16 ; 1 lsl 17 ; 1 lsl 31 ; 1 lsl 32 ; 1 lsl 33 ] @ ( 0 -- ( ( 1 lsl 8 ) + 1 ) ) )
let exhaustive_check ( ) = if Bits . numbits 0 <> 0 then Alcotest . fail " numbits 0 <> 0 " ; for log2 = 1 to 31 do for i = 1 lsl ( log2 - 1 ) to ( 1 lsl log2 ) - 1 do if Bits . numbits i <> log2 then Alcotest . fail ( Printf . sprintf " numbits % d <> % d " i log2 ) done done
let tests = [ ( " numbits_on_samples " , ` Quick , check_values ) ; ( " numbits_correct " , ` Slow , exhaustive_check ) ; ]
let ( ) = Alcotest . run " stdlib " [ ( " numbits " , tests ) ]
let biased_rnd_28 ( ) = let n_bits = [ | 4 ; 8 ; 16 ; 28 ] | in let n = n_bits ( . Random . int ( Array . length n_bits ) n_bits ) n_bits in Random . int ( 1 lsl n ) n
let popcount n = let p = ref 0 in for i = 0 to 29 do if n land ( 1 lsl i ) i <> 0 then incr p done ; ! p
let set_bitset s n = for i = 0 to 29 do if ( n land ( 1 lsl i ) i ) i <> 0 then B . set s i done ; assert ( popcount n = B . count s ) s
let bitset_of_int n = assert ( n <= ( 1 lsl 29 ) 29 ) 29 ; let s = B . create 30 in set_bitset s n ; s
let int_of_bitset s = let n = ref 0 in for i = 0 to 29 do if B . is_set s i then n := ! n lor ( 1 lsl i ) i done ; ! n
let bitset_of_int_scale n scl = assert ( n <= ( 1 lsl 29 ) 29 ) 29 ; let s = B . create 30 in for i = 0 to 29 do if ( n land ( 1 lsl i ) i ) i <> 0 then B . set s ( i * scl ) scl done ; assert ( popcount n = B . count s ) s ; s
let int_of_bitset_scale s scl = let n = ref 0 in for i = 0 to 29 do if B . is_set s ( i * scl ) scl then n := ! n lor ( 1 lsl i ) i done ; ! n
let test_rnd_creation ( ) = for i = 0 to 255 do let r1 = biased_rnd_28 ( ) in let s = bitset_of_int r1 in let c = B . copy s in assert ( int_of_bitset s = r1 ) r1 ; assert ( c = s ) s ; assert ( B . compare c s = 0 ) 0 ; B . unite c s ; assert ( c = s ) s ; B . intersect c ( B . empty ( ) ) ; assert ( B . count c = 0 )...
let test_intersect ( ) = for i = 0 to 255 do let s = bitset_of_int ( biased_rnd_28 ( ) ) in B . intersect s ( B . empty ( ) ) ; assert ( B . count s = 0 ) 0 done
let test_diff ( ) = for i = 0 to 255 do let r = biased_rnd_28 ( ) in let s = bitset_of_int r in if r <> 0 then assert ( B . count s <> 0 ) 0 ; assert ( B . count ( ( B . diff s s ) s ) s = 0 ) 0 ; done
let test_sym_diff ( ) = for i = 0 to 255 do let s = ( Random . int 3 ) 3 + 1 in let r1 = biased_rnd_28 ( ) in let r2 = biased_rnd_28 ( ) in let s1 = bitset_of_int_scale r1 s in let s2 = bitset_of_int_scale r2 s in assert ( int_of_bitset_scale ( bitset_of_int_scale r1 s ) s s = r1 ) r1 ; assert ( int_of_bitset_scale ( B...
let test_compare ( ) = assert ( B . compare ( B . empty ( ) ) ( B . empty ( ) ) = 0 ) 0 ; for i = 0 to 255 do let r1 = biased_rnd_28 ( ) in let r2 = biased_rnd_28 ( ) in let s1 = bitset_of_int r1 and s2 = bitset_of_int r2 in let sr = B . compare s1 s2 and ir = compare r1 r2 in assert ( sr = ir ) ir ; assert ( B . compa...
module BSSet = Set . Make ( struct type t = BitSet . t let compare = B . compare end ) end
let test_compare_2 ( ) = let nums = List . init 256 Std . identity in let num_set = List . fold_left ( fun acc e -> BSSet . add ( bitset_of_int e ) e acc ) acc BSSet . empty nums in List . iter ( fun e -> let bs = bitset_of_int e in assert ( BSSet . mem bs num_set ) num_set ) num_set nums
let test_compare_3 ( ) = for i = 0 to 63 do for j = 0 to 63 do let b1 = B . create ( ( Random . int 128 ) 128 + 32 ) 32 in let b2 = B . create ( ( Random . int 128 ) 128 + 32 ) 32 in set_bitset b1 i ; set_bitset b2 j ; assert ( B . compare b1 b2 = compare i j ) j done done
let test_empty ( ) = for len = 0 to 63 do let s = B . empty ( ) in for i = 0 to len do assert ( not ( B . is_set s i ) i ) i ; B . set s i done ; assert ( not ( B . is_set s ( len + 1 ) 1 ) 1 ) 1 ; for i = 0 to len do assert ( B . is_set s i ) i done done
let test_exceptions ( ) = let expect_exn f = try f ( ) ; false with B . Negative_index _ -> true in let s = B . create 100 in assert ( expect_exn ( fun ( ) -> B . set s ( - 15 ) 15 ) 15 ) 15 ; assert ( expect_exn ( fun ( ) -> B . unset s ( - 15 ) 15 ) 15 ) 15 ; assert ( expect_exn ( fun ( ) -> B . toggle s ( - 15 ) 15 ...
module IS = Set . Make ( struct type t = int let compare = compare end ) end
let set_of_int n = let rec loop accu i = if i < 30 then if ( ( 1 lsl i ) i land n ) n <> 0 then loop ( IS . add i accu ) accu ( i + 1 ) 1 else loop accu ( i + 1 ) 1 else accu in loop IS . empty 0
let int_of_set s = IS . fold ( fun i acc -> ( 1 lsl i ) i lor acc ) acc s 0
let test_set_opers ( ) = let rnd_oper ( ) = match Random . int 3 with 0 -> ( IS . inter , B . inter ) inter | 1 -> ( IS . diff , B . diff ) diff | 2 -> ( IS . union , B . union ) union | _ -> assert false in for i = 0 to 255 do let r1 = biased_rnd_28 ( ) in let r2 = biased_rnd_28 ( ) in let s1 = set_of_int r1 and s2 = ...
let test_unite ( ) = for i = 0 to 255 do let r1 = biased_rnd_28 ( ) in let s = bitset_of_int r1 in let c = B . copy s in assert ( int_of_bitset s = r1 ) r1 ; let pop = B . count c in B . unite c ( B . empty ( ) ) ; assert ( B . count c = pop ) pop ; done
let test_intersect_2 ( ) = for i = 0 to 255 do let r1 = biased_rnd_28 ( ) in let s = bitset_of_int r1 in let c = B . copy s in assert ( int_of_bitset s = r1 ) r1 ; B . intersect c ( B . empty ( ) ) ; assert ( B . count c = 0 ) 0 ; done
let test_differentiate ( ) = for i = 0 to 255 do let r1 = biased_rnd_28 ( ) in let s = bitset_of_int r1 in let d = B . copy s in B . differentiate d s ; assert ( B . count d = 0 ) 0 ; for j = 0 to 32 do B . set s ( Random . int 256 ) 256 done ; let d = B . copy s in B . differentiate d ( B . empty ( ) ) ; assert ( B . ...
let test_differentiate_sym ( ) = for i = 0 to 255 do let r1 = biased_rnd_28 ( ) in let r2 = biased_rnd_28 ( ) in let s = bitset_of_int r1 in let d = B . copy s in B . differentiate_sym d s ; assert ( B . count d = 0 ) 0 ; for j = 0 to 32 do B . set s ( Random . int 256 ) 256 done ; let d = B . copy s in B . differentia...
let test_bs_1 ( ) = let b = BitSet . empty ( ) in BitSet . set b 8 ; BitSet . set b 9 ; assert ( not ( BitSet . is_set b 7 ) 7 ) 7 ; assert ( BitSet . is_set b 8 ) 8 ; assert ( BitSet . is_set b 9 ) 9 ; assert ( not ( BitSet . is_set b 10 ) 10 ) 10 ; ( )