text
stringlengths
0
601k
module TestDoubleTraversorsStdlibList ( M : sig include BASE include Traits . COMBINE_VANILLA with type ' a t := ' a t include Traits . ITER_PARALLEL with type ' a elt := ' a and type ' a t := ' a t include Traits . MAP_PARALLEL with type ' a t := ' a t include Traits . REVMAP_PARALLEL with type ' a t := ' a t include ...
let dummy_list = Script_list . ( cons 42 empty )
let forty_two = Alpha_context . Script_int . of_int 42
let forty_two_n = Alpha_context . Script_int . abs forty_two
let dummy_set = let open Script_set in update forty_two true ( empty Script_typed_ir . int_key )
let dummy_map = let open Script_map in update forty_two ( Some forty_two ) ( empty Script_typed_ir . int_key )
let dummy_timestamp = Alpha_context . Script_timestamp . of_zint ( Z . of_int 42 )
let dummy_pk = Signature . Public_key . of_b58check_exn " edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU "
let dummy_bytes = Bytes . of_string " dummy "
let dummy_string = match Alpha_context . Script_string . of_string " dummy " with | Ok s -> s | Error _ -> assert false
let free = [ " balance " ; " bool " ; " parsing_unit " ; " unparsing_unit " ]
let all_interpreter_costs = let open Michelson_v1_gas . Cost_of . Interpreter in [ ( " drop " , drop ) ; ( " dup " , dup ) ; ( " swap " , swap ) ; ( " cons_some " , cons_some ) ; ( " cons_none " , cons_none ) ; ( " if_none " , if_none ) ; ( " cons_pair " , cons_pair ) ; ( " car " , car ) ; ( " cdr " , cdr ) ; ( " cons_...
let all_parsing_costs = let open Michelson_v1_gas . Cost_of . Typechecking in [ ( " public_key_optimized " , public_key_optimized ) ; ( " public_key_readable " , public_key_readable ) ; ( " key_hash_optimized " , key_hash_optimized ) ; ( " key_hash_readable " , key_hash_readable ) ; ( " signature_optimized " , signatur...
let all_unparsing_costs = let open Michelson_v1_gas . Cost_of . Unparsing in [ ( " public_key_optimized " , public_key_optimized ) ; ( " public_key_readable " , public_key_readable ) ; ( " key_hash_optimized " , key_hash_optimized ) ; ( " key_hash_readable " , key_hash_readable ) ; ( " signature_optimized " , signature...
let all_io_costs = let open Storage_costs in [ ( " read_access 0 0 " , read_access ~ path_length : 0 ~ read_bytes : 0 ) ; ( " read_access 1 0 " , read_access ~ path_length : 1 ~ read_bytes : 0 ) ; ( " read_access 0 1 " , read_access ~ path_length : 0 ~ read_bytes : 1 ) ; ( " read_access 1 1 " , read_access ~ path_lengt...
let cast_cost_to_s ( c : Alpha_context . Gas . cost ) : _ S . t = Data_encoding . Binary . to_bytes_exn Alpha_context . Gas . cost_encoding c |> Data_encoding . Binary . of_bytes_exn S . n_encoding
let test_cost_reprs_are_all_positive list ( ) = List . iter_es ( fun ( cost_name , cost ) -> if S . ( cost > S . zero ) then return_unit else if S . equal cost S . zero && List . mem ~ equal : String . equal cost_name free then return_unit else fail ( Exn ( Failure ( Format . asprintf " Gas cost test " \% s " \ failed ...
let test_costs_are_all_positive list ( ) = let list = List . map ( fun ( cost_name , cost ) -> ( cost_name , cast_cost_to_s cost ) ) list in test_cost_reprs_are_all_positive list ( )
let tests = [ Tztest . tztest " Positivity of interpreter costs " ` Quick ( test_costs_are_all_positive all_interpreter_costs ) ; Tztest . tztest " Positivity of typechecking costs " ` Quick ( test_costs_are_all_positive all_parsing_costs ) ; Tztest . tztest " Positivity of unparsing costs " ` Quick ( test_costs_are_al...
let opg = max_int / 10000
let err x = Exn ( Gas_levels_test_error x )
let succeed x = match x with Ok _ -> true | _ -> false
let failed x = not ( succeed x )
let dummy_context ( ) = Context . init ~ consensus_threshold : 0 1 >>=? fun ( block , _ ) -> Raw_context . prepare ~ level : Int32 . zero ~ predecessor_timestamp : Time . Protocol . epoch ~ timestamp : Time . Protocol . epoch ( block . context : Environment_context . Context . t ) >|= Environment . wrap_tzresult
let consume_gas_lwt context gas = Lwt . return ( consume_gas context ( S . safe_int gas ) ) >|= Environment . wrap_tzresult
let consume_gas_limit_in_block_lwt context gas = Lwt . return ( consume_gas_limit_in_block context gas ) >|= Environment . wrap_tzresult
let test_detect_gas_exhaustion_in_fresh_context ( ) = dummy_context ( ) >>=? fun context -> fail_unless ( consume_gas context ( S . safe_int opg ) |> succeed ) ( err " In a fresh context , gas consumption is unlimited . " )
let make_context remaining_block_gas = let open Gas_limit_repr in dummy_context ( ) >>=? fun context -> let hard_limit = Arith . fp ( constants context ) . hard_gas_limit_per_operation in let hard_limit_block = Arith . fp ( constants context ) . hard_gas_limit_per_block in let block_gas = Arith . ( unsafe_fp ( Z . of_i...
let test_detect_gas_exhaustion_when_operation_gas_hits_zero ( ) = let gas_op = 100000 in dummy_context ( ) >>=? fun context -> set_gas_limit context ( Gas_limit_repr . Arith . unsafe_fp ( Z . of_int gas_op ) ) |> fun context -> fail_unless ( consume_gas context ( S . safe_int gas_op ) |> succeed ) ( err " Succeed when ...
let test_detect_gas_exhaustion_when_block_gas_hits_zero ( ) = let gas k = Gas_limit_repr . Arith . unsafe_fp ( Z . of_int k ) in let remaining_gas = gas 100000 and too_much = gas ( 100000 + 1 ) in make_context 100000 >>=? fun context -> fail_unless ( consume_gas_limit_in_block context remaining_gas |> succeed ) ( err "...
let test_detect_gas_limit_consumption_above_hard_gas_operation_limit ( ) = dummy_context ( ) >>=? fun context -> fail_unless ( consume_gas_limit_in_block context ( Gas_limit_repr . Arith . unsafe_fp ( Z . of_int opg ) ) |> failed ) ( err " Fail when consuming gas above the hard limit per operation in the \ block . " )
let check_context_levels context block_level operation_level = let op_check = match gas_level context with | Unaccounted -> true | Limited { remaining } -> Gas_limit_repr . Arith . ( unsafe_fp ( Z . of_int operation_level ) = remaining ) in let block_check = Gas_limit_repr . Arith . ( unsafe_fp ( Z . of_int block_level...
let monitor remaining_block_gas initial_operation_level consumed_gas ( ) = let op_limit = Gas_limit_repr . Arith . unsafe_fp ( Z . of_int initial_operation_level ) in make_context remaining_block_gas >>=? fun context -> consume_gas_limit_in_block_lwt context op_limit >>=? fun context -> set_gas_limit context op_limit |...
let test_monitor_gas_level = monitor 1000 100 10
let test_set_gas_unlimited ( ) = let init_block_gas = 100000 in let op_limit_int = 10000 in let op_limit = Gas_limit_repr . Arith . unsafe_fp ( Z . of_int op_limit_int ) in make_context init_block_gas >>=? fun context -> set_gas_limit context op_limit |> set_gas_unlimited |> fun context -> consume_gas_lwt context opg >...
let test_set_gas_limited ( ) = let init_block_gas = 100000 in let op_limit_int = 10000 in let op_limit = Gas_limit_repr . Arith . unsafe_fp ( Z . of_int op_limit_int ) in let op_gas = 100 in make_context init_block_gas >>=? fun context -> set_gas_unlimited context |> fun context -> set_gas_limit context op_limit |> fun...
let apply_with_gas header ( ? operations = [ ] ) ( pred : Block . t ) = let open Alpha_context in ( let open Environment . Error_monad in begin_application ~ chain_id : Chain_id . zero ~ predecessor_context : pred . context ~ predecessor_fitness : pred . header . shell . fitness ~ predecessor_timestamp : pred . header ...
let bake_with_gas ? policy ? timestamp ? operation ? operations pred = let operations = match ( operation , operations ) with | ( Some op , Some ops ) -> Some ( op :: ops ) | ( Some op , None ) -> Some [ op ] | ( None , Some ops ) -> Some ops | ( None , None ) -> None in Block . Forge . forge_header ? timestamp ? polic...
let check_consumed_gas consumed expected = fail_unless Alpha_context . Gas . Arith . ( consumed = expected ) ( err ( Format . asprintf " Gas discrepancy : consumed gas : % a | expected : % a \ n " Alpha_context . Gas . Arith . pp consumed Alpha_context . Gas . Arith . pp expected ) )
let lazy_unit = Alpha_context . Script . lazy_expr ( Expr . from_string " Unit " )
let prepare_origination block source script = let code = Expr . toplevel_from_string script in let script = Alpha_context . Script . { code = lazy_expr code ; storage = lazy_unit } in Op . contract_origination ( B block ) source ~ script
let originate_contract block source script = prepare_origination block source script >>=? fun ( operation , dst ) -> Block . bake ~ operation block >>=? fun block -> return ( block , dst )
let init_block to_originate = Context . init ~ consensus_threshold : 0 1 >>=? fun ( block , contracts ) -> let src = WithExceptions . Option . get ~ loc : __LOC__ @@ List . hd contracts in let rec full_originate block originated = function | [ ] -> return ( block , List . rev originated ) | h :: t -> originate_contract...
let nil_contract = " parameter unit ; \ n \ storage unit ; \ n \ code { \ n \ \ DROP ; \ n \ \ UNIT ; NIL operation ; PAIR \ n \ \ } \ n "
let fail_contract = " parameter unit ; storage unit ; code { FAIL } "
let loop_contract = " parameter unit ; \ n \ storage unit ; \ n \ code { \ n \ \ DROP ; \ n \ \ PUSH bool True ; \ n \ \ LOOP { \ n \ \ PUSH string " \ GASGASGAS " ; \\ n \ \ PACK ; \ n \ \ SHA3 ; \ n \ \ DROP ; \ n \ \ PUSH bool True \ n \ \ } ; \ n \ \ UNIT ; NIL operation ; PAIR \ n \ \ } \ n "
let block_with_one_origination contract = init_block [ contract ] >>=? fun ( block , src , originated ) -> match originated with [ dst ] -> return ( block , src , dst ) | _ -> assert false
let full_block ( ) = init_block [ nil_contract ; fail_contract ; loop_contract ] >>=? fun ( block , src , originated ) -> let ( dst_nil , dst_fail , dst_loop ) = match originated with [ c1 ; c2 ; c3 ] -> ( c1 , c2 , c3 ) | _ -> assert false in return ( block , src , dst_nil , dst_fail , dst_loop )
let combine_operations_with_gas ? counter block src list_dst = let rec make_op_list full_gas op_list = function | [ ] -> return ( full_gas , List . rev op_list ) | ( dst , gas_limit ) :: t -> Op . transaction ~ gas_limit ( B block ) src dst Alpha_context . Tez . zero >>=? fun op -> make_op_list ( Alpha_context . Gas . ...
let bake_operations_with_gas ? counter block src list_list_dst = let counter = Option . value ~ default : Z . zero counter in let rec make_list full_gas op_list counter = function | [ ] -> return ( full_gas , List . rev op_list ) | list_dst :: t -> let n = Z . of_int ( List . length list_dst ) in combine_operations_wit...
let basic_gas_sampler ( ) = Alpha_context . Gas . Arith . integral_of_int_exn ( 100 + Random . int 900 )
let generic_test_block_one_origination contract gas_sampler structure = block_with_one_origination contract >>=? fun ( block , src , dst ) -> let lld = List . map ( List . map ( fun _ -> ( dst , gas_sampler ( ) ) ) ) structure in bake_operations_with_gas ~ counter : Z . one block src lld >>=? fun ( _block , consumed_ga...
let make_batch_test_block_one_origination name contract gas_sampler = let test = generic_test_block_one_origination contract gas_sampler in let test_one_operation ( ) = test [ [ ( ) ] ] in let test_one_operation_list ( ) = test [ [ ( ) ; ( ) ; ( ) ] ] in let test_many_single_operations ( ) = test [ [ ( ) ] ; [ ( ) ] ; ...
let test_consume_exactly_all_block_gas ( ) = block_with_one_origination nil_contract >>=? fun ( block , src , dst ) -> let lld = List . map ( fun _ -> [ ( dst , Alpha_context . Gas . Arith . integral_of_int_exn 1040000 ) ] ) [ 1 ; 1 ; 1 ; 1 ; 1 ] in bake_operations_with_gas ~ counter : Z . one block src lld >>=? fun _ ...
let test_malformed_block_max_limit_reached ( ) = block_with_one_origination nil_contract >>=? fun ( block , src , dst ) -> let lld = [ ( dst , Alpha_context . Gas . Arith . integral_of_int_exn 1 ) ] :: List . map ( fun _ -> [ ( dst , Alpha_context . Gas . Arith . integral_of_int_exn 1040000 ) ] ) [ 1 ; 1 ; 1 ; 1 ; 1 ] ...
let test_malformed_block_max_limit_reached ' ( ) = block_with_one_origination nil_contract >>=? fun ( block , src , dst ) -> let lld = [ ( dst , Alpha_context . Gas . Arith . integral_of_int_exn 1 ) :: List . map ( fun _ -> ( dst , Alpha_context . Gas . Arith . integral_of_int_exn 1040000 ) ) [ 1 ; 1 ; 1 ; 1 ; 1 ] ; ] ...
let test_block_mixed_operations ( ) = full_block ( ) >>=? fun ( block , src , dst_nil , dst_fail , dst_loop ) -> let l = [ [ dst_nil ] ; [ dst_nil ; dst_fail ; dst_nil ] ; [ dst_loop ] ; [ dst_nil ] ] in let lld = List . map ( List . map ( fun x -> ( x , basic_gas_sampler ( ) ) ) ) l in bake_operations_with_gas ~ count...
let quick ( what , how ) = Tztest . tztest what ` Quick how
let tests = List . map quick ( [ ( " Detect gas exhaustion in fresh context " , test_detect_gas_exhaustion_in_fresh_context ) ; ( " Detect gas exhaustion when operation gas as hits zero " , test_detect_gas_exhaustion_when_operation_gas_hits_zero ) ; ( " Detect gas exhaustion when block gas as hits zero " , test_detect_...
let ( let * ) = ( >>=? )
module Gas_monad_syntax = struct let ( let * ) = GM . ( >>$ ) end
let ten_milligas = Gas . fp_of_milligas_int 10
let new_context ~ limit = Context . init 1 >>=? fun ( b , _contracts ) -> Incremental . begin_construction b >|=? fun inc -> let state = Incremental . validation_state inc in Gas . set_limit state . ctxt limit
let assert_gas_exhaustion ~ loc ctxt gas_monad = match GM . run ctxt gas_monad with | Error _ -> return ( ) | _ -> failwith " % s : expected gas - exhaustion error " loc
let assert_equal_gas ~ loc g1 g2 = Assert . equal ~ loc Gas . Arith . equal " Compare gas " Gas . Arith . pp g1 g2
let assert_inner_errors ~ loc ctxt gas_monad ~ errors ~ remaining_gas = match GM . run ctxt gas_monad with | Ok ( Error e , ctxt ) -> let * ( ) = Assert . assert_equal_list ~ loc ( = ) " Inner error " Format . pp_print_string e errors in assert_equal_gas ~ loc ( Gas . remaining_operation_gas ctxt ) ( Gas . fp_of_millig...
let assert_success ~ loc ctxt gas_monad ~ result ~ remaining_gas = match GM . run ctxt gas_monad with | Ok ( Ok x , ctxt ) -> let * ( ) = Assert . equal_int ~ loc x result in assert_equal_gas ~ loc ( Gas . remaining_operation_gas ctxt ) ( Gas . fp_of_milligas_int remaining_gas ) | _ -> failwith " % s : expected success...
let test_gas_exhaustion ( ) = let * ctxt = new_context ~ limit : ten_milligas in let gas_monad = let open Gas_monad_syntax in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 5 ) in let * x = GM . return 1 in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 10 ) in let * y = GM . return 2 in GM . retu...
let test_gas_exhaustion_before_error ( ) = let * ctxt = new_context ~ limit : ten_milligas in let gas_monad = let open Gas_monad_syntax in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 5 ) in let * x = GM . return 1 in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 10 ) in let * ( ) = GM . of_res...
let test_successful_with_remaining_gas ( ) = let * ctxt = new_context ~ limit : ten_milligas in let gas_monad = let open Gas_monad_syntax in let * x = GM . return 1 in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 5 ) in let * y = GM . return 2 in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 5 ...
let test_successful_with_spare_gas ( ) = let * ctxt = new_context ~ limit : ten_milligas in let gas_monad = let open Gas_monad_syntax in let * x = GM . return 1 in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 5 ) in let * y = GM . return 2 in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 3 ) in...
let test_inner_error ( ) = let * ctxt = new_context ~ limit : ten_milligas in let gas_monad = let open Gas_monad_syntax in let * x = GM . return 1 in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 5 ) in let * ( ) = GM . of_result ( error " Oh no " ) in let * y = GM . return 2 in let * ( ) = GM . consume_gas...
let test_unlimited ( ) = let * ctxt = new_context ~ limit : ten_milligas in let gas_monad = let open Gas_monad_syntax in let * x = GM . return 1 in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 5 ) in let * y = GM . return 2 in let * ( ) = GM . consume_gas ( Saturation_repr . safe_int 100 ) in let * ( ) = G...
let test_bind_result_ok ( ) = let * ctxt = new_context ~ limit : ten_milligas in let gas_monad = let open Gas_monad in GM . consume_gas ( Saturation_repr . safe_int 1 ) >?$ fun ( ) -> Ok 42 in assert_success ~ loc : __LOC__ ctxt gas_monad ~ result : 42 ~ remaining_gas : 9
let test_bind_result_error ( ) = let * ctxt = new_context ~ limit : ten_milligas in let gas_monad = let open Gas_monad in GM . consume_gas ( Saturation_repr . safe_int 1 ) >?$ fun ( ) -> error " Oh no " in assert_inner_errors ~ loc : __LOC__ ctxt gas_monad ~ errors [ " : Oh no " ] ~ remaining_gas : 9
let tests = [ Tztest . tztest " Test exhaustion " ` Quick test_gas_exhaustion ; Tztest . tztest " Test exhaustion before error " ` Quick test_gas_exhaustion_before_error ; Tztest . tztest " Test successful result " ` Quick test_successful_with_remaining_gas ; Tztest . tztest " Test successful result " ` Quick test_succ...
let extract_qcheck_result = function | Ok pure_result -> pure_result | Error err -> Format . printf " @\ n % a . " @ Environment . Error_monad . pp_trace err ; false
let test_free_neutral ( start , any_cost ) = let open Alpha_context in extract_qcheck_result ( Gas . consume start Gas . free >>? fun free_first -> Gas . consume free_first any_cost >>? fun branch1 -> Gas . consume start any_cost >>? fun cost_first -> Gas . consume cost_first Gas . free >|? fun branch2 -> let equal_con...
let test_free_consumption start = let open Alpha_context in extract_qcheck_result ( Gas . consume start Gas . free >|? fun after_empty_consumption -> Gas . Arith . ( qcheck_eq ~ pp ~ eq : equal ( Gas . consumed ~ since : start ~ until : after_empty_consumption ) zero ) )
let test_consume_commutes ( start , cost1 , cost2 ) = let open Alpha_context in extract_qcheck_result ( Gas . consume start cost1 >>? fun after_cost1 -> Gas . consume after_cost1 cost2 >>? fun branch1 -> Gas . consume start Gas . ( cost1 +@ cost2 ) >|? fun branch2 -> Gas . Arith . ( qcheck_eq ~ pp ~ eq : equal ( Gas . ...
let context_arb : Alpha_context . t QCheck . arbitrary = QCheck . always ( Lwt_main . run ( Context . init 1 >>=? fun ( b , _contracts ) -> Incremental . begin_construction b >|=? fun inc -> let state = Incremental . validation_state inc in Alpha_context . Gas . set_limit state . ctxt Alpha_context . Gas . Arith . ( fp...
let gas_cost_arb : Alpha_context . Gas . cost QCheck . arbitrary = let open Alpha_context . Gas in let open QCheck in let rand = 0 -- 1000 in let safe_rand = map Saturation_repr . safe_int rand in choose [ map atomic_step_cost safe_rand ; map step_cost safe_rand ; map alloc_cost safe_rand ; map alloc_bytes_cost rand ; ...
let tests = [ QCheck . Test . make ~ count : 1000 ~ name " : Consuming commutes " QCheck . ( triple context_arb gas_cost_arb gas_cost_arb ) test_consume_commutes ; QCheck . Test . make ~ count : 1000 ~ name " : Consuming [ free ] consumes nothing " context_arb test_free_consumption ; QCheck . Test . make ~ count : 1000...
let ( ) = Alcotest . run " gas properties " [ ( " gas properties " , qcheck_wrap tests ) ]
let ok = ref false
let finalise _ = ok := true
let test ( ) = let success = true in let % lwt bus = OBus_bus . session ( ) in let % lwt ( ) = print " safety check : " in let event = ref 0 in ok := false ; Gc . finalise finalise event ; let event = 1 in ignore event ; Gc . full_major ( ) ; let % lwt ( ) = printl ( if ! ok then " success " else " failure " ) in let s...
type ' a t = ' a Generator . t
let generate = Generator . generate let int_up_to_size = Generator . create ( fun ~ size ~ random -> Splittable_random . int random ~ lo : 0 ~ hi : size ) in let random = Splittable_random . State . create Random . State . default in List . init 30 ~ f ( : fun size -> Generator . generate int_up_to_size ~ size ~ random...
let perturb = Generator . perturb let gen = Generator . create ( fun ~ size : _ ~ random -> Splittable_random . int random ~ lo : 0 ~ hi : 9 ) in let size = 0 in List . init 10 ~ f ( : fun salt -> let random = Splittable_random . State . of_int 0 in let gen = Generator . perturb gen salt in List . init 10 ~ f ( : fun _...
let size = Generator . size test_generator Generator . size ( m_nat ~ up_to : 30 ) ; [ % expect { | ( generator exhaustive ) } ] | ; ;
let sizes = Generator . sizes test_generator ~ mode ` : inexhaustive ( Generator . sizes ( ) ) ( m_list ( m_nat ~ up_to : 10 ) ) ; [ % expect { | ( generator ( " generated 3_724 distinct values in 10_000 iterations " ( " did not generate these values " ( ( 0 10 ) ( 10 0 ) ) ) ) ) } ] ; | show_distribution ( Generator ....
let with_size = Generator . with_size test_generator ~ mode ` : inexhaustive ( Generator . with_size ~ size : 0 Generator . size ) ( m_nat ~ up_to : 10 ) ; [ % expect { | ( generator ( " generated 1 distinct values in 10_000 iterations " ( " did not generate these values " ( 1 2 3 4 5 6 7 8 9 10 ) ) ) ) } ] | ; ;
let filter = Generator . filter let is_even int = int % 2 = 0 in test_generator ~ mode ` : inexhaustive ( Generator . filter ~ f : is_even Generator . size ) ( m_nat ~ up_to : 30 ) ; [ % expect { | ( generator ( " generated 16 distinct values in 10_000 iterations " ( " did not generate these values " ( 1 3 5 7 9 11 13 ...
let filter_map = Generator . filter_map let exactly_half int = if int % 2 = 0 then Some ( int / 2 ) else None in test_generator ( Generator . filter_map ~ f : exactly_half Generator . size ) ( m_nat ~ up_to : 15 ) ; [ % expect { | ( generator exhaustive ) } ] | ; ;
let of_list = Generator . of_list test_generator ( Generator . of_list Bool . all ) m_bool ; [ % expect { | ( generator exhaustive ) } ] | ; ;
let of_weighted_list = Generator . of_weighted_list test_generator ~ mode ` : inexhaustive ( Generator . of_weighted_list ( List . init 31 ~ f ( : fun size -> Float . of_int size , size ) ) ) ( m_nat ~ up_to : 30 ) ; [ % expect { | ( generator ( " generated 30 distinct values in 10_000 iterations " ( " did not generate...
let union = Generator . union test_generator ( Generator . union ( List . init 31 ~ f ( : fun size -> Generator . return size ) ) ) ( m_nat ~ up_to : 30 ) ; [ % expect { | ( generator exhaustive ) } ] | ; ;
let weighted_union = Generator . weighted_union test_generator ~ mode ` : inexhaustive ( Generator . weighted_union ( List . init 31 ~ f ( : fun size -> Float . of_int size , Generator . return size ) ) ) ( m_nat ~ up_to : 30 ) ; [ % expect { | ( generator ( " generated 30 distinct values in 10_000 iterations " ( " did...
let fixed_point = Generator . fixed_point test_generator ~ mode ` : inexhaustive ( Generator . fixed_point ( fun generator -> Generator . bind Generator . bool ~ f ( : function | false -> Generator . return 0 | true -> Generator . map generator ~ f : Int . succ ) ) ) ( m_nat ~ up_to : 30 ) ; [ % expect { | ( generator ...