text
stringlengths
0
601k
let synchronous_interface_tests = [ ( " kstream . sync . stream , next " >:: fun _ -> let emitted = ref false in let s = stream ( fun ( ) -> if not ! emitted then ( emitted := true ; Some " foo " ) else None ) in next s |> assert_equal ~ msg " : foo " ( Some " foo " ) ; next s |> assert_equal ~ msg " : empty " None ) ;...
let tests = internal_tests @ synchronous_interface_tests
module Testable = struct open Mdx . Label let relation = Alcotest . testable Relation . pp ( = ) let msg = Alcotest . testable ( fun fmt ( ` Msg e ) -> Format . pp_print_string fmt e ) ( = ) let label = Alcotest . testable pp ( = ) end
let test_raw_parse = let ty = Alcotest . ( pair string ( option ( pair Testable . relation string ) ) ) in let make_test ~ input ~ expected = let test_name = Printf . sprintf " raw_parse : % S " input in let test_fun ( ) = Alcotest . check ty test_name expected ( Mdx . Label . Relation . raw_parse input ) in ( test_nam...
let test_interpret = let ty = Alcotest . result Testable . label Testable . msg in let make_test ~ label ~ value ~ expected = let test_name = Printf . sprintf " interpret : % S " label in let test_fun ( ) = Alcotest . check ty test_name expected ( Mdx . Label . interpret label value ) in ( test_name , ` Quick , test_fu...
let test_of_string = let ty = Alcotest . ( result ( list Testable . label ) ( list Testable . msg ) ) in let make_test ~ input ~ expected = let test_name = Printf . sprintf " of_string : % S " input in let test_fun ( ) = Alcotest . check ty test_name expected ( Mdx . Label . of_string input ) in ( test_name , ` Quick ,...
let suite = ( " Label " , test_raw_parse @ test_interpret @ test_of_string )
let r = ref 0 in let t = return ( ) >>= fun ( ) -> Int . incr r ; return ( ) in assert ( ! r = 0 ) ; force t ; assert ( ! r = 1 ) ; force t ; assert ( ! r = 1 ) ; ; let r = ref 0 in let t = return ( ) >>= fun ( ) -> lazy ( Int . incr r ) in assert ( ! r = 0 ) ; force t ; assert ( ! r = 1 ) ; force t ; assert ( ! r = 1 ...
let ids = [ | 1 ; 42 ; 1337 ; 1984 ] | |> Array . map Z . of_int |> Array . map Lazy_storage_kind . Big_map . Id . parse_z
let strs = [ " | 0 " ; " True " ; " nat " ; " bool " ] |
let exprs = strs |> Array . map Expr . from_string
let hashes = strs |> Array . map ( fun x -> [ x ] ) |> Array . map Script_expr_hash . hash_string
let updates_len_existing = [ 1 ; 2 ; 3 ]
let updates_len_other = 0 :: updates_len_existing
let gen_inits idx : ( ( Lazy_storage_kind . Big_map . Id . t , Lazy_storage_kind . Big_map . alloc ) Lazy_storage_diff . init * int list ) list = [ ( Existing , updates_len_existing ) ; ( Copy { src = ids . ( idx - 1 ) } , updates_len_other ) ; ( Alloc { key_type = exprs . ( idx ) ; value_type = exprs . ( idx - 1 ) } ,...
let gen_update_list idx : Lazy_storage_kind . Big_map . update list = [ None ; Some exprs . ( idx ) ] |> List . map ( fun value -> Lazy_storage_kind . Big_map . { key = exprs . ( idx ) ; key_hash = hashes . ( idx ) ; value } )
let rec gen_updates updates_len : Lazy_storage_kind . Big_map . updates list = if updates_len = 0 then [ ] else gen_updates ( updates_len - 1 ) |> List . map ( fun suffix -> gen_update_list updates_len |> List . map ( fun prefix -> prefix :: suffix ) ) |> List . flatten
let gen_updates_list updates_lens : Lazy_storage_kind . Big_map . updates list = updates_lens |> List . map gen_updates |> List . flatten
let gen_diffs idx : ( Lazy_storage_kind . Big_map . Id . t , Lazy_storage_kind . Big_map . alloc , Lazy_storage_kind . Big_map . updates ) Lazy_storage_diff . diff list = let open Lazy_storage_diff in Remove :: ( gen_inits idx |> List . map ( fun ( init , updates_lens ) -> gen_updates_list updates_lens |> List . map ( ...
let gen_diffs_items idx : Lazy_storage_diff . diffs_item list = let id = ids . ( idx ) in gen_diffs idx |> List . map ( fun diff -> Lazy_storage_diff . make Big_map id diff )
let rec gen_diffs_list len : Lazy_storage_diff . diffs list = if len = 0 then [ ] else gen_diffs_list ( len - 1 ) |> List . map ( fun suffix -> gen_diffs_items len |> List . map ( fun prefix -> prefix :: suffix ) ) |> List . flatten
let diffs_list_lens = [ 0 ; 1 ; 2 ; 3 ]
let diffs_list : Lazy_storage_diff . diffs list = diffs_list_lens |> List . map gen_diffs_list |> List . flatten
let conversion_roundtrip lazy_storage_diff = let legacy_big_map_diff = Contract_storage . Legacy_big_map_diff . of_lazy_storage_diff lazy_storage_diff in let reconverted = Contract_storage . Legacy_big_map_diff . to_lazy_storage_diff legacy_big_map_diff in assert ( Stdlib . ( = ) reconverted lazy_storage_diff )
let encoding_roundtrip lazy_storage_diff = let encoded = Data_encoding . Binary . to_bytes_exn Lazy_storage_diff . encoding lazy_storage_diff in match Data_encoding . Binary . of_bytes Lazy_storage_diff . encoding encoded with | Ok decoded -> assert ( Stdlib . ( = ) decoded lazy_storage_diff ) | Error _ -> Stdlib . fai...
let on_diffs f ( ) = List . iter f diffs_list ; return_unit
let tests = [ Tztest . tztest " conversion roundtrip " ` Slow ( on_diffs conversion_roundtrip ) ; Tztest . tztest " encoding roundtrip " ` Slow ( on_diffs encoding_roundtrip ) ; ]
let scy_addr = Uint16 . of_int 0xFF42
let scx_addr = Uint16 . of_int 0xFF43
let ly_addr = Uint16 . of_int 0xFF44
let lyc_addr = Uint16 . of_int 0xFF45
let wy_addr = Uint16 . of_int 0xFF4A
let wx_addr = Uint16 . of_int 0xFF4B
let create ( ) = Lcd_position . create ~ scy_addr ~ scx_addr ~ ly_addr ~ lyc_addr ~ wy_addr ~ wx_addr let t = create ( ) in [ scy_addr ; scx_addr ; ly_addr ; lyc_addr ; wy_addr ; wx_addr ] |> List . map ( Lcd_position . read_byte t ) |> List . map Uint8 . show |> List . iter print_endline ; [ % expect { | $ 00 $ 00 $ 0...
let addr = ( Uint16 . of_int 0xFF41 ) let t = Lcd_stat . create ~ addr in Lcd_stat . read_byte t addr |> Uint8 . show |> print_endline ; [ % expect { | $ 82 } ] | let t = Lcd_stat . create ~ addr in Gpu_mode . [ HBlank ; VBlank ; OAM_search ; Pixel_transfer ] |> List . iter ( fun mode -> Lcd_stat . set_gpu_mode t mode ...
let flts = [ 1 . 1234 ; - 94 . 1239823897423 ; 0 . 000000000000012 ; 0 . 12130981239081238973249872349871346123873264876324 ; - 3 . 92 ]
let op1 f a = LDouble . ( to_float ( f ( of_float a ) ) )
let op2 f a b = LDouble . ( to_float ( f ( of_float a ) ( of_float b ) ) )
let chk_float x y = match classify_float x , classify_float y with | FP_normal , FP_normal | FP_subnormal , FP_subnormal | FP_zero , FP_normal | FP_zero , FP_subnormal | FP_normal , FP_zero | FP_subnormal , FP_zero -> abs_float ( x . - y ) < 1e - 12 | x , y when x = y -> true | _ -> false
let chk1 fop lop a = let x = fop a in let y = op1 lop a in chk_float x y
let chk2 fop lop a b = let x = fop a b in let y = op2 lop a b in chk_float x y
let test_op2 _ = let assert_chk2 n f l = List . iter ( fun a -> List . iter ( fun b -> assert_bool n @@ chk2 f l a b ) flts ) flts in assert_chk2 " add " ( . ) + LDouble . add ; assert_chk2 " sub " ( . ) - LDouble . sub ; assert_chk2 " mul " ( . * ) LDouble . mul ; assert_chk2 " div " ( . / ) LDouble . div ; assert_chk...
let test_op1 _ = let assert_chk1 n f l = List . iter ( fun a -> assert_bool n @@ chk1 f l a ) flts in assert_chk1 " neg " ( fun x -> . - x ) LDouble . neg ; assert_chk1 " sqrt " sqrt LDouble . sqrt ; assert_chk1 " exp " exp LDouble . exp ; assert_chk1 " log " log LDouble . log ; assert_chk1 " log10 " log10 LDouble . lo...
let test_opw _ = let chk_frexp a = let x , i = frexp a in let y , j = LDouble . ( frexp ( of_float a ) ) in let y = LDouble . to_float y in assert_bool " frexp " ( chk_float x y && i = j ) in let chk_modf a = let w , x = modf a in let y , z = LDouble . ( modf ( of_float a ) ) in let y , z = LDouble . ( to_float y , to_...
let test_classify _ = assert_bool " min " LDouble . ( classify min_float = FP_normal ) ; assert_bool " max " LDouble . ( classify max_float = FP_normal ) ; assert_bool " epsilon " LDouble . ( classify max_float = FP_normal ) ; assert_bool " nan " LDouble . ( classify nan = FP_nan ) ; assert_bool " inf " LDouble . ( cla...
let test_conv _ = List . iter ( fun a -> assert_bool " to / of_float " ( a = LDouble . ( to_float ( of_float a ) ) ) ) flts ; assert_bool " to_int " ( 3 = LDouble . ( to_int ( of_float 3 . 45 ) ) ) ; assert_bool " to_int " ( - 34 = LDouble . ( to_int ( of_float ( - 34 . 999 ) ) ) ) ; assert_bool " mant_dig " ( LDouble ...
let test_complex _ = let module C = Complex in let cplx = [ { C . re = 2 . 9 ; im = 4 . 26 } ; { C . re = 0 . 32 ; im = - 7 . 6 } ; { C . re = - 35 . 1 ; im = 12 . 3 } ; { C . re = - 0 . 002 ; im = - 9 . 1 } ; ] in let chk_complex ( ? prec = 1e - 12 ) x y = C . norm ( C . sub x y ) < prec in let assert_chk2 ? prec name...
let test_marshal _ = let same_repr x y = let open Obj in let x = magic x in let y = magic y in is_block x && is_block y && size x = size y && tag x = tag y in let assert_ldouble x = let ( _ , xc , _ ) as x = " foo " , LDouble . of_float x , 1 in let s = Marshal . to_string x [ ] in let ( ( _ , yc , _ ) : string * LDoub...
let test_comparisons _ = let open LDouble in begin assert_equal false ( neg_infinity < nan ) ; assert_equal false ( nan < neg_infinity ) ; assert_equal false ( infinity < nan ) ; assert_equal false ( nan < infinity ) ; assert_equal false ( of_float 1 . 0 < nan ) ; assert_equal false ( nan < of_float 1 . 0 ) ; assert_eq...
let test_int_conversions _ = begin assert_equal max_int ( LDouble . to_int ~ printer : string_of_int ; assert_equal min_int ( LDouble . to_int ~ printer : string_of_int ; end
let suite = " LDouble tests " >::: [ " test functions with 2 args " >:: test_op2 ; " test functions with 1 args " >:: test_op1 ; " test functions with weird args " >:: test_opw ; " test classify " >:: test_classify ; " test conversion " >:: test_conv ; " test complex api " >:: test_complex ; " test marshal " >:: test_m...
let _ = run_test_tt_main suite
let count , run_count = let v = ref 0 in let count , send_count = E . create ( ) in let rec run_count ( ) = incr v ; send_count ! v ; ignore ( G . set_timeout ~ ms : 0 run_count ) in count , run_count
let count_value count = let p = El . p [ ] in let count_txt c = [ El . txt Jstr . ( v " Steps : " + of_int c ) ] in let count = S . hold [ ] ( E . map count_txt count ) in Elr . def_children p count ; p
let count_value_nest count = let p = El . p [ ] in let count_txt c = [ El . txt Jstr . ( v " Steps ( nest ) : " + of_int c ) ] in let count = S . hold [ ] ( E . map count_txt count ) in Elr . def_children p count ; El . div [ p ]
let steps ( ) = let steps = El . div [ ] in let children = let counts c = [ count_value count ; count_value_nest count ] in S . hold [ ] ( E . map counts count ) in Elr . def_children steps children ; steps
let main ( ) = let h1 = El . h1 [ El . txt ' " No leaks " ] ! in let i = " Memory usage must be bounded and the counters must not slow down . " in let info = El . p [ El . txt ' i ] in El . set_children ( Document . body G . document ) [ h1 ; info ; steps ( ) ] ; run_count ( )
let ( ) = main ( )
let test reg leds = lightLeds leds ; Printf . printf " The pulse mode . . . \ n " ; %! applyRegPulse reg leds 2 . ; Printf . printf " The classic mode . . . \ n " ; %! applyRegAll reg leds ; Unix . sleep 2 ; Printf . printf " Only one led :\ n " ; %! clearLeds leds ; leds . ( 1 ) <- true ; Printf . printf " The pulse m...
let _ = let what = Sys . argv . ( 1 ) in Printf . printf " % s \ n " Sys . argv . ( 1 ) ; ignore ( setupPhys ( ) ) ; let reg = genReg 11 13 15 ~ invert : false in let leds = initReg reg ~ nb_reg : 2 in let t = true and f = false in clearLeds leds ; if what = " g " then begin let make_t n k = clearLeds leds ; for k = 0 ...
let dummy_source_code_position = Source_code_position . { pos_fname = " file_name . ml " ; pos_lnum = 0 ; pos_bol = 0 ; pos_cnum = 0 } ; ;
let run_test ( ~ component : _ Bonsai . Arrow_deprecated . t ) ~ initial_input ~ f = let driver component = Driver . create component ~ initial_input ~ clock : Incr . clock in f ( driver component ) ; ;
module Helpers = struct include Helpers let make ~ driver = Helpers . make ~ driver let make_string ~ driver = Helpers . make_string ~ driver let make_string_with_inject ~ driver = Helpers . make_string_with_inject ~ driver let make_with_inject ~ driver = Helpers . make_with_inject ~ driver end
module Counter_component = struct module Input = Unit module Model = Int module Action = struct type t = | Increment | Decrement [ @@ deriving sexp_of ] end module Result = struct type t = string * ( Action . t -> unit Effect . t ) end let apply_action ~ inject : _ ~ schedule_event : _ ( ) model : Action . t -> Model ....
module _ = struct open Bonsai . Arrow_deprecated . Let_syntax let dummy ( type t ) ( module M : Bonsai . Arrow_deprecated . Model with type t = t ) ~ default = Bonsai . Arrow_deprecated . state_machine ( module M ) ( module M ) [ % here ] ~ default_model : default ~ apply_action ( : fun ~ inject : _ ~ schedule_event : ...
let test_create_cycle_eras ( ) = let empty_cycle_eras = Level_repr . create_cycle_eras [ ] |> Environment . wrap_tzresult in Assert . proto_error ~ loc : __LOC__ empty_cycle_eras ( function | Level_repr . Invalid_cycle_eras -> true | _ -> false ) >>=? fun ( ) -> let increasing_first_levels = [ Level_repr . { first_leve...
let test_case_1 = ( [ Level_repr . { first_level = Raw_level_repr . of_int32_exn 1l ; first_cycle = Cycle_repr . root ; blocks_per_cycle = 8l ; blocks_per_commitment = 2l ; } ; ] , [ ( 1 , ( 1 , 0 , 0 , 0 , false ) ) ; ( 2 , ( 2 , 1 , 0 , 1 , true ) ) ; ( 3 , ( 3 , 2 , 0 , 2 , false ) ) ; ( 8 , ( 8 , 7 , 0 , 7 , true )...
let test_case_2 = ( List . rev [ Level_repr . { first_level = Raw_level_repr . of_int32_exn 1l ; first_cycle = Cycle_repr . root ; blocks_per_cycle = 8l ; blocks_per_commitment = 2l ; } ; { first_level = Raw_level_repr . of_int32_exn 17l ; first_cycle = Cycle_repr . of_int32_exn 2l ; blocks_per_cycle = 16l ; blocks_per...
let test_case_3 = ( List . rev [ Level_repr . { first_level = Raw_level_repr . of_int32_exn 1l ; first_cycle = Cycle_repr . root ; blocks_per_cycle = 8l ; blocks_per_commitment = 2l ; } ; { first_level = Raw_level_repr . of_int32_exn 17l ; first_cycle = Cycle_repr . of_int32_exn 2l ; blocks_per_cycle = 16l ; blocks_per...
let test_level_from_raw ( ) = List . iter_es ( fun ( cycle_eras , test_cases ) -> List . iter_es ( fun ( input_level , ( level , level_position , cycle , cycle_position , expected_commitment ) ) -> let raw_level = Raw_level_repr . of_int32_exn ( Int32 . of_int input_level ) in Level_repr . create_cycle_eras cycle_eras ...
let test_first_level_in_cycle ( ) = let cycle_eras = fst test_case_3 in let test_cases = [ ( 0l , 1 ) ; ( 1l , 9 ) ; ( 2l , 17 ) ; ( 3l , 33 ) ; ( 4l , 49 ) ; ( 5l , 55 ) ; ( 6l , 61 ) ; ( 7l , 67 ) ; ] in let f ( input_cycle , level ) = Level_repr . create_cycle_eras cycle_eras |> Environment . wrap_tzresult >>?= fun ...
let tests = [ Tztest . tztest " create_cycle_eras " ` Quick test_create_cycle_eras ; Tztest . tztest " level_from_raw " ` Quick test_level_from_raw ; Tztest . tztest " first_level_in_cycle " ` Quick test_first_level_in_cycle ; ]
let test_lex_single input expected_tok test_ctxt = let tokenized = Lex . lex input in assert_equal 1 ( List . length tokenized ) ; assert_equal ( expected_tok ) ( List . hd tokenized )
let test_lex_multi input expected_toks test_ctxt = let tokenized = Lex . lex input in let rec compare_token_lists a b = match a with | [ ] -> assert_equal b [ ] | head :: tail -> assert_equal ( List . hd b ) head ; compare_token_lists tail ( List . tl b ) in compare_token_lists tokenized expected_toks
let test_expect_failure input fail_msg test_ctxt = let f = fun ( ) -> Lex . lex input in assert_raises ( Failure fail_msg ) f
let lex_char_tests = [ " test_lex_char " >:: test_lex_single " ' a ' " ( Char ' a ' ) ; " test_lex_char_esc " >:: test_lex_single " ' \\ n ' " ( Char ' \ n ' ) ; " test_lex_char_backslash " >:: test_lex_single " ' ' " \\\\ ( Char ' ' ) ; \\ " test_lex_char_hex " >:: test_lex_single " ' \\ x61 ' " ( Char ' a ' ) ; " tes...
let lex_int_tests = [ " test_lex_int " >:: test_lex_single " 3 " ( Int 3 ) ; " test_lex_zero " >:: test_lex_single " 0 " ( Int 0 ) ; " test_lex_int_max " >:: test_lex_single " 2147483647 " ( Int 2147483647 ) ; " test_lex_int_overflow " >:: test_expect_failure " 2147483648 " " Invalid int literal " ; " test_lex_int_unde...
let lex_keyword_tests = [ " test_lex_return_keyword " >:: test_lex_single " return " ReturnKeyword ; " test_lex_char_keyword " >:: test_lex_single " char " CharKeyword ; " test_lex_int_keyword " >:: test_lex_single " int " IntKeyword ; " test_lex_if_keyword " >:: test_lex_single " if " IfKeyword ; " test_lex_else_keywo...
let lex_punctuation_tests = [ " test_lex_openbrace " >:: test_lex_single " { " OpenBrace ; " test_lex_closebrace " >:: test_lex_single " } " CloseBrace ; " test_lex_openparen " >:: test_lex_single " ( " OpenParen ; " test_lex_closeparen " >:: test_lex_single " ) " CloseParen ; " test_lex_semicolon " >:: test_lex_single...
let lex_id_tests = [ " test_lex_id_simple " >:: test_lex_single " hello " ( Id " hello " ) ; " test_lex_id_underscore " >:: test_lex_single " _hell_o " ( Id " _hell_o " ) ; " test_lex_id_uppercase " >:: test_lex_single " HELLO " ( Id " HELLO " ) ; " test_lex_id_uppercase_return " >:: test_lex_single " RETURN " ( Id " R...
let lex_whitespace_tests = [ " test_leading_whitespace " >:: test_lex_single " foo " ( Id " foo " ) ; " test_leading_tab " >:: test_lex_single " \ t foo " ( Id " foo " ) ; " test_trailing_whitespace " >:: test_lex_single " 123 " ( Int 123 ) ; " test_trailing_tab " >:: test_lex_single " 0x81 \ t " ( Int 0x81 ) ; ]
let lex_multi_tests = [ " test_lex_negative " >:: test_lex_multi " - 1 " [ Minus ; Int 1 ] ; " test_lex_positive " >:: test_lex_multi " + 1 " [ Plus ; Int 1 ] ; " test_lex_brace_id " >:: test_lex_multi " } foo " [ CloseBrace ; Id " foo " ] ; " test_lex_brace_id_whitespace " >:: test_lex_multi " } bar " [ CloseBrace ; I...
let rec translate = { : lexer | " | current_directory " -> begin print_string ( Sys . getcwd ( ) ) ; translate lexbuf end | _ as c -> begin print_char c ; translate lexbuf ; end | ! -> exit 0 } | ; ;
let num_lines = ref 0
let num_chars = ref 0
let rec count = { : lexer | | ' \ n ' -> ( incr num_lines ; incr num_chars ; count lexbuf ) | _ -> ( incr num_chars ; count lexbuf ) | ! -> ( ) } |
let _ = begin ( count ( Lexing . from_channel ( open_in " testr / test_lexer . ml " ) ) ) ; Format . printf " % d % d \ n " ! num_lines ! num_chars ; end ; ; { : regexp | digit = [ ' 0 ' ' - 9 ' ] ; id = [ ' a ' ' - z ' ] [ ' a ' ' - z ' ' 0 ' ' - 9 ' ] * } ; ; |
let rec toy_lang = { : lexer | | digit + as inum -> ( printf " integer : % s ( % d ) \ n " inum ( int_of_string inum ) ; toy_lang lexbuf ) | digit + ' . ' digit * as fnum -> ( printf " float : % s ( % f ) \ n " fnum ( float_of_string fnum ) ; toy_lang lexbuf ) | " if " | " then " | " else " | " begin " | " end " | " le...
let _ = toy_lang ( Lexing . from_channel ( open_in " testr / test_lexer . ml " ) )
module QRReader : sig type t val create : unit -> t val id : t -> Uuidm . t val handler : t -> ( [ ` QRCode of QRCode . t ] , [ ` QRCode of QRCode . t ] ) Handler . t val use : t -> string -> unit type t = { id : Uuidm . t ; handler : ( [ ` QRCode of QRCode . t ] , [ ` QRCode of QRCode . t ] ) Handler . t ; } let creat...
module Controller : sig type t val create : int SMap . t -> t val handler : t -> ( [ ` QRCode of QRCode . t ] , [ ` User of User . t ] ) Handler . t val connect_readers : t -> QRReader . t list -> t type t = { id : Uuidm . t ; handler : ( [ ` QRCode of QRCode . t ] , [ ` User of User . t ] ) Handler . t ; } let create ...
module Door : sig type t val create : readers : UuidSet . t -> action ( : Uuidm . t -> string -> unit ) -> t val connect_controller : t -> Controller . t -> t type t = { id : Uuidm . t ; readers : UuidSet . t ; handler : ( [ ` User of User . t ] , [ ` Nil ] ) Handler . t ; } let create ~ readers ~ action = let id = Uui...
let prepare_library ( ) = project begin fun ( ) -> file " src / foo . ml " [ " let v = 1 " ] ; file " src / optional / bar . ml " [ " let v = Foo . v + 1 " ] ; file " src / optional_bar . ml " [ " include Optional . Bar " ] ; file " src / baz . ml " [ " exit 1 " ] ; file " src / optional / quux . ml " [ " exit 1 " ] ; ...
let depend ( ? optional = false ) code expect = depending begin fun ( ) -> let package = if optional then " test - library . optional " else " test - library " in file " src / main . ml " code ; tags [ " < src / main . *>: package ( " ^ package ^ " ) " ] ; ocamlbuild [ " main . byte " ; " main . native " ] ; let expect...
let tests = " library " >::: [ test " basic " begin fun ( ) -> prepare_library ( ) ; depend [ " Test_library . Foo . v |> string_of_int |> print_endline " ] 1 end ; test " optional " begin fun ( ) -> prepare_library ( ) ; depend ~ optional : true [ " Test_library . Optional . Bar . v |> string_of_int |> print_endline "...
let mk_tmpfile contents : string = let ( tmpfile_name , chan ) = Filename . open_temp_file " foo " " txt " in output_string chan contents ; close_out chan ; tmpfile_name
let coatCheck = Coat_check . create ( )
let alloc_uv_fs ( ) = let memory = allocate_n char ~ count : Uv_consts . size_of_uv_fs_t in coerce ( ptr char ) ( ptr C . uv_fs ) memory
let test_expired_callback ( ) = let filename = mk_tmpfile " hello " in let data = alloc_uv_fs ( ) in let _ = begin let cb fs = let _ = Obj . repr data in Printf . printf " XXX Called ' % s ' \ n " ( C . get_uv_fs_t_path fs ) in let tckt = Coat_check . ticket coatCheck in let ( ) = Coat_check . store coatCheck tckt ( Ob...
let test_store_callback_and_data ( ) = let filename = mk_tmpfile " foo " in let data = alloc_uv_fs ( ) in let nameRef = ref " " in let _ = begin let cb fs = nameRef := " XXX " in let safe = ( data , cb ) in let tckt = Coat_check . ticket coatCheck in let ( ) = Coat_check . store coatCheck tckt safe in let ( ) = Gc . co...