text
stringlengths
0
601k
let parse_couple s p = let s1 = parse_single s p in let p = Str . match_end ( ) in let s2 = parse_single s p in s1 , s2
let parse_type s p = if Str . string_match type_pat s p then ( match Str . matched_group 1 s with | " E " -> E ( parse_couple s ( Str . match_end ( ) ) ) | " D " -> D ( parse_couple s ( Str . match_end ( ) ) ) | " B " -> B ( parse_single s ( Str . match_end ( ) ) ) | " P " -> P ( parse_single s ( Str . match_end ( ) ) ...
let profile_of_string = function | " node " -> ` Nodeprep | " name " -> ` Nameprep | " res " -> ` Resourceprep | " sasl " -> ` Saslprep | " trace " -> ` Trace | " iscsi " -> ` Iscsi | " mib " -> ` Mib | _ -> failwith " profile parse error "
let parse_line s = if Str . string_match profile_pat s 0 then Some ( let profile = profile_of_string ( Str . matched_group 1 s ) s in let p = Str . match_end ( ) in let t = parse_type s p in profile , t ) else None
let check_line n s = match parse_line s with | None -> 0 | Some ( profile , t ) t -> ( match t with | E ( s1 , s2 ) s2 -> expect_equal ~ msg ( : lazy ( " line : " ^ ( string_of_int n ) n ) n ) n ( stringprep profile s1 ) s1 ( stringprep profile s2 ) s2 | D ( s1 , s2 ) s2 -> expect_true ~ msg ( : lazy ( " line : " ^ ( s...
let check_file f = let c = open_in_bin f in let rec check line n = try raise ( Ok ( input_line c ) c ) c with | End_of_file -> n | Ok s -> let n = n + ( check_line line s ) s in check ( line + 1 ) 1 n in let _ = check 1 0 in close_in c
let testfile = input_filename " data / stringprep "
let _ = test ~ desc " : stringprep " ~ body ( : fun ( ) -> expect_pass ~ body ( : fun ( ) -> check_file testfile ) )
let x = Sys . opaque_identity " one string " in let y = Sys . opaque_identity " another " in require_no_allocation [ % here ] ( fun ( ) -> ignore ( Sys . opaque_identity ( String . Caseless . equal x y ) : bool ) ) ; [ % expect { } ] || ; ; let string = String . init 10 ~ f : Char . of_int_exn in let test here f = let ...
module Unit_tests_util = struct let to_bin_str t ~ bin_writer_t ~ bin_size_t = let write = bin_writer_t . Bin_prot . Type_class . write in let size = bin_size_t t in let buf = Bigstring . create size in let len = write buf ~ pos : 0 t in assert ( len = size ) ; Bigstring . to_string buf ; ; let string_to_bin_str t = le...
module Even_int_id = Make_with_validate_without_pretty_printer ( struct let module_name = " Even_int_id " let validate s = if Int . of_string s % 2 <> 0 then Or_error . error_s [ % message " Not a valid Even_int_id " ~ _ ( : s : string ) ] else Ok ( ) ; ; end ) ( )
let even_int_id_to_bin_str t = let bin_writer_t = Even_int_id . bin_writer_t in let bin_size_t = Even_int_id . bin_size_t in Unit_tests_util . to_bin_str t ~ bin_writer_t ~ bin_size_t ; ;
let even_int_id_of_bin_str str = Even_int_id . bin_reader_t . Bin_prot . Type_class . read ( Bigstring . of_string str ) ~ pos_ref ( : ref 0 ) ; ; [ % test_result : string ] ( Even_int_id . of_string " 14 " |> Even_int_id . to_string ) ~ expect " : 14 " ; ; [ % test_result : string ] ( Even_int_id . t_of_sexp ( Sexp . ...
let print_error or_error = match or_error with | Ok _ -> printf " < OK " > | Error error -> Error . to_string_hum error |> printf " % s " ; ; Or_error . try_with ( fun ( ) -> Even_int_id . of_string " 15 " ) |> print_error ; [ % expect { | ( Invalid_argument " ( " \ Not a valid Even_int_id " \ 15 ) " ) } ] | ; ; Or_err...
module M = Make_without_pretty_printer ( struct let module_name = " test " end ) ( ) [ % test_result : string ] ( M . of_string " FOOBAR " |> M . to_string ) ~ expect " : FOOBAR " ; ; [ % test_result : string ] ( M . t_of_sexp ( Sexp . of_string " FOOBAR " ) |> M . sexp_of_t |> Sexp . to_string ) ~ expect " : FOOBAR " ...
let string_id_to_bin_str t = let bin_writer_t = M . bin_writer_t in let bin_size_t = M . bin_size_t in Unit_tests_util . to_bin_str t ~ bin_writer_t ~ bin_size_t ; ;
let string_id_of_bin_str str = M . bin_reader_t . Bin_prot . Type_class . read ( Bigstring . of_string str ) ~ pos_ref ( : ref 0 ) ; ; [ % test_result : string ] ( M . of_string " FOOBAR " |> string_id_to_bin_str |> string_id_of_bin_str |> M . to_string ) ~ expect " : FOOBAR " ; ; [ % test_result : string ] ( M . of_st...
let print_error or_error = match or_error with | Ok _ -> printf " < OK " > | Error error -> Error . to_string_hum error |> printf " % s " ; ; Or_error . try_with ( fun ( ) -> M . of_string " " ) |> print_error ; [ % expect { | ( Invalid_argument " ' ' is not a valid test because it is empty " ) } ] | ; ; Or_error . try...
module Record = struct [ %% h5struct sf64 " sf64 " Float64 Seek ; si " si " Int Seek ; si64 " si64 " Int64 Seek ; ss " ss " ( String 14 ) Seek ; f64 " f64 " Float64 ; i " i " Int ; i64 " i64 " Int64 ; s " s " ( String 16 ) ] end
module Subset = struct [ %% h5struct f64 " f64 " Float64 ; ] end
module Simple = struct [ %% h5struct f " F " Float64 Seek ] end
let ( ) = let len = 1000 in let a = Record . Array . init len ( fun i e -> let si = i * 2 in Record . set e ~ sf64 ( : float_of_int si ) ~ si ~ si64 ( : Int64 . of_int si ) ~ ss ( : Printf . sprintf " % 14d " si ) ~ f64 ( : float_of_int i ) ~ i ~ i64 ( : Int64 . of_int i ) ~ s ( : Printf . sprintf " % 14d " i ) ) in le...
module Big = struct [ %% h5struct id " ID " Int ; big " Big " Bigstring ; f32 " F32 " Array_float32 ; f64 " F64 " Array_float64 ; si8 " SI8 " Array_sint8 ; ui8 " UI8 " Array_uint8 ; si16 " SI16 " Array_sint16 ; ui16 " UI16 " Array_uint16 ; i32 " I32 " Array_int32 ; i64 " I64 " Array_int64 ; i " I " Array_int ; ni " NI ...
let create_array len = Big . Array . init len ( fun i b -> let f32 = Array1 . create float32 c_layout i in for j = 0 to i - 1 do f32 . { j } <- float j done ; let f64 = Array1 . create float64 c_layout i in for j = 0 to i - 1 do f64 . { j } <- float j done ; let si8 = Array1 . create int8_signed c_layout i in for j = 0...
let ( ) = let check a = Big . Array . iteri a ~ f ( : fun i a -> Array . iter ( fun ( Big . Accessors . T acc ) -> match acc . field . type_ with | Int -> assert ( acc . get a = i ) | Int64 -> assert false | Float64 -> assert false | String _ -> assert false | Bigstring -> assert ( acc . get a |> Bigstring . to_string ...
let stress_test_bigarray num_arrays num_elements = let create_array ( ) = Big . Array . get ( create_array ( 1 + Random . int num_arrays ) ) 0 in let a = Array . init num_arrays ( fun _ -> create_array ( ) ) in let create_element ( ) = let a = a . ( Random . int num_arrays ) in let pos = Big . mem a |> Big . Array . le...
let ( ) = stress_test_bigarray 128 128
let ( ) = let s = Array . init 128 ( fun i -> String . init i ( fun i -> Char . chr ( i + 1 ) ) ) in let b = Array . map Bigstring . of_string s in Gc . full_major ( ) ; Array . iteri ( fun i b -> assert ( Bigstring . to_string b = s . ( i ) ) ) b
module Bigchar = struct [ %% h5struct id " ID " Int ; s " S " ( String 1 ) ; a " A " Bigstring ; b " B " Array_char ; ] end
let ( ) = let len = 1024 in let aa = Array . init len ( fun i -> String . init i ( fun i -> let i = i land 0xff in Char . chr ( if i = 0 then 1 else i ) ) ) in let ab = Array . init len ( fun i -> String . init i ( fun i -> Char . chr ( i land 0xff ) ) ) in let v = Bigchar . Vector . create ( ) in for i = 0 to len - 1 ...
module Foo = struct [ %% h5struct a " A " Int ( Default 0 ) ; b " B " Float64 ; ] end
module Bar = struct [ %% h5struct b " B " Float64 ; d " D " ( String 16 ) ( Default " NONE " ) ; a " A " Int ; c " C " Int ( Default 1 ) ; ] end
module Ext = struct type t = private int end
module Mem = struct module T = struct type t = { refcount : int ; data : Ext . t ; capacity : int ; mutable nmemb : int ; size : int ; nfields : int ; } end type t = { ops : Ext . t ; t : T . t ; } let data t : Hdf5_raw . H5tb . Data . t = Obj . magic t . t . data end
let ( ) = let len = 16 in let h5 = H5 . create_trunc " test . h5 " in let a = Foo . Array . init len ( fun i -> Foo . set ~ a : i ~ b ( : float i . * 0 . 25 ) ) in Foo . Array . make_table a h5 " a " ; H5 . close h5 ; let h5 = H5 . open_rdonly " test . h5 " in Bar . Array . read_table h5 " a " |> Bar . Array . iteri ~ ...
module Short = struct [ %% h5struct a " A " ( String 16 ) ; ] end
module Shorter = struct [ %% h5struct a " A " ( String 8 ) ; ] end
module Long = struct [ %% h5struct a " A " Bigstring ; ] end
let ( ) = let file = " test . h5 " in let h5 = H5 . create_trunc file in let a = Short . Array . init 8 ( fun i -> Short . set ~ a ( : Printf . sprintf " % 16d " i ) ) in Short . Array . make_table a h5 " a " ; H5 . close h5 ; let h5 = H5 . open_rdonly file in begin try let _ = Shorter . Array . read_table h5 " a " in ...
let testlib = Dl . ( dlopen ~ filename " : clib / libtest_functions . so " ~ flags [ : RTLD_NOW ] )
module Build_foreign_tests ( S : Cstubs . FOREIGN with type ' a result = ' a and type ' a return = ' a ) = struct module M = Functions . Common ( S ) open M let test_passing_struct _ = let module M = struct let s = make simple let ( ) = begin setf s i 10 ; setf s f 14 . 5 ; setf s self ( from_voidp simple null ) end le...
let test_incomplete_struct_members _ = let s = structure " s " in begin assert_raises IncompleteType ( fun ( ) -> field s " _ " void ) ; assert_raises IncompleteType ( fun ( ) -> field s " _ " ( structure " incomplete " ) ) ; assert_raises IncompleteType ( fun ( ) -> field s " _ " ( union " incomplete " ) ) ; end
let test_adding_fields_through_views _ = let module M = struct let struct_s = structure " struct_s " let s = typedef struct_s " s " let i = field s " i " int let j = field s " j " float let ( ) = seal s end in ( )
let test_ocaml_types_rejected_as_fields _ = let module M = struct let s = structure " s " let ( ) = assert_raises IncompleteType ( fun ( ) -> field s " o " ocaml_string ) let u = union " u " let ( ) = assert_raises IncompleteType ( fun ( ) -> let _ = field u " o " ocaml_string in seal u ) end in ( )
let test_pointers_to_struct_members _ = let module M = struct type s let styp : s structure typ = structure " s " let ( ) -: ty label = field styp label ty let i = int -: " i " let j = int -: " j " let k = ptr int -: " k " let ( ) = seal styp let s = make styp let ( ) = begin let sp = addr s in sp |-> i <-@ 10 ; sp |->...
let test_structs_with_union_members _ = let module M = struct type u and s let complex64_eq = let open Complex in let eps = 1e - 12 in fun { re = lre ; im = lim } { re = rre ; im = rim } -> abs_float ( lre . - rre ) < eps && abs_float ( lim . - rim ) < eps let utyp : u union typ = union " u " let ( ) -: ty label = fiel...
let test_structs_with_array_members _ = let module M = struct type u and s let styp : s structure typ = structure " s " let ( ) -: ty label = field styp label ty let i = int -: " i " let a = array 3 double -: " a " let c = char -: " c " let ( ) = seal styp let s = make styp module Array = CArray let arr = Array . of_li...
let test_updating_sealed_struct _ = let styp = structure " sealed " in let _ = field styp " _ " int in let ( ) = seal styp in assert_raises ( ModifyingSealedType " sealed " ) ( fun ( ) -> field styp " _ " char )
let test_sealing_empty_struct _ = let empty = structure " empty " in assert_raises ( Unsupported " struct with no fields " ) ( fun ( ) -> seal empty )
let test_field_references_not_invalidated _ = let module M = struct type s1 and s2 let s1 : s1 structure typ = structure " s1 " let ( ) = ( fun ( ) -> let s2 : s2 structure typ = structure " s2 " in let _ = field s2 " i " int in let ( ) = seal s2 in let _ = field s1 " _ " s2 in ( ) ) ( ) let ( ) = begin Gc . full_major...
let test_struct_ffi_type_lifetime _ = let module M = struct let f = let t = void @-> returning ( begin let s = structure " one_int " in let _ = field s " i " int in let ( ) = seal s in s end ) in Foreign . foreign ~ from : testlib " return_struct_by_value " t let ( ) = Gc . full_major ( ) let x = f ( ) end in ( )
module Build_stub_tests ( S : Cstubs . FOREIGN with type ' a result = ' a and type ' a return = ' a ) = struct open Functions include Build_foreign_tests ( S ) module N = Functions . Stubs ( S ) open N let test_passing_structs_with_union_members _ = let mkInt v = let t = make tagged in t . @ tag <-@ ' i ' ; ( t . @ num...
module Build_struct_stub_tests ( S : Ctypes . TYPE with type ' a typ = ' a Ctypes . typ and type ( ' a , ' s ) field = ( ' a , ' s ) Ctypes . field ) = struct module M = Types . Struct_stubs ( S ) let retrieve_size name = let f = Foreign . foreign ~ from : testlib name ( void @-> returning size_t ) in Unsigned . Size_t...
let suite = " Struct tests " >::: [ " passing struct ( foreign ) " >:: Foreign_tests . test_passing_struct ; " passing struct ( stubs ) " >:: Stub_tests . test_passing_struct ; " returning struct ( foreign ) " >:: Foreign_tests . test_returning_struct ; " returning struct ( stubs ) " >:: Stub_tests . test_returning_str...
let _ = run_test_tt_main suite
module Account = struct type t = Mina_base . Account . Stable . Latest . t [ @@ deriving bin_io_unversioned , sexp , equal , compare , hash , yojson ] yojson type key = Mina_base . Account . Key . Stable . Latest . t [ @@ deriving bin_io_unversioned , sexp , equal , compare , hash ] hash let empty = Mina_base . Account...
module Hash = struct module T = struct type t = Md5 . t [ @@ deriving sexp , hash , compare , bin_io_unversioned , equal ] equal end include T include Codable . Make_base58_check ( struct type t = T . t [ @@ deriving bin_io_unversioned ] bin_io_unversioned let description = " Ledger test hash " let version_byte = Base5...
module In_memory_kvdb : Intf . Key_value_database with type config := string = struct module Bigstring_frozen = struct module T = struct include Bigstring . Stable . V1 let hash = hash_t_frozen let hash_fold_t = hash_fold_t_frozen end include T include Hashable . Make_binable ( T ) T end type t = { uuid : Uuid . Stable...
module Storage_locations : Intf . Storage_locations = struct let key_value_db_dir = " " end
module Key = struct [ %% versioned module Stable = struct module V1 = struct type t = Mina_base . Account . Key . Stable . V1 . t [ @@ deriving sexp , equal , compare , hash ] hash let to_latest = Fn . id end end ] end let to_string = Signature_lib . Public_key . Compressed . to_base58_check let gen = Account . key_gen...
module Account_id = struct [ %% versioned module Stable = struct module V2 = struct type t = Mina_base . Account_id . Stable . V2 . t [ @@ deriving sexp , equal , compare , hash ] hash let to_latest = Fn . id end end ] end include Hashable . Make_binable ( Stable . Latest ) Latest include Comparable . Make ( Stable . L...
module Base_inputs = struct module Key = Key module Account_id = Account_id module Token_id = Token_id module Balance = Balance module Account = Account module Hash = Hash end
let pp_str_pair ppf ( a , b ) = Format . fprintf ppf " [ @< 1 ( >% a , % a ) ] " @ String . dump a String . dump b
let pp_pair ppf ( a , b ) = Format . fprintf ppf " [ @< 1 ( >% a , % a ) ] " @ String . Sub . dump a String . Sub . dump b
let eq_pair ( l0 , r0 ) ( l1 , r1 ) = String . Sub . equal l0 l1 && String . Sub . equal r0 r1
let eq_sub = eq ~ eq : String . Sub . equal ~ pp : String . Sub . dump
let eq_sub_raw = eq ~ eq : String . Sub . equal ~ pp : String . Sub . dump_raw
let eqs sub s = eq_str ( String . Sub . to_string sub ) s
let eqb sub s = eq_str ( String . Sub . base_string sub ) s
let eqs_opt sub os = let sub_to_str = function | Some sub -> Some ( String . Sub . to_string sub ) | None -> None in eq_option ~ eq ( ) := ~ pp : pp_str ( sub_to_str sub ) os
let eqs_pair_opt subs_pair pair = let subs_to_str = function | None -> None | Some ( sub , sub ' ) -> Some ( String . Sub . to_string sub , String . Sub . to_string sub ' ) in eq_option ~ eq ( ) := ~ pp : pp_str_pair ( subs_to_str subs_pair ) pair
let empty_pos s pos = eq_int ( String . Sub . length s ) 0 ; eq_int ( String . Sub . start_pos s ) pos
let misc = test " String . Sub misc . base functions " @@ fun ( ) -> eqs String . Sub . empty " " ; eqs ( String . Sub . v " abc " ) " abc " ; eqs ( String . Sub . v ~ start : 0 ~ stop : 1 " abc " ) " a " ; eqs ( String . Sub . v ~ start : 1 ~ stop : 2 " abc " ) " b " ; eqs ( String . Sub . v ~ start : 1 ~ stop : 3 " a...
let head = test " String . [ get_ ] head " @@ fun ( ) -> let empty = String . Sub . v ~ start : 2 ~ stop : 2 " abc " in let bc = String . Sub . v ~ start : 1 ~ stop : 3 " abc " in let eq_ochar = eq_option ~ eq ( ) := ~ pp : pp_char in eq_ochar ( String . Sub . head empty ) None ; eq_ochar ( String . Sub . head ~ rev : ...
let to_string = test " String . Sub . to_string " @@ fun ( ) -> let no_alloc s = let r = String . Sub . to_string s in eq_bool ( r == ( String . Sub . base_string s ) || r == String . empty ) true in no_alloc ( String . Sub . v ~ start : 0 ~ stop : 0 " abc " ) ; eq_str ( String . Sub . ( to_string ( v ~ start : 0 ~ sto...
let start = test " String . Sub . start " @@ fun ( ) -> empty_pos String . Sub . ( start @@ v " " ) 0 ; empty_pos String . Sub . ( start @@ v ~ start : 0 ~ stop : 0 " abc " ) 0 ; empty_pos String . Sub . ( start @@ v ~ start : 0 ~ stop : 1 " abc " ) 0 ; empty_pos String . Sub . ( start @@ v ~ start : 0 ~ stop : 2 " abc...
let stop = test " String . Sub . stop " @@ fun ( ) -> empty_pos String . Sub . ( stop @@ v " " ) 0 ; empty_pos String . Sub . ( stop @@ v ~ start : 0 ~ stop : 0 " abc " ) 0 ; empty_pos String . Sub . ( stop @@ v ~ start : 0 ~ stop : 1 " abc " ) 1 ; empty_pos String . Sub . ( stop @@ v ~ start : 0 ~ stop : 2 " abc " ) 2...
let tail = test " String . Sub . tail " @@ fun ( ) -> empty_pos String . Sub . ( tail @@ v " " ) 0 ; empty_pos String . Sub . ( tail @@ v ~ start : 0 ~ stop : 0 " abc " ) 0 ; empty_pos String . Sub . ( tail @@ v ~ start : 0 ~ stop : 1 " abc " ) 1 ; eqs String . Sub . ( tail @@ v ~ start : 0 ~ stop : 2 " abc " ) " b " ;...
let base = test " String . Sub . base " @@ fun ( ) -> eqs String . Sub . ( base @@ v " " ) " " ; eqs String . Sub . ( base @@ v ~ start : 0 ~ stop : 0 " abc " ) " abc " ; eqs String . Sub . ( base @@ v ~ start : 0 ~ stop : 1 " abc " ) " abc " ; eqs String . Sub . ( base @@ v ~ start : 0 ~ stop : 2 " abc " ) " abc " ; e...
let extend = test " String . Sub . extend " @@ fun ( ) -> let empty = String . Sub . v ~ start : 2 ~ stop : 2 " abcdefg " in let abcd = String . Sub . v ~ start : 0 ~ stop : 4 " abcdefg " in let cd = String . Sub . v ~ start : 2 ~ stop : 4 " abcdefg " in app_invalid ~ pp : String . Sub . pp ( fun s -> String . Sub . ex...
let reduce = test " String . Sub . reduce " @@ fun ( ) -> let empty = String . Sub . v ~ start : 2 ~ stop : 2 " abcdefg " in let abcd = String . Sub . v ~ start : 0 ~ stop : 4 " abcdefg " in let cd = String . Sub . v ~ start : 2 ~ stop : 4 " abcdefg " in app_invalid ~ pp : String . Sub . pp ( fun s -> String . Sub . re...
let extent = test " String . Sub . extent " @@ fun ( ) -> app_invalid ~ pp : String . Sub . dump_raw String . Sub . ( extent ( v " a " ) ) ( String . Sub . ( v " b " ) ) ; let abcd = " abcd " in let e0 = String . Sub . v ~ start : 0 ~ stop : 0 abcd in let a = String . Sub . v ~ start : 0 ~ stop : 1 abcd in let ab = Str...
let overlap = test " String . Sub . overlap " @@ fun ( ) -> let empty_pos sub pos = match sub with | None -> fail " no sub " | Some sub -> empty_pos sub pos in app_invalid ~ pp : String . Sub . dump_raw String . Sub . ( extent ( v " a " ) ) ( String . Sub . ( v " b " ) ) ; let abcd = " abcd " in let e0 = String . Sub ....
let append = test " String . Sub . append " @@ fun ( ) -> let no_allocl s s ' = eq_bool ( String . Sub . ( base_string @@ append s s ' ) == String . Sub . ( base_string s ) ) true in let no_allocr s s ' = eq_bool ( String . Sub . ( base_string @@ append s s ' ) == String . Sub . ( base_string s ' ) ) true in no_allocl ...
let concat = test " String . Sub . concat " @@ fun ( ) -> let dash = String . sub_with_range ~ first : 2 ~ len : 1 " ab - d " in let ddash = String . sub_with_range ~ first : 1 ~ len : 2 " a -- d " in let empty = String . sub_with_range ~ first : 2 ~ len : 0 " ab - d " in let no_alloc ? sep s = let r = String . Sub . (...
let is_empty = test " String . Sub . is_empty " @@ fun ( ) -> eq_bool ( String . Sub . is_empty ( String . Sub . v " " ) ) true ; eq_bool ( String . Sub . is_empty ( String . Sub . v ~ start : 4 ~ stop : 4 " abcd " ) ) true ; eq_bool ( String . Sub . is_empty ( String . Sub . v ~ start : 0 ~ stop : 0 " huiy " ) ) true ...
let is_prefix = test " String . Sub . is_prefix " @@ fun ( ) -> let empty = String . sub_with_range ~ first : 3 ~ len : 0 " ugoadfj " in let sempty = String . sub_with_range ~ first : 4 ~ len : 0 " dfkdjf " in let habla = String . sub_with_range ~ first : 2 ~ len : 5 " abhablablu " in let h = String . sub_with_range ~ ...
let is_infix = test " String . Sub . is_infix " @@ fun ( ) -> let empty = String . sub_with_range ~ first : 1 ~ len : 0 " ugoadfj " in let sempty = String . sub_with_range ~ first : 2 ~ len : 0 " dfkdjf " in let asdf = String . sub_with_range ~ first : 1 ~ len : 4 " aasdflablu " in let a = String . sub_with_range ~ fir...
let is_suffix = test " String . Sub . is_suffix " @@ fun ( ) -> let empty = String . sub_with_range ~ first : 1 ~ len : 0 " ugoadfj " in let sempty = String . sub_with_range ~ first : 2 ~ len : 0 " dfkdjf " in let asdf = String . sub_with_range ~ first : 1 ~ len : 4 " aasdflablu " in let ha = String . sub_with_range ~ ...
let for_all = test " String . Sub . for_all " @@ fun ( ) -> let empty = String . Sub . v ~ start : 3 ~ stop : 3 " asldfksaf " in let s123 = String . Sub . v ~ start : 2 ~ stop : 5 " sf123df " in let s412 = String . Sub . v " 412 " in let s142 = String . Sub . v ~ start : 3 " aaa142 " in let s124 = String . Sub . v ~ st...
let exists = test " String . Sub . exists " @@ fun ( ) -> let empty = String . Sub . v ~ start : 3 ~ stop : 3 " asldfksaf " in let s541 = String . sub_with_index_range ~ first : 1 ~ last : 3 " a541 " in let s154 = String . sub_with_index_range ~ first : 1 " a154 " in let s654 = String . sub_with_index_range ~ last : 2 ...
let same_base = test " String . Sub . same_base " @@ fun ( ) -> let abcd = " abcd " in let a = String . sub_with_index_range ~ first : 0 ~ last : 0 abcd in let ab = String . sub_with_index_range ~ first : 0 ~ last : 1 abcd in let abce = String . sub_with_index_range ~ first : 0 ~ last : 1 " abce " in eq_bool ( String ....
let equal_bytes = test " String . Sub . equal_bytes " @@ fun ( ) -> let a = String . sub_with_index_range ~ first : 0 ~ last : 0 " abcd " in let ab = String . sub_with_index_range ~ first : 0 ~ last : 1 " abcd " in let ab ' = String . sub_with_index_range ~ first : 2 ~ last : 3 " cdab " in let cd = String . sub_with_in...
let compare_bytes = test " String . Sub . compare_bytes " @@ fun ( ) -> let empty = String . Sub . v " " in let ab = String . sub_with_index_range ~ first : 0 ~ last : 1 " abcd " in let ab ' = String . sub_with_index_range ~ first : 2 ~ last : 3 " cdab " in let abc = String . Sub . v ~ start : 3 ~ stop : 5 " adabcdd " ...
let equal = test " String . Sub . equal " @@ fun ( ) -> app_invalid ~ pp : pp_bool ( String . Sub . ( equal ( v " b " ) ) ) ( String . Sub . v " a " ) ; let base = " abcd " in let a = String . Sub . v ~ start : 0 ~ stop : 1 base in let empty = String . Sub . v ~ start : 4 ~ stop : 4 base in let ab = String . sub_with_i...
let compare = test " String . Sub . compare " @@ fun ( ) -> app_invalid ~ pp : pp_bool ( String . Sub . ( equal ( v " b " ) ) ) ( String . Sub . v " a " ) ; let base = " abcd " in let a = String . Sub . v ~ start : 0 ~ stop : 1 base in let empty = String . Sub . v ~ start : 4 ~ stop : 4 base in let ab = String . sub_wi...
let with_range = test " String . Sub . with_range " @@ fun ( ) -> let invalid ? first ? len s = app_invalid ~ pp : String . Sub . pp ( String . Sub . with_range ? first ? len ) s in let empty_pos ? first ? len s pos = empty_pos ( String . Sub . with_range ? first ? len s ) pos in let base = " 00abc1234 " in let abc = S...
let with_index_range = test " String . Sub . with_index_range " @@ fun ( ) -> let empty_pos ? first ? last s pos = empty_pos ( String . Sub . with_index_range ? first ? last s ) pos in let base = " 00abc1234 " in let abc = String . sub ~ start : 2 ~ stop : 5 base in let a = String . sub ~ start : 2 ~ stop : 3 base in l...
let span = test " String . Sub . { span , take , drop } " @@ fun ( ) -> let eq_pair ( l0 , r0 ) ( l1 , r1 ) = String . Sub . ( equal l0 l1 && equal r0 r1 ) in let eq_pair = eq ~ eq : eq_pair ~ pp : pp_pair in let eq ( ? rev = false ) ? min ? max ? sat s ( sl , sr as spec ) = let ( l , r as pair ) = String . Sub . span ...
let trim = test " String . Sub . trim " @@ fun ( ) -> let drop_a c = c = ' a ' in let base = " 00aaaabcdaaaa00 " in let aaaabcdaaaa = String . sub ~ start : 2 ~ stop : 13 base in let aaaabcd = String . sub ~ start : 2 ~ stop : 9 base in let bcdaaaa = String . sub ~ start : 6 ~ stop : 13 base in let aaaa = String . sub ...