text
stringlengths
0
601k
let suite = " fs_suite " >::: [ " fs_stat " >:: test_fs_stat ; " fs_fstat " >:: test_fs_fstat ; " fs_lstat " >:: test_fs_lstat ; " fs_read " >:: test_fs_read ; " fs_write " >:: test_fs_write ; " fs_unlink " >:: test_fs_unlink ; " fs_mkdir " >:: test_fs_mkdir ; " fs_mkdtemp " >:: test_fs_mkdtemp ; " fs_rmdir " >:: test_...
let initGL ~ width ~ height = glClearColor 0 . 0 0 . 0 0 . 0 0 . 0 ; glClearDepth 1 . 0 ; glDepthFunc GL_LESS ; glEnable GL_DEPTH_TEST ; glShadeModel GL_SMOOTH ; glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; gluPerspective 45 . 0 ( ( float width ) . ( / float height ) ) 0 . 1 100 . 0 ; glMatrixMode GL_MODELVIEW ; ;...
let reshape ~ width ~ height = let height = if height = 0 then 1 else height in glViewport 0 0 width height ; glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; gluPerspective 45 . 0 ( ( float width ) . ( / float height ) ) 0 . 1 100 . 0 ; glMatrixMode GL_MODELVIEW ; ; ;
let display ~ font ( ) = glClear [ GL_COLOR_BUFFER_BIT ; GL_DEPTH_BUFFER_BIT ] ; glLoadIdentity ( ) ; glTranslate ( 0 . 0 ) ( 0 . 0 ) ( 0 . 0 ) ; ftglSetFontFaceSize font 72 72 ; ftglRenderFont font " Hello World " ! FTGL_RENDER_ALL ; glutSwapBuffers ( ) ; ; ;
let keyPressed ~ window ~ font ~ key ~ x ~ y = match key with | ' q ' | ' \ 027 ' -> ftglDestroyFont ~ font ; glutDestroyWindow window ; exit ( 0 ) ; | _ -> ( ) ; ;
let ( ) = ignore ( glutInit Sys . argv ) ; glutInitDisplayMode [ GLUT_RGBA ; GLUT_DOUBLE ; GLUT_ALPHA ; GLUT_DEPTH ] ; glutInitWindowSize 640 480 ; glutInitWindowPosition 0 0 ; let window = glutCreateWindow " FTGL Test " in let font = ftglCreatePixmapFont " / usr / share / fonts / ttf / western / Adventure . ttf " in g...
let ( ) = Backtrace . elide := true let r = ref None in let loop i = if i = 0 then 0 else ( match ! r with | None -> assert false | Some v -> print_s [ % message ( i : int ) ] ; 1 + Value . to_int_exn ( Value . funcall1 v ( i - 1 |> Value . of_int_exn ) ) ) in r := Some ( Function . to_value ( lambda [ % here ] ( Retur...
let eval_string s = s |> Form . Blocking . eval_string
let emacs_raise ( ) = Funcall . Wrap . ( " signal " <: Symbol . t @-> int @-> return nil ) ( " error " |> Symbol . intern ) 13 ; ;
let emacs_try_with = " ( lambda ( f ) ( condition - case error ( funcall f ) ( error ` ( emacs - caught - it , error ) ) ) ) " |> eval_string ; ;
let ocaml_raise = lambda_nullary_nil [ % here ] ( fun ( ) -> raise_s [ % message " raising " ] ) |> Function . to_value ; ; show_raise emacs_raise ; [ % expect { | ( raised 13 ) } ] ; | return ( ) ; ; print_s [ % sexp ( Value . funcall1 emacs_try_with ocaml_raise : Value . t ) ] ; [ % expect { | ( emacs - caught - it (...
let filter_meaningless_char str = String . split_on_char ' ' ' \ str |> String . concat " " |> Str . ( split ( regexp " ( " ) " ) ) \\\\“\\|\\”\\|\\\ |> String . concat " "
let test_glib_check_version test_ctxt = let open Unsigned . UInt32 in let major = of_int32 GLib . Core . c_MAJOR_VERSION in let minor = of_int32 GLib . Core . c_MINOR_VERSION in let micro = of_int32 GLib . Core . c_MICRO_VERSION in match GLib . Core . check_version major minor micro with | None -> assert_equal_string "...
let test_filename_to_uri_ok test_ctxt = let path " =/ var " in match GLib . Core . filename_to_uri path None with | Error e -> assert_equal_string " This should not " " have been reached " | Ok uri -> match uri with | None -> assert_equal_string " This should not " " have been reached " | Some uri ' -> assert_equal_str...
let test_filename_from_uri_no_hostname test_ctxt = let uri = " file :/// etc / mpd . conf " in match GLib . Core . filename_from_uri uri with | Error e -> assert_equal_string " GError : This should not " " have been reached " | Ok ( filename_opt , hostname_opt ) -> let _ = match filename_opt with | None -> assert_equal...
let test_filename_to_uri_error test_ctxt = let path " = a_totally_bad_path_that_should_not_exist " in let expected = " The pathname a_totally_bad_path_that_should_not_exist is \ not an absolute path " in let _ = match GLib . Core . filename_to_uri path None with | Error e -> ( match e with | None -> assert_equal_string...
let test_filename_from_uri_bad_uri test_ctxt = let uri = " noprotocoletcmpd . conf " in let expected = " The URI noprotocoletcmpd . conf is not an absolute URI using the file scheme " in match GLib . Core . filename_from_uri uri with | Error e -> ( match e with | None -> assert_equal_string " This should not " " have b...
let test_filename_from_uri_with_hostname test_ctxt = let uri = " file :// localhost / etc / mpd . conf " in match GLib . Core . filename_from_uri uri with | Error e -> assert_equal_string " GError : This should not " " have been reached " | Ok ( filename_opt , hostname_opt ) -> let _ = match filename_opt with | None ->...
let test_get_charset_ok test_ctxt = let ( is_utf8 , charset ) = GLib . Core . get_charset ( ) in if is_utf8 then assert_equal_string " UTF - 8 " charset else assert ( " UTF - 8 " <> charset )
let test_dir_make_tmp test_ctxt = match GLib . Core . dir_make_tmp None with | Error _ -> assert_equal_string " Error with dir_make_tmp " " this should not have been reached " | Ok tmp_opt -> match tmp_opt with | None -> assert_equal_string " no tmp " " this should not have been reached " | Some tmp -> assert_file_exis...
let tests = " GLib functions tests " >::: [ " Test glib check version " >:: test_glib_check_version ; " Test glib filename_to_uri ok " >:: test_filename_to_uri_ok ; " Test glib filename_to_uri with error " >:: test_filename_to_uri_error ; " Test glib get_charset ok " >:: test_get_charset_ok ; " Test glib dir_make_tmp "...
module Maybe = struct type ' a t = ' a option [ @@ deriving_inline sexp_grammar ] let _ = fun ( _ : ' a t ) -> ( ) let ( t_sexp_grammar : Ppx_sexp_conv_lib . Sexp . Private . Raw_grammar . t ) = let ( _the_generic_group : Ppx_sexp_conv_lib . Sexp . Private . Raw_grammar . generic_group ) = { implicit_vars = [ " option ...
module Make ( T : sig type ' a t [ @@ deriving sexp_grammar ] end ) = struct [ @@@ warning " - 37 " ] type ' a t = T of ' a T . t u and ' a u = U of ' a T . t t Maybe . t [ @@ deriving_inline sexp_grammar ] let _ = fun ( _ : ' a t ) -> ( ) let _ = fun ( _ : ' a u ) -> ( ) let ( ( t_sexp_grammar : Ppx_sexp_conv_lib . Se...
module T1 = Make ( Maybe )
module T2 = Make ( T1 )
type t = int T2 . t * int T1 . t [ @@ deriving_inline sexp_grammar ]
let _ = fun ( _ : t ) -> ( )
let ( t_sexp_grammar : Ppx_sexp_conv_lib . Sexp . Private . Raw_grammar . t ) = let ( _the_generic_group : Ppx_sexp_conv_lib . Sexp . Private . Raw_grammar . generic_group ) = { implicit_vars = [ " int " ; " T2 . t " ; " T1 . t " ] ; ggid = " \ 023 \ 203 \ 177 ! 5 ( \\ B1 \ 167 \ 214 \ 007S \ 000 \ 134B " ; types = [ (...
let _ = t_sexp_grammar [ @@@ end ]
let detect_funptr_leaks ( ? expected_number_of_leaked_funptrs = 0 ) f = let number_of_leaked_funptrs = ref 0 in Foreign . report_leaked_funptr := ( fun _msg -> number_of_leaked_funptrs := ! number_of_leaked_funptrs + 1 ) ; Gc . full_major ( ) ; Gc . full_major ( ) ; assert_equal 0 ! number_of_leaked_funptrs ; let res =...
module Common_tests ( S : Cstubs . FOREIGN with type ' a result = ' a and type ' a return = ' a ) = struct module M = Functions . Stubs ( S ) let make_f ( ) : ( int -> int ) * ( [ ` Live ` | Released ] -> unit ) = let closure_status = ref ` Live in let f = ( ! ref ( ) ) + 1 in Gc . finalise ( fun _ -> closure_status :=...
let suite = " Dynamic - Funptr tests " >::: [ " test_of_fun_and_free ( foreign ) " >:: Foreign_tests . test_of_fun_and_free ; " test_of_fun_and_free ( stubs ) " >:: Stub_tests . test_of_fun_and_free ; " test_of_fun_and_leak ( foreign ) " >:: Foreign_tests . test_of_fun_and_leak ; " test_of_fun_and_leak ( stubs ) " >:: ...
let _ = run_test_tt_main suite
let s x = let to_string : _ -> _ = Js . Unsafe . eval_string { | ( function ( x ) { if ( x === null ) return " null " if ( x === undefined ) return " undefined " if ( typeof x === " function " ) return " function " # + x . length if ( x . toString ( ) == " [ object Arguments ] " ) return " ( Arguments : " + Array . pro...
let call_and_log f str = let call : _ -> _ = Js . Unsafe . eval_string str in let r = call f in Printf . printf " Result : % s " ( s r )
let cb1 a = Printf . printf " got % s , done \ n " ( s a )
let cb2 a b = Printf . printf " got % s , % s , done \ n " ( s a ) ( s b )
let cb3 a b c = Printf . printf " got % s , % s , % s , done \ n " ( s a ) ( s b ) ( s c )
let cb4 a b c d = Printf . printf " got % s , % s , % s , % s , done \ n " ( s a ) ( s b ) ( s c ) ( s d )
let cb5 a b c d e = Printf . printf " got % s , % s , % s , % s , % s , done \ n " ( s a ) ( s b ) ( s c ) ( s d ) ( s e ) call_and_log ( Js . wrap_callback cb3 ) { | ( function ( f ) { return f ( 1 , 2 , 3 , 4 ) } ) } ; | [ % expect { | got 1 , 2 , 3 , done Result : 0 } ] | call_and_log ( Js . wrap_callback cb3 ) { | ...
let rec log_pause n = if n <= 0 then Lwt . return_unit else let open Lwt_syntax in let * ( ) = Lwt . pause ( ) in log_pause ( n / 8 )
module Fn = struct let lambda s l = let open QCheck in make ~ print ( : fun _ -> s ) ( Gen . return l ) let pred = QCheck . oneof [ lambda " ( fun x _ -> x > 0 ) " ( fun x _ -> x > 0 ) ; lambda " ( fun _ y -> y < 0 ) " ( fun _ y -> y < 0 ) ; lambda " ( fun _ _ -> false ) " ( fun _ _ -> false ) ; lambda " ( fun _ _ -> t...
module Apply = struct let fn fn x y = fn x y end
module Apply2 = struct let fn fn x y z = fn x ( fn y z ) end
module IterOf = struct let fn r fn y = r := fn ! r y end
module IteriOf = struct let fn r fn i y = r := fn ! r ( fn i y ) end
module Iter2Of = struct let fn r fn x y = r := fn ! r ( fn x y ) end
module MapOf = struct let fn const fn elt = fn const elt end
module FilterMapOf = struct let fns cond fn const elt = if cond const elt then Some ( fn const elt ) else None end
module ConcatMapOf = struct let fns of_list fn consta constb elt = of_list [ fn consta elt ; fn constb elt ] end
module IterEOf = struct open Result_syntax let fn r fn y = r := fn ! r y ; return_unit let fn_e r fn y = let * t = fn ! r y in r := t ; return_unit end
module IteriEOf = struct open Result_syntax let fn r fn i y = r := fn ! r ( fn i y ) ; return_unit let fn_e r fn i y = let * z = fn i y in let * t = fn ! r z in r := t ; return_unit end
module Iter2EOf = struct open Result_syntax let fn r fn x y = r := fn x y ; return_unit let fn_e r fn x y = let * t = fn x y in r := t ; return_unit end
module FoldEOf = struct let fn fn acc elt = Ok ( fn acc elt ) let fn_e fn acc elt = fn acc elt end
module Fold2EOf = struct open Result_syntax let fn fn acc x y = Ok ( fn acc ( fn x y ) ) let fn_e fn acc x y = let * z = fn x y in fn acc z end
module MapEOf = struct let fn const fn elt = Ok ( fn const elt ) let fn_e const fn elt = fn const elt end
module Map2EOf = struct let fn fn x y = Ok ( fn x y ) let fn_e fn x y = fn x y end
module CondEOf = struct let fn fn const elt = Ok ( fn const elt ) let fn_e fn const elt = fn const elt end
module CondMapEOf = struct let fn fn const elt = Ok ( fn const elt ) let fn_e fn const elt = fn const elt end
module Cond2EOf = struct let fn fn x y = Ok ( fn x y ) let fn_e fn x y = fn x y end
module FilterMapEOf = struct open Result_syntax let fns cond fn const elt = Ok ( if cond const elt then Some ( fn const elt ) else None ) let fns_e cond fn const elt = let + b = cond const elt in if b then Some ( fn const elt ) else None end
module ConcatMapEOf = struct let fns of_list fn consta constb elt = Ok ( of_list [ fn consta elt ; fn constb elt ] ) end
module IterSOf = struct open Lwt_syntax let fn r fn y = r := fn ! r y ; return_unit let monotonous r fn const y = r := ! r + fn const y ; return_unit let fn_s r fn y = let * t = fn ! r y in r := t ; return_unit end
module IteriSOf = struct open Lwt_syntax let fn r fn i y = r := fn ! r ( fn i y ) ; return_unit let fn_s r fn i y = let * z = fn i y in let * t = fn ! r z in r := t ; return_unit end
module Iter2SOf = struct open Lwt_syntax let fn r fn x y = r := fn x y ; return_unit let fn_s r fn x y = let * t = fn x y in r := t ; return_unit end
module FoldSOf = struct let fn fn acc elt = Lwt . return ( fn acc elt ) let fn_s fn acc elt = fn acc elt end
module Fold2SOf = struct open Lwt_syntax let fn fn acc x y = return ( fn acc ( fn x y ) ) let fn_s fn acc x y = let * z = fn x y in fn acc z end
module MapSOf = struct let fn const fn elt = Lwt . return ( fn const elt ) let fn_s const fn elt = fn const elt end
module Map2SOf = struct let fn fn x y = Lwt . return ( fn x y ) let fn_s fn x y = fn x y end
module CondSOf = struct let fn fn const elt = Lwt . return ( fn const elt ) let fn_s fn const elt = fn const elt end
module CondMapSOf = struct let fn fn const elt = Lwt . return ( fn const elt ) let fn_s fn const elt = fn const elt end
module Cond2SOf = struct let fn fn x y = Lwt . return ( fn x y ) let fn_s fn x y = fn x y end
module FilterMapSOf = struct open Lwt_syntax let fns cond fn const elt = Lwt . return ( if cond const elt then Some ( fn const elt ) else None ) let fns_s cond fn const elt = let + b = cond const elt in if b then Some ( fn const elt ) else None end
module ConcatMapSOf = struct let fns of_list fn consta constb elt = Lwt . return ( of_list [ fn consta elt ; fn constb elt ] ) end
module IterESOf = struct open Lwt_result_syntax let fn r fn y = r := fn ! r y ; return_unit let monotonous r fn const y = r := ! r + fn const y ; return_unit let fn_e r fn y = let * t = Lwt . return @@ fn ! r y in r := t ; return_unit let fn_s r fn y = let *! t = fn ! r y in r := t ; return_unit let fn_es r fn y = let ...
module IteriESOf = struct open Lwt_result_syntax let fn r fn i y = r := fn ! r ( fn i y ) ; return_unit let fn_e r fn i y = let * z = Lwt . return @@ fn i y in let * t = Lwt . return @@ fn ! r z in r := t ; return_unit let fn_s r fn i y = let *! z = fn i y in let *! t = fn ! r z in r := t ; return_unit let fn_es r fn i...
module Iter2ESOf = struct open Lwt_result_syntax let fn r fn x y = r := fn x y ; return_unit let fn_e r fn x y = let * t = Lwt . return @@ fn x y in r := t ; return_unit let fn_s r fn x y = let * t = fn x y in r := t ; return_unit let fn_es r fn x y = let * t = fn x y in r := t ; return_unit end
module FoldESOf = struct open Lwt_result_syntax let fn fn acc elt = return ( fn acc elt ) let fn_e fn acc elt = Lwt . return @@ fn acc elt let fn_s fn acc elt = Lwt_result . ok @@ fn acc elt let fn_es fn acc elt = fn acc elt end
module Fold2ESOf = struct open Lwt_result_syntax let fn fn acc x y = return ( fn acc ( fn x y ) ) let fn_e fn acc x y = let * z = Lwt . return @@ fn x y in Lwt . return @@ fn acc z let fn_s fn acc x y = let *! z = fn x y in let *! r = fn acc z in return r let fn_es fn acc x y = let * z = fn x y in fn acc z end
module MapESOf = struct open Lwt_result_syntax let fn const fn elt = return ( fn const elt ) let fn_e const fn elt = Lwt . return @@ fn const elt let fn_s const fn elt = Lwt_result . ok @@ fn const elt let fn_es const fn elt = fn const elt end
module MapEPOf = struct open Lwt_traced_result_syntax let fn const fn elt = return ( fn const elt ) let fn_e const fn elt = match fn const elt with | Ok _ as ok -> Lwt . return ok | Error err -> fail err let fn_s const fn elt = Lwt_result . ok @@ fn const elt let fn_es const fn elt = let open Lwt_syntax in let + r = fn...
module Map2ESOf = struct open Lwt_traced_result_syntax let fn fn x y = return ( fn x y ) let fn_e fn x y = Lwt . return @@ fn x y let fn_s fn x y = Lwt_result . ok @@ fn x y let fn_es fn x y = fn x y end
module CondESOf = struct let fn fn const elt = Lwt_result_syntax . return ( fn const elt ) let fn_es fn const elt = fn const elt end
module CondMapESOf = struct let fn fn const elt = Lwt_result_syntax . return ( fn const elt ) let fn_es fn const elt = fn const elt end
module Cond2ESOf = struct let fn fn x y = Lwt_result_syntax . return ( fn x y ) let fn_es fn x y = fn x y end
module FilterMapESOf = struct open Lwt_traced_result_syntax let fns cond fn const elt = return ( if cond const elt then Some ( fn const elt ) else None ) let fns_es cond fn const elt = let + b = cond const elt in if b then Some ( fn const elt ) else None end
module ConcatMapESOf = struct open Lwt_traced_result_syntax let fns of_list fn consta constb elt = return ( of_list [ fn consta elt ; fn constb elt ] ) end
let many = QCheck . ( list int )
let maybe = QCheck . ( option int )
let manymany = let open QCheck in oneof [ map ~ rev ( : fun ( input , _ ) -> input ) ( fun input -> ( input , input ) ) ( list int ) ; pair ( list int ) ( list int ) ; ]
let eq ? pp a b = qcheck_eq ? pp a b
let eq_e ? pp ( a : ( ' a , ' trace ) result ) ( b : ( ' a , ' trace ) result ) = eq ? pp a b
let eq_s ? pp a b = Lwt_main . run ( let open Lwt_syntax in let + a = a and + b = b in eq ? pp a b )
let eq_es ? pp ( a : ( ' a , ' b ) result Lwt . t ) ( b : ( ' a , ' b ) result Lwt . t ) = eq_s ? pp a b
let eq_es_ep ? pp es ep = Lwt_main . run ( let open Lwt_syntax in let + es = es and + ep = ep in match ( es , ep ) with | ( Ok ok_es , Ok ok_ep ) -> eq ? pp ok_es ok_ep | ( Error error_es , Error trace_ep ) -> let trace_ep_has_error_es = Support . Test_trace . fold ( fun has error -> has || error = error_es ) false tra...
let eq_ep ? pp a b = Lwt_main . run ( let open Lwt_syntax in let + a = a and + b = b in match ( a , b ) with | ( Ok ok_es , Ok ok_ep ) -> eq ? pp ok_es ok_ep | ( Error _ , Error _ ) -> true | ( Ok _ , Error _ ) -> QCheck . Test . fail_report " Ok _ is not Error _ " | ( Error _ , Ok _ ) -> QCheck . Test . fail_report " ...
module PP = struct let int = Format . pp_print_int let res ok error = Format . pp_print_result ~ ok ~ error let str = Format . pp_print_string let list elt = Format . pp_print_list ~ pp_sep : Format . pp_print_space elt let bool = Format . pp_print_bool let trace = Support . Test_trace . pp end
let list1_gen gen = QCheck2 . Gen . ( list_size ( 1 -- 20 ) gen |> add_shrink_invariant ( fun l -> l <> [ ] ) )
let irmin_tree_gen = let module StringList = struct type t = string list let compare = Stdlib . compare end in let module StringListMap = Stdlib . Map . Make ( StringList ) in let open MakeMapGen ( StringListMap ) in let open QCheck2 . Gen in let + entries = small_list ( pair ( small_list string ) bytes_gen ) in List ....
let print_tree = Format . asprintf " % a " Store . Tree . pp