text
stringlengths
0
601k
let l_filled_array = [ | 1 ; 2 ; 3 ; 4 ; 5 ; 6 ] |
let r_filled_array = [ | 6 ; 5 ; 4 ; 3 ; 2 ; 1 ] |
let test_iter iter_f array_values seq = let index = ref 0 in Lwt . catch ( fun ( ) -> iter_f ( fun v -> assert ( v = array_values . ( ! index ) ) ; index := ( ! index + 1 ) ) seq ; Lwt . return_true ) ( function _ -> Lwt . return_false )
let test_iter_node iter_f array_values seq = let index = ref 0 in Lwt . catch ( fun ( ) -> iter_f ( fun n -> assert ( ( Lwt_sequence . get n ) = array_values . ( ! index ) ) ; index := ( ! index + 1 ) ) seq ; Lwt . return_true ) ( function _ -> Lwt . return_false )
let test_iter_rem iter_f array_values seq = let index = ref 0 in Lwt . catch ( fun ( ) -> iter_f ( fun n -> assert ( ( Lwt_sequence . get n ) = array_values . ( ! index ) ) ; Lwt_sequence . remove n ; index := ( ! index + 1 ) ) seq ; Lwt . return_true ) ( function _ -> Lwt . return_false )
let suite = suite " lwt_sequence " [ test " create " begin fun ( ) -> let s = Lwt_sequence . create ( ) in let _ = assert ( Lwt_sequence . is_empty s ) in let len = Lwt_sequence . length s in Lwt . return ( len = 0 ) end ; test " add_l " begin fun ( ) -> let s = Lwt_sequence . create ( ) in let n = Lwt_sequence . add_l...
let suite = suite " lwt_signal " [ test " limit " ( fun ( ) -> let s , push = React . S . create 0 in let cond = Lwt_condition . create ( ) in let s ' = Lwt_react . S . limit ( fun ( ) -> Lwt_condition . wait cond ) s in let l = ref [ ] in let e = React . E . map ( fun x -> l := x :: ! l ) ( React . S . changes s ' ) i...
module Result = struct type ( ' + a , ' + b ) t = ( ' a , ' b ) result = | Ok of ' a | Error of ' b end
let expect_exit f = Lwt . catch ( fun ( ) -> f ( ) >>= fun _ -> Lwt . return_false ) ( function | Exit -> Lwt . return_true | e -> Lwt . fail e )
let suite = suite " lwt_stream " [ test " from " ( fun ( ) -> let mvar = Lwt_mvar . create_empty ( ) in let stream = Lwt_stream . from ( fun ( ) -> Lwt_mvar . take mvar >>= fun x -> return ( Some x ) ) in let t1 = Lwt_stream . next stream in let t2 = Lwt_stream . next stream in let t3 = Lwt_stream . next stream in Lwt_...
let suite = suite " lwt_switch " [ test " turn_off , add_hook " ( fun ( ) -> let hook_1_calls = ref 0 in let hook_2_calls = ref 0 in let hook call_counter ( ) = call_counter := ! call_counter + 1 ; Lwt . return_unit in let switch = Lwt_switch . create ( ) in Lwt_switch . add_hook ( Some switch ) ( hook hook_1_calls ) ;...
let suite = suite " Lwt_timeout " [ test " basic " begin fun ( ) -> let p , r = Lwt . wait ( ) in let start_time = Unix . gettimeofday ( ) in let timeout = Lwt_timeout . create 1 ( fun ( ) -> let delta = Unix . gettimeofday ( ) . - start_time in Lwt . wakeup_later r delta ) in Lwt_timeout . start timeout ; p >|= fun de...
let ( ) = match Sys . argv with | [ | _ ; " -- child " ] | -> exit 42 | _ -> ( )
let wait_tests = [ test " wait " ~ sequential : true ~ only_if ( : fun ( ) -> not Sys . win32 ) begin fun ( ) -> match Lwt_unix . fork ( ) with | 0 -> Unix . execv Sys . argv . ( 0 ) [ " " ; | " -- child " ] | | child_pid -> Lwt_unix . wait ( ) >|= function | exited_pid , Lwt_unix . WEXITED 42 when exited_pid = child_p...
let ( ) = let is_fd_open fd = let fd = ( Obj . magic ( int_of_string fd ) : Unix . file_descr ) in let buf = Bytes . create 1 in try ignore ( Unix . read fd buf 0 1 ) ; true with Unix . Unix_error ( Unix . EBADF , _ , _ ) -> false in match Sys . argv with | [ | _ ; " -- cloexec " ; fd ; " -- open " ] | -> if is_fd_open...
let test_cloexec ~ closed flags = Lwt_unix . openfile " / dev / zero " ( Unix . O_RDONLY :: flags ) 0o644 >>= fun fd -> match Lwt_unix . fork ( ) with | 0 -> let fd = string_of_int ( Obj . magic ( Lwt_unix . unix_file_descr fd ) ) in let expected_status = if closed then " -- closed " else " -- open " in Unix . execv Sy...
let openfile_tests = [ test " openfile : O_CLOEXEC " ~ only_if ( : fun ( ) -> not Sys . win32 ) ( fun ( ) -> test_cloexec ~ closed : true [ Unix . O_CLOEXEC ] ) ; test " openfile : O_CLOEXEC not given " ~ only_if ( : fun ( ) -> not Sys . win32 ) ( fun ( ) -> test_cloexec ~ closed : false [ ] ) ; test " openfile : O_KEE...
let utimes_tests = [ test " utimes : basic " ( fun ( ) -> let temporary_file = Test_unix . temp_file ( ) in Lwt_unix . utimes temporary_file 1 . 2 . >>= fun ( ) -> let stat = Unix . stat temporary_file in let c1 = stat . Unix . st_atime = 1 . in let c2 = stat . Unix . st_mtime = 2 . in Lwt . return ( instrument ( c1 &&...
let readdir_tests = let populate n = let path = Test_unix . temp_directory ( ) in let filenames = let rec loop n acc = if n <= 0 then acc else loop ( n - 1 ) ( ( string_of_int n ) :: acc ) in loop n [ ] in List . iter ( fun filename -> let fd = Unix . ( openfile ( Filename . concat path filename ) [ O_WRONLY ; O_CREAT ...
let io_vectors_byte_count_tests = let open Lwt_unix . IO_vectors in [ test " io_vector_byte_count : basic " ( fun ( ) -> let iov = create ( ) in append_bytes iov ( Bytes . create 10 ) 0 10 ; append_bigarray iov ( Lwt_bytes . create 10 ) 0 10 ; Lwt . return ( byte_count iov = 20 ) ) ; test " io_vector_byte_count : offse...
let readv_tests = let make_io_vectors vecs = let open Lwt_unix . IO_vectors in let io_vectors = create ( ) in let underlying = List . map ( function | ` Bytes ( prefix , slice_length , suffix ) -> let buffer = Bytes . make ( prefix + slice_length + suffix ) ' _ ' in append_bytes io_vectors buffer prefix slice_length ; ...
let writev_tests = let make_io_vectors vecs = let open Lwt_unix . IO_vectors in let io_vectors = create ( ) in List . iter ( function | ` Bytes ( s , offset , length ) -> append_bytes io_vectors ( Bytes . unsafe_of_string s ) offset length | ` Bigarray ( s , offset , length ) -> append_bigarray io_vectors ( Lwt_bytes ....
let send_recv_msg_tests = [ test " send_msg , recv_msg " ~ only_if ( : fun ( ) -> not Sys . win32 ) begin fun ( ) -> let socket_1 , socket_2 = Lwt_unix . ( socketpair PF_UNIX SOCK_STREAM 0 ) in let pipe_read , pipe_write = Lwt_unix . pipe ~ cloexec : true ( ) in let source_buffer = Bytes . of_string " _foo_bar_ " in le...
let bind_tests_address = Unix . ( ADDR_INET ( inet_addr_loopback , 56100 ) )
let bind_tests = let directory_exists dir = try Sys . is_directory dir with Sys_error _ -> false in [ test " bind : basic " ( fun ( ) -> let socket = Lwt_unix . ( socket PF_INET SOCK_STREAM 0 ) in Lwt . finalize ( fun ( ) -> Lwt_unix . bind socket bind_tests_address >>= fun ( ) -> Lwt . return ( Unix . getsockname ( Lw...
let dir_tests = [ test " getcwd " ( fun ( ) -> Lwt_unix . getcwd ( ) >>= fun ( _ : string ) -> Lwt . return_true ) ; test " getcwd and chdir " ( fun ( ) -> Lwt_unix . getcwd ( ) >>= fun here -> Lwt_unix . chdir here >>= fun ( ) -> Lwt_unix . getcwd ( ) >>= fun there -> Lwt . return ( here = there ) ) ; test " getcwd an...
let lwt_preemptive_tests = [ test " run_in_main " begin fun ( ) -> let f ( ) = Lwt_preemptive . run_in_main ( fun ( ) -> Lwt_unix . sleep 0 . 01 >>= fun ( ) -> Lwt . return 42 ) in Lwt_preemptive . detach f ( ) >>= fun x -> Lwt . return ( x = 42 ) end ; ]
let getlogin_works = if Sys . win32 then false else match Unix . getlogin ( ) with | _ -> true | exception Unix . Unix_error _ -> false
let lwt_user_tests = [ test " getlogin and Unix . getlogin " ~ only_if ( : fun ( ) -> getlogin_works ) begin fun ( ) -> let unix_user = Unix . getlogin ( ) in Lwt_unix . getlogin ( ) >>= fun user -> Lwt . return ( user = unix_user ) end ; test " getpwnam and Unix . getpwnam " ~ only_if ( : fun ( ) -> getlogin_works ) b...
let file_suffix = let last_file_suffix = ref 0 in fun ( ) -> incr last_file_suffix ; ! last_file_suffix
let test_filename name = Printf . sprintf " % s_ % i " name ( file_suffix ( ) )
let pread_tests ~ blocking = let test_file = test_filename " test_pread_pwrite " in let file_contents = " 01234567890123456789 " in let blocking_string = if blocking then " blocking " else " nonblocking " in [ test ~ sequential : true ( " basic pread " ^ blocking_string ) ( fun ( ) -> Lwt_unix . openfile test_file [ O_...
let dup_tests ~ blocking = let test_file = test_filename " test_dup " in let file_contents = " 01234567890123456789 " in let len = String . length file_contents in let buf = Bytes . make len ' \ x00 ' in let blocking_string = if blocking then " blocking " else " nonblocking " in [ test ~ sequential : true ( " dup on so...
let suite = suite " lwt_unix " ( wait_tests @ openfile_tests @ utimes_tests @ readdir_tests @ io_vectors_byte_count_tests @ readv_tests @ writev_tests @ send_recv_msg_tests @ bind_tests @ dir_tests @ lwt_preemptive_tests @ lwt_user_tests @ pread_tests ~ blocking : true @ pread_tests ~ blocking : false @ dup_tests ~ blo...
let test_string_rt ( ) = let addrs = [ ( " ca : fe : ba : be : ee : ee " , ' ' ) ; : ( " ca - fe - ba - be - ee - ee " , ' ' ) - ] in List . iter ( fun ( addr , sep ) -> let os = of_string_exn addr in let ts = to_string ~ sep os in assert_equal ~ msg ( : addr ^ " <> " ^ ts ) ts addr ; let os = Macaddr_sexp . ( t_of_sex...
let assert_result_failure ~ msg a = match a with Ok _ -> assert_failure msg | Error ( ` Msg _ ) -> ( )
let test_string_rt_bad ( ) = let addrs = [ " ca : fe : ba : be : ee : e " ; " ca : fe : ba : be : ee : eee " ; " ca : fe : ba : be : eeee " ; " ca : fe : ba : be : ee :: ee " ; " ca : fe : ba : be : e : eee " ; " ca : fe : ba : be : ee - ee " ; ] in List . iter ( fun addr -> assert_result_failure ~ msg : addr ( of_stri...
let test_bytes_rt ( ) = let addr = " \ 254 \ 099 \ 003 \ 128 \ 000 \ 000 " in assert_equal ~ msg ( : String . escaped addr ) ( to_octets ( of_octets_exn addr ) ) addr
let test_bytes_rt_bad ( ) = let addrs = [ " \ 254 \ 099 \ 003 \ 128 \ 000 " ; " \ 254 \ 099 \ 003 \ 128 \ 000 \ 000 \ 233 " ] in List . iter ( fun addr -> assert_result_failure ~ msg ( : String . escaped addr ) ( of_octets addr ) ) addrs
let test_cstruct_rt ( ) = let open Macaddr_cstruct in let addr = " \ 254 \ 099 \ 003 \ 128 \ 000 \ 000 " in assert_equal ~ msg ( : String . escaped addr ) ( Cstruct . to_string ( to_cstruct ( of_cstruct_exn ( Cstruct . of_string addr ) ) ) ) addr
let error s = ( s , Parse_error ( " MAC is exactly 6 bytes " , s ) )
let test_cstruct_rt_bad ( ) = let open Macaddr_cstruct in let addrs = [ error " \ 254 \ 099 \ 003 \ 128 \ 000 " ; error " \ 254 \ 099 \ 003 \ 128 \ 000 \ 000 \ 233 " ] in List . iter ( fun ( addr , exn ) -> assert_raises ~ msg ( : String . escaped addr ) exn ( fun ( ) -> of_cstruct_exn ( Cstruct . of_string addr ) ) ) ...
let test_make_local ( ) = let ( ) = Random . self_init ( ) in let bytegen i = if i = 0 then 253 else 255 - i in let local_addr = make_local bytegen in assert_equal ~ msg " : is_local " ( is_local local_addr ) true ; assert_equal ~ msg " : is_unicast " ( is_unicast local_addr ) true ; assert_equal ~ msg " : localize " (...
let suite = " Test " >::: [ " string_rt " >:: test_string_rt ; " string_rt_bad " >:: test_string_rt_bad ; " bytes_rt " >:: test_bytes_rt ; " bytes_rt_bad " >:: test_bytes_rt_bad ; " cstruct_rt " >:: test_cstruct_rt ; " cstruct_rt_bad " >:: test_cstruct_rt_bad ; " make_local " >:: test_make_local ; ] ; ;
let test_mode = " test - major - mode " |> Symbol . intern
module M = ( val define_derived_mode test_mode [ % here ] ~ docstring " : docstring " ~ mode_line " :< test - mode mode line " > ~ initialize ( : Returns Value . Type . unit , fun ( ) -> print_s [ % message " initialized " ] ) ( ) ) require_does_raise [ % here ] ( fun ( ) -> Major_mode . wrap_existing " org - mode " [ ...
let show_syntax_table t = Test_syntax_table . show ( syntax_table t ) show_syntax_table M . major_mode ; [ % expect { | ( ( Close_paren " ) ] } " ) ( Escape ) \ ( Open_paren " ( [ { " ) ( Punctuation " ' , . ; ` " ) !#:?@^~ ( String_quote " " " ) \ ( Symbol_constitutent &*+-/<=> _ ) | ( Whitespace " " ) ( Word_constitu...
let hey = let doc = " Equivalent to set ( $ opt ) . " in let env = Cmd . Env . info " TEST_ENV " ~ doc in let doc = " Set hey . " in Arg . ( value & flag & info [ " hey " ; " y " ] ~ env ~ doc )
let repodir = let doc = " See option ( $ opt ) . " in let env = Cmd . Env . info " TEST_REPODDIR " ~ doc in let doc = " Run the program in repository directory ( $ docv ) . " in Arg . ( value & opt file Filename . current_dir_name & info [ " repodir " ] ~ env ~ docv " : DIR " ~ doc )
let id = let doc = " See option ( $ opt ) . " in let env = Cmd . Env . info " TEST_ID " ~ doc in let doc = " Whatever ( $ docv ) bla ( $ env ) and ( $ opt ) . " in Arg . ( value & opt int ~ vopt : 10 0 & info [ " id " ; " i " ] ~ env ~ docv " : ID ) " ~ doc )
let miaouw = let doc = " See option ( $ opt ) . These are term names ( $ mname ) ( $ tname ) " in let docs = " MIAOUW SECTION ( non - standard unpositioned do not do this ) " in let env = Cmd . Env . info " TEST_MIAOUW " ~ doc ~ docs in let doc = " Whatever this is the doc var ( $ docv ) this is the env var ( $ env ) \...
let test hey repodir id miaouw = Format . printf " hey : % B . @ repodir : % s . @ id : % d . @ miaouw : % s . " @ hey repodir id miaouw
let man_test_t = Term . ( const test $ hey $ repodir $ id $ miaouw )
let info = let doc = " print a customizable message repeatedly " in let envs = [ Cmd . Env . info " TEST_IT " ~ doc " : This is ( $ env ) for ( $ tname ) " ] in let exits = ( Cmd . Exit . info ~ doc " : This is a ( $ status ) for ( $ tname ) " 1 :: Cmd . Exit . info ~ doc " : Ranges from ( $ status ) to ( $ status_max ...
let ( ) = exit ( Cmd . eval ( Cmd . v info man_test_t ) )
let print x = print_s [ % sexp ( x : ( string , int ) Symmetric_diff_element . t ) ] in let f x = x + 1 in print ( Symmetric_diff_element . map_data ( " foo " , ` Left 1 ) ~ f ) ; [ % expect { | ( foo ( Left 2 ) ) } ] ; | print ( Symmetric_diff_element . map_data ( " foo " , ` Right 5 ) ~ f ) ; [ % expect { | ( foo ( R...
let quickcheck_config = let test_count = match Sys . backend_type with | Native | Bytecode -> 10_000 | Other _ -> 1_000 in { Base_quickcheck . Test . default_config with test_count } ; ; let quickcheck_m here m ~ f = quickcheck_m here m ~ f ~ config : quickcheck_config end
module type Types = sig type ' k key type ' c cmp type ( ' k , ' v , ' c ) t type ( ' k , ' v , ' c ) tree type ( ' k , ' c , ' a ) create_options type ( ' k , ' c , ' a ) access_options end
module type S = sig module Types : Types include Map . Creators_generic with type ( ' a , ' b , ' c ) t := ( ' a , ' b , ' c ) Types . t with type ( ' a , ' b , ' c ) tree := ( ' a , ' b , ' c ) Types . tree with type ' a key := ' a Types . key with type ' a cmp := ' a Types . cmp with type ( ' a , ' b , ' c ) options ...
module type Instance = sig module Types : Types module Key : sig type t = int Types . key [ @@ deriving compare , equal , quickcheck , sexp_of ] include Comparable . Infix with type t := t end type ' a t = ( int , ' a , Int . comparator_witness ) Types . t [ @@ deriving equal , quickcheck , sexp_of ] val key : int -> K...
module Instance ( Cmp : sig type comparator_witness val comparator : ( int , comparator_witness ) Comparator . t end ) = struct module Key = struct type t = int [ @@ deriving quickcheck , sexp_of ] type comparator_witness = Cmp . comparator_witness let comparator = Cmp . comparator let compare = comparator . compare le...
module Instance_int = struct module I = Instance ( Int ) type t = int I . t [ @@ deriving equal , quickcheck , sexp_of ] end
module Instance_tree ( Cmp : sig type comparator_witness val comparator : ( int , comparator_witness ) Comparator . t end ) = struct module M = Instance ( Cmp ) include M type ' a t = ( int , ' a , Cmp . comparator_witness ) Map . Using_comparator . Tree . t let of_tree tree = Map . Using_comparator . of_tree ~ compara...
module Lst ( T : sig type t [ @@ deriving equal , sexp_of ] end ) = struct type t = T . t list [ @@ deriving equal , sexp_of ] end
module Ok ( T : sig type t [ @@ deriving equal , sexp_of ] end ) = struct type t = ( T . t , ( Error . t [ @ equal . ignore ] ) ) Result . t [ @@ deriving equal , sexp_of ] end
module Opt ( T : sig type t [ @@ deriving equal , sexp_of ] end ) = struct type t = T . t option [ @@ deriving equal , sexp_of ] end
module Pair ( T : sig type t [ @@ deriving equal , quickcheck , sexp_of ] end ) = struct type t = T . t * T . t [ @@ deriving equal , quickcheck , sexp_of ] let quickcheck_generator = let open Base_quickcheck . Generator . Let_syntax in match % bind Base_quickcheck . Generator . bool with | true -> [ % generator : t ] ...
module Test_creators_and_accessors ( Types : Types ) ( Impl : S with module Types := Types ) ( Instance : Instance with module Types := Types ) : S with module Types := Types = struct open Instance open Impl open struct module Alist = struct type t = ( Key . t * int ) list [ @@ deriving compare , equal , quickcheck , s...
module _ : module type of struct include Base . Map open Base . Map module type Accessors1 = Accessors1 module type Accessors2 = Accessors2 module type Accessors3 = Accessors3 module type Accessors3_with_comparator = Accessors3_with_comparator module type Accessors_generic = Accessors_generic module type Creators1 = Cr...
let ( ) = Random . init 1597
module TestB ( B : Builder . S with type G . V . label = int ) = struct let test n = let v = Array . init n B . G . V . create in let rec make g i = if i = n then g else make ( B . add_vertex g v . ( i ) ) ( i + 1 ) in let g = ref ( make ( B . empty ( ) ) 0 ) in for i = 0 to n - 1 do for j = 0 to n - 1 do if Random . b...
module TestI ( G : Sig . I with type V . label = int ) = TestB ( Builder . I ( G ) )
module TestP ( G : Sig . P with type V . label = int ) = TestB ( Builder . P ( G ) )
module Int = struct include Int let hash x = x let default = 42 end
module TestM ( G : Imperative . Matrix . S ) = struct let test n = let g = G . make n in for i = 0 to n - 1 do for j = 0 to n - 1 do if Random . bool ( ) then G . add_edge g i j done done ; let counter = ref 0 in let f x = incr counter ; x in let g ' = G . map_vertex f g in assert ( ! counter = n ) ; assert ( G . nb_ve...
module Req = struct include Caqti_type . Std include Caqti_request . Infix end
let bad_select_req = Req . ( unit -->! unit @:- " SELECT not_defined " )
let test_error ( module C : Caqti_blocking . CONNECTION ) = ( match C . find bad_select_req ( ) with | Ok ( ) -> Alcotest . fail " unexpected ok from bad_select " | Error ( ` Request_failed { msg = Caqti_driver_mariadb . Error_msg { errno ; error = _ } ; _ } ) -> Alcotest . ( check int ) " errno " 1054 errno | Error er...
let test_cases_on_connection = [ " test_error " , ` Quick , test_error ; ]
let mk_test ( name , pool ) = let pass_conn ( name , speed , f ) = let f ' ( ) = Caqti_blocking . Pool . use ( fun c -> Ok ( f c ) ) pool |> function | Ok ( ) -> ( ) | Error err -> Alcotest . failf " % a " Caqti_error . pp err in ( name , speed , f ' ) in let test_cases = List . map pass_conn test_cases_on_connection i...
let mk_tests { uris ; tweaks_version } = let connect_pool uri = ( match Caqti_blocking . connect_pool uri ~ max_size : 1 ? tweaks_version with | Ok pool -> ( test_name_of_uri uri , pool ) | Error err -> raise ( Caqti_error . Exn err ) ) in let is_mariadb uri = Uri . scheme uri = Some " mariadb " in let pools = List . m...
let ( ) = Alcotest_cli . run_with_args_dependency " test_mariadb " common_args mk_tests
let show t = print_s [ % message " " ~ marker ( : t : t ) ~ buffer ( : buffer t : Buffer . t option ) ~ insertion_type ( : insertion_type t : Insertion_type . t ) ~ position ( : position t : Position . t option ) ] ; ; show ( create ( ) ) ; [ % expect { | ( ( marker " #< marker in no buffer " ) > ( buffer ( ) ) ( inser...
let module M = struct [ @@@ warning " - 37 " ] type sign = | SPlus | SMinus type raw_numeral = int type prim_token = | Numeral of sign * raw_numeral | String of string type operator_token = | Add | Sub | Times | PlusPlus type expr = | Literal of prim_token | Op of operator_token * expr list let write_out chan v = let s...
module type Test_intf = sig val depth : int module Location : Merkle_ledger . Location_intf . S module Base : Merkle_mask . Base_merkle_tree_intf . S with module Addr = Location . Addr and module Location = Location and type account := Account . t and type root_hash := Hash . t and type hash := Hash . t and type key :=...
module Make ( Test : Test_intf ) Test_intf = struct module Maskable = Test . Maskable module Mask = Test . Mask let directions = let rec add_direction count b accum = if count >= Test . depth then accum else let dir = if b then Direction . Right else Direction . Left in add_direction ( count + 1 ) 1 ( not b ) b ( dir :...
module type Depth_S = sig val depth : int end
module Make_maskable_and_mask_with_depth ( Depth : Depth_S ) Depth_S = struct let depth = Depth . depth module Location : Merkle_ledger . Location_intf . S = Merkle_ledger . Location . T module Location_binable = struct module Arg = struct type t = Location . t = | Generic of Merkle_ledger . Location . Bigstring . Stab...
module Make_maskable_and_mask ( Depth : Depth_S ) Depth_S = Make ( Make_maskable_and_mask_with_depth ( Depth ) Depth ) Depth ( module struct module Depth_4 = struct let depth = 4 end module Mdb_d4 = Make_maskable_and_mask ( Depth_4 ) Depth_4 module Depth_30 = struct let depth = 30 end module Mdb_d30 = Make_maskable_and...
let mat_eq sub lange x y = let ( m , n ) = dim x in match ( to_int m , to_int n ) with | ( 0 , _ ) | ( _ , 0 ) -> true | _ -> sub x y ; lange ? norm : None ? work : None y < 1e - 6
let test_mat_float32 ( ) = let f m n ll = of_list_dyn float32 m n ll in let ( ) = x y = Slap . S . ( mat_eq ( Mat . axpy ~ alpha ( :- 1 . ) ) lange x y ) in " m_emp " @? ( f zero zero [ ] = [ % mat . float32 [ ] ] ) ; " m_sgl " @? ( f one one [ [ 42 . ] ] = [ % mat . float32 [ 42 . ] ] ) ; " m_olp " @? ( f two three [ ...
let test_mat_float64 ( ) = let f m n ll = of_list_dyn float64 m n ll in let ( ) = x y = Slap . D . ( mat_eq ( Mat . axpy ~ alpha ( :- 1 . ) ) lange x y ) in " m_emp " @? ( f zero zero [ ] = [ % mat . float64 [ ] ] ) ; " m_sgl " @? ( f one one [ [ 42 . ] ] = [ % mat . float64 [ 42 . ] ] ) ; " m_olp " @? ( f two three [ ...
let test_mat_complex32 ( ) = let f m n ll = of_list_dyn complex32 m n ll in let alpha = Complex . ( { re = ( - 1 . ) ; im = 0 . } ) in let c x = Complex . ( { re = x ; im = x } ) in let ( ) = x y = Slap . C . ( mat_eq ( Mat . axpy ~ alpha ) lange x y ) in " m_emp " @? ( f zero zero [ ] = [ % mat . complex32 [ ] ] ) ; "...
let test_mat_complex64 ( ) = let f m n ll = of_list_dyn complex64 m n ll in let alpha = Complex . ( { re = ( - 1 . ) ; im = 0 . } ) in let c x = Complex . ( { re = x ; im = x } ) in let ( ) = x y = Slap . Z . ( mat_eq ( Mat . axpy ~ alpha ) lange x y ) in " m_emp " @? ( f zero zero [ ] = [ % mat . complex64 [ ] ] ) ; "...
let test_mat_char ( ) = let f m n ll = of_list_dyn char m n ll in " m_emp " @? ( f zero zero [ ] = [ % mat . char [ ] ] ) ; " m_sgl " @? ( f one one [ [ ' x ' ] ] = [ % mat . char [ ' x ' ] ] ) ; " m_olp " @? ( f two three [ [ ' a ' ; ' b ' ; ' c ' ] ; [ ' d ' ; ' e ' ; ' f ' ] ] = [ % mat . char [ ' a ' , ' b ' , ' c ...
let test_mat_sint8 ( ) = let f m n ll = of_list_dyn int8_signed m n ll in " m_emp " @? ( f zero zero [ ] = [ % mat . sint8 [ ] ] ) ; " m_sgl " @? ( f one one [ [ 42 ] ] = [ % mat . sint8 [ 42 ] ] ) ; " m_olp " @? ( f two three [ [ 11 ; 12 ; 13 ] ; [ 21 ; 22 ; 23 ] ] = [ % mat . sint8 [ 11 , 12 , 13 ; 21 , 22 , 23 ] ] )...
let test_mat_uint8 ( ) = let f m n ll = of_list_dyn int8_unsigned m n ll in " m_emp " @? ( f zero zero [ ] = [ % mat . uint8 [ ] ] ) ; " m_sgl " @? ( f one one [ [ 42 ] ] = [ % mat . uint8 [ 42 ] ] ) ; " m_olp " @? ( f two three [ [ 11 ; 12 ; 13 ] ; [ 21 ; 22 ; 23 ] ] = [ % mat . uint8 [ 11 , 12 , 13 ; 21 , 22 , 23 ] ]...
let test_mat_sint16 ( ) = let f m n ll = of_list_dyn int16_signed m n ll in " m_emp " @? ( f zero zero [ ] = [ % mat . sint16 [ ] ] ) ; " m_sgl " @? ( f one one [ [ 42 ] ] = [ % mat . sint16 [ 42 ] ] ) ; " m_olp " @? ( f two three [ [ 11 ; 12 ; 13 ] ; [ 21 ; 22 ; 23 ] ] = [ % mat . sint16 [ 11 , 12 , 13 ; 21 , 22 , 23 ...
let test_mat_uint16 ( ) = let f m n ll = of_list_dyn int16_unsigned m n ll in " m_emp " @? ( f zero zero [ ] = [ % mat . uint16 [ ] ] ) ; " m_sgl " @? ( f one one [ [ 42 ] ] = [ % mat . uint16 [ 42 ] ] ) ; " m_olp " @? ( f two three [ [ 11 ; 12 ; 13 ] ; [ 21 ; 22 ; 23 ] ] = [ % mat . uint16 [ 11 , 12 , 13 ; 21 , 22 , 2...
let test_mat_int ( ) = let f m n ll = of_list_dyn int m n ll in " m_emp " @? ( f zero zero [ ] = [ % mat . int [ ] ] ) ; " m_sgl " @? ( f one one [ [ 42 ] ] = [ % mat . int [ 42 ] ] ) ; " m_olp " @? ( f two three [ [ 11 ; 12 ; 13 ] ; [ 21 ; 22 ; 23 ] ] = [ % mat . int [ 11 , 12 , 13 ; 21 , 22 , 23 ] ] ) ; " m_oll " @? ...