text
stringlengths
0
601k
module Factories = struct let ast_name_node ( ? loc = Fixtures . location ) name = { txt = name ; loc } let ast_type_node type_name = { ptyp_desc = Ptyp_constr ( ( ast_name_node ( Lident type_name ) ) , [ ] ) ; ptyp_loc = Fixtures . location ; ptyp_attributes = [ ] } let ast_constructor_node ~ name ~ pcd_args ~ pcd_res...
let test_constructor_is_bare = let open Parsetree in let test ~ constructor ~ expected ctxt = let actual = Ppx_enum_lib . Utils . constructor_is_bare constructor in assert_equal ~ ctxt ~ cmp [ :% eq : bool ] ~ printer [ :% show : bool ] expected actual in " constructor_is_bare " >::: [ " | C " >:: test ~ constructor : ...
let suite = " Factory " >::: [ test_constructor_is_bare ]
Quickcheck . test_distinct_values ~ sexp_of : Unstable . sexp_of_t quickcheck_generator ~ trials : 1_024 ~ distinct_values : 512 ~ compare ; [ % expect { } ] || ; ; Quickcheck . test ~ sexp_of : sexp_of_t quickcheck_generator ~ f : invariant ; [ % expect { } ] || ; ; let conversions = List . init 16 ~ f ( : fun int -> ...
let uchar = map [ int32 ] ( fun n -> let n = ( Int32 . to_int n land 0xFFFFFFF ) mod 0x10FFFF in try Uchar . of_int n with Invalid_argument _ -> bad_test ( ) )
let unicode = list1 uchar
let norm form str = let n = Uunf . create form in let rec add acc v = match Uunf . add n v with | ` Uchar u -> add ( u :: acc ) ` Await | ` Await | ` End -> acc in let rec go acc = function | [ ] -> List . rev ( add acc ` End ) | ( v :: vs ) -> go ( add acc ( ` Uchar v ) ) vs in go [ ] str
let unicode_to_string s = let b = Buffer . create 10 in List . iter ( Uutf . Buffer . add_utf_8 b ) s ; Buffer . contents b
let pp_unicode ppf s = Format . fprintf ppf " [ @< v 2 " ; > Format . fprintf ppf " [ " @\% s " ] \@@ " ( unicode_to_string s ) ; s |> List . iter ( fun u -> Format . fprintf ppf " [ @ U +% 04x % s ( % a ) ] @@ " ( Uchar . to_int u ) ( Uucp . Name . name u ) Uucp . Block . pp ( Uucp . Block . block u ) ) ; Format . fpr...
let unicode = with_printer pp_unicode unicode
let ( ) = add_test ~ name " : uunf " [ unicode ] @@ fun s -> let nfc = norm ` NFC s in let nfd = norm ` NFD s in let nfkc = norm ` NFKC s in let nfkd = norm ` NFKD s in let tests = [ nfc , [ norm ` NFC nfc ; norm ` NFC nfd ] ; nfd , [ norm ` NFD nfc ; norm ` NFD nfd ] ; nfkc , [ norm ` NFC nfkc ; norm ` NFC nfkd ; norm...
let log_src = Logs . Src . create " distributed " ~ doc " : logs events related to the distributed library "
module Log = ( val Logs_lwt . src_log log_src : Logs_lwt . LOG )
module Test_io = struct type ' a t = ' a Lwt . t type ' a stream = ' a Lwt_stream . t type input_channel = Uwt_io . input_channel type output_channel = Uwt_io . output_channel type server = Uwt_io . server type level = Debug | Info | Warning | Error exception Timeout = Uwt_compat . Lwt_unix . Timeout let established_co...
let lwt_reporter log_it = let buf_fmt ( ) = let b = Buffer . create 512 in Format . formatter_of_buffer b , fun ( ) -> let m = Buffer . contents b in Buffer . reset b ; m in let app , app_flush = buf_fmt ( ) in let reporter = Logs . format_reporter ~ app ~ dst : app ( ) in let report src level ~ over k msgf = let k ' (...
let log_it_quiet _ = Lwt . return ( )
let log_to_stdout = Uwt_io . write Uwt_io . stdout
let ( ) = let module Tests = Test_distributed . Make ( Test_io ) in let logger = log_it_quiet in Logs . Src . set_level log_src ( Some Logs . Debug ) ; Logs . set_reporter @@ lwt_reporter logger ; Tests . run_suite ( )
let print t = List . iter ( errors t ) ~ f : Caml . print_endline print ( all [ ( fun _ -> fail " a " ) ; ( fun _ -> pass ) ; ( fun _ -> fail " b " ) ; ( fun _ -> pass ) ; ( fun _ -> fail " c " ) ] ( ) ) ; [ % expect { | ( " " a ) ( " " b ) ( " " c ) } ] | ; ; print ( first_failure pass ( fail " foo " ) ) ; [ % expect ...
let two_errors = of_list [ fail " foo " ; fail " bar " ] print ( first_failure two_errors ( fail " snoo " ) ) ; [ % expect { | ( " " foo ) ( " " bar ) } ] | ; ; print ( first_failure ( fail " snoo " ) two_errors ) ; [ % expect { | ( " " snoo ) } ] | ; ; let v ( ) = if true then failwith " This unit validation raises " ...
type t = { x : bool } [ @@ deriving fields ] = let validate_x = Staged . unstage ( Validate . field_direct_folder Validate . pass_bool ) in let validate t = Fields . Direct . fold t ~ init [ ] : ~ x : validate_x |> Validate . of_list |> Validate . result in let t = { x = true } in require_no_allocation [ % here ] ( fun...
module Raw = struct type t = int [ @@ deriving bin_io , compare , hash , sexp , typerep ] let here = [ % here ] let validate _ = Validate . pass let validate_binio_deserialization = true let all = [ Int . min_value ; - 100 ; - 1 ; 0 ; 1 ; 100 ; Int . max_value ] end
module V = Make_bin_io_compare_hash_sexp ( Raw )
module type Output = sig type t [ @@ deriving sexp_of ] include Equal . S with type t := t end
let for_all ( type a ) raw_fn validated_fn ( module Output : Output with type t = a ) = List . iter Raw . all ~ f ( : fun raw -> let expected = raw_fn raw in let actual = validated_fn ( V . create_exn raw ) in require [ % here ] ( Output . equal expected actual ) ~ if_false_then_print_s : ( lazy [ % message " Validated...
let for_all2 ( type a ) raw_fn validated_fn ( module Output : Output with type t = a ) = List . iter Raw . all ~ f ( : fun raw1 -> List . iter Raw . all ~ f ( : fun raw2 -> let expected = raw_fn raw1 raw2 in let actual = validated_fn ( V . create_exn raw1 ) ( V . create_exn raw2 ) in require [ % here ] ( Output . equal...
module V2 : sig type t = V . t [ @@ deriving typerep ] type t = V . t include Add_typerep ( Raw ) ( V ) end ( module struct module Positive_int = struct type t = int [ @@ deriving bin_io , sexp ] let validate t = if t > 0 then Validate . pass else Validate . fail " must be positive " end let does_raise = Exn . does_rai...
let good = [ OBus_string . validate " azerty " ; OBus_string . validate " Jérémie " ; OBus_path . validate " " ; / OBus_path . validate " / a " ; OBus_path . validate " / a / b " ; OBus_name . validate_bus " : 1 . 1 " ; OBus_name . validate_bus " : a . 2 " ; OBus_name . validate_bus " foo . bar " ; OBus_name . validate...
let bad = [ OBus_string . validate " \ xe9 " ; OBus_path . validate " / dd // dd " ; OBus_path . validate " / dd " ; // OBus_path . validate " / dd " ; / OBus_path . validate " " ; OBus_name . validate_bus " : 1 . . 2 " ; OBus_name . validate_bus " a . . b " ; ]
let test ( ) = let % lwt ( ) = printl " Validation of all types of D - Bus strings " in let % lwt ( ) = Lwt_list . iter_s ( function | Some err -> printlf " valid string recognized as bad : % s " ( OBus_string . error_message err ) | None -> return ( ) ) good in let % lwt ( ) = Lwt_list . iter_s ( function | None -> pr...
let init_validator ( f : Validator . t -> Block_validator_process . t -> Store . chain_store -> ' a -> unit -> unit Lwt . t ) test_dir switch ( ) : unit Lwt . t = ( Shell_test_helpers . init_chain test_dir >>= fun store -> Shell_test_helpers . init_mock_p2p Distributed_db_version . Name . zero >>=? fun p2p -> let chain...
let wrap f _switch ( ) = Tztest . with_empty_mock_sink ( fun _ -> Lwt_utils_unix . with_tempdir " tezos_test_ " ( fun test_dir -> init_validator f test_dir _switch ( ) ) )
let validator_events validator block_validator chain _switch ( ) = Validator . activate ~ start_prevalidator : false validator ~ validator_process : block_validator chain >>= function | Error trace -> Format . printf " Error :\ n % a \ n " pp_print_trace trace ; Format . print_flush ( ) ; Lwt . return_unit | Ok _ -> le...
let tests = [ Alcotest_lwt . test_case " validator_events " ` Quick ( wrap validator_events ) ]
let ( ) = Backtrace . elide := true
let show t = print_s [ % sexp ( t : t ) ]
let test_predicate f t = print_s [ % sexp ( f t : bool ) ] let test string = show ( string |> of_utf8_bytes ) in test " " ; [ % expect { | " " } ] ; | test " a " ; [ % expect { | a } ] ; | test " ( ) " ; [ % expect { | ( ) } ] ; | test " ( a b c ) " ; [ % expect { | ( a b c ) } ] ; | return ( ) ; ; let t = " " ┌ |> of_...
module Make_subtype = struct module Non_nil = Make_subtype ( struct let name = " non - nil " let here = [ % here ] let is_in_subtype = is_not_nil end ) open Non_nil let % expect_test " [ of_value_exn ] success " = let t = of_value_exn ( 13 |> of_int_exn ) in print_s [ % sexp ( t : t ) ] ; [ % expect { | 13 } ] ; | retu...
let print_args = lambda [ % here ] ( Returns Value . Type . value ) ( let % map_open . Defun ( ) = return ( ) and args = rest " args " value in print_s [ % message ( args : t list ) ] ; list args ) |> Function . to_value ; ; for i = 0 to 5 do funcallN_i print_args ( List . init i ~ f : of_int_exn ) done ; [ % expect { ...
let v0 = 0 |> of_int_exn
let v1 = 1 |> of_int_exn
let v2 = 2 |> of_int_exn
let v3 = 3 |> of_int_exn
let v4 = 4 |> of_int_exn let show result = print_s [ % message ( result : t ) ] in show ( funcall0 print_args ) ; [ % expect { | ( args ( ) ) ( result nil ) } ] ; | show ( funcall1 print_args v0 ) ; [ % expect { | ( args ( 0 ) ) ( result ( 0 ) ) } ] ; | show ( funcall2 print_args v0 v1 ) ; [ % expect { | ( args ( 0 1 )...
let print_num_args = lambda [ % here ] ( Returns Value . Type . value ) ( let % map_open . Defun ( ) = return ( ) and args = rest " args " value in print_s [ % message " " ~ num_args ( : List . length args : int ) ] ; list args ) |> Function . to_value ; ;
let length = Funcall . Wrap . ( " length " <: value @-> return value ) let array = Array . create nil ~ len : 3_500_000 in let list = funcallN_array print_num_args array in [ % expect { | ( num_args 3_500_000 ) } ] ; | let length = length list in print_s [ % sexp ( length : t ) ] ; [ % expect { | 3500000 } ] ; | funcal...
module Type = struct open Type let % expect_test " [ sexp_of_t ] " = print_s [ % sexp ( int : _ t ) ] ; [ % expect { | int } ] ; | print_s [ % sexp ( list int : _ t ) ] ; [ % expect { | ( list int ) } ] ; | return ( ) ; ; let % expect_test " round trip " = let test a t = let v1 = a |> Value . Type . to_value t in let a...
let schema = " CREATE TABLE test_values ( " ^ " row_id INTEGER NOT NULL , " ^ " string_col TEXT NULL , " ^ " int_col INT NULL , " ^ " int64_col INT NULL , " ^ " float_col FLOAT NULL , " ^ " bool_col INT NULL " ^ ) " ; " in let insert_sql = " INSERT INTO test_values " ^ ( " row_id , string_col , int_col , int64_col , fl...
let strip_whitespace = Str . ( global_replace ( regexp " [ \ n ] " ) + " " )
let equal_ignoring_whitespace l r = strip_whitespace l = strip_whitespace r
module Common_tests ( S : Cstubs . FOREIGN with type ' a result = ' a and type ' a return = ' a ) = struct module M = Functions . Stubs ( S ) open M let test_atomic_printing _ = let open Signed in let open Unsigned in let _CHAR_MIN = retrieve_CHAR_MIN ( ) in let _CHAR_MAX = retrieve_CHAR_MAX ( ) in assert_equal ( strin...
let test_pointer_printing _ = let arr = CArray . make int 10 in let p = CArray . start arr in assert_equal ( string_of ( ptr ( reference_type p ) ) p ) ( string_of ( ptr void ) ( to_voidp p ) )
let test_struct_printing _ = let s = structure " s " in let ( ) -: ty label = field s label ty in let a = array 3 int -: " arr " in let d = double -: " dbl " in let c = char -: " chr " in let ( ) = seal s in let t = structure " t " in let ( ) -: ty label = field t label ty in let ts = s -: " ts " in let ti = int -: " t...
let test_union_printing _ = let s = structure " s " in let ( ) -: ty label = field s label ty in let i = uint16_t -: " i " in let j = uint16_t -: " j " in let ( ) = seal s in let u = union " u " in let ( ) -: ty label = field u label ty in let us = s -: " us " in let ua = array 4 uint8_t -: " ua " in let ( ) = seal u i...
let test_array_printing _ = let arr = CArray . of_list int [ - 1 ; 0 ; 1 ] in let arrarr = CArray . of_list ( array 3 int ) [ arr ; arr ] in assert_bool " array printing " ( equal_ignoring_whitespace " { { - 1 , 0 , 1 } , { - 1 , 0 , 1 } } " ( string_of ( array 2 ( array 3 int ) ) arrarr ) )
let test_ocaml_string_printing _ = let s = " abc [ " " @%^&*\ in begin assert_equal ( string_of ocaml_string ( ocaml_string_start s ) ) ( Printf . sprintf " % S " s ) ; assert_bool " ocaml_string printing with offsets " ( equal_ignoring_whitespace ( string_of ocaml_string ( ( ocaml_string_start s ) +@ 3 ) ) ( Printf . ...
let suite = " Value printing tests " >::: [ " printing atomic values ( foreign ) " >:: Foreign_tests . test_atomic_printing ; " printing atomic values ( stubs ) " >:: Stub_tests . test_atomic_printing ; " printing pointers " >:: test_pointer_printing ; " printing structs " >:: test_struct_printing ; " printing unions "...
let _ = run_test_tt_main suite
show_raise ( fun ( ) -> default_value_exn ( int_var " z " ) ) ; [ % expect { | ( raised ( void - variable ( z ) ) ) } ] ; | return ( ) ; ; let t = int_var " z " in Current_buffer . set_value t 13 ; print_s [ % sexp ( default_value_exn t : int ) ] ; [ % expect { | 13 } ] ; | return ( ) ; ; let t = int_var " z " in set_d...
module Common_tests ( S : Cstubs . FOREIGN with type ' a result = ' a and type ' a return = ' a ) = struct module M = Functions . Stubs ( S ) open Signed open Unsigned open M let test_snprintf _ = let bufsz = 128 in let write snprintf apply = let buf = allocate_n char bufsz in ignore ( apply ( snprintf buf bufsz ) ) ; ...
let suite = " Variadic tests " >::: [ " snprintf " >:: Stub_tests . test_snprintf ; ]
let _ = run_test_tt_main suite
type colors = Red | Green | Blue [ @@ deriving qcheck ] qcheck
let pp_colors fmt x = let open Format in match x with | Red -> fprintf fmt " Red " | Green -> fprintf fmt " Green " | Blue -> fprintf fmt " Blue "
let eq_colors = Alcotest . of_pp pp_colors
let gen = Gen . oneofl [ Red ; Green ; Blue ] Blue
let test_variants ( ) = test_compare ~ msg " : Gen . oneofl <=> deriving variants " ~ eq : eq_colors gen gen_colors
type poly_colors = [ ` Red | ` Green | ` Blue ] Blue [ @@ deriving qcheck ] qcheck
let pp_poly_colors fmt x = let open Format in match x with | ` Red -> fprintf fmt " ` Red " | ` Green -> fprintf fmt " ` Green " | ` Blue -> fprintf fmt " ` Blue "
let eq_poly_colors = Alcotest . of_pp pp_poly_colors
let gen_poly : poly_colors Gen . t = Gen . oneofl [ ` Red ; ` Green ; ` Blue ] Blue
let test_poly_variants ( ) = test_compare ~ msg " : Gen . oneofl <=> deriving variants " ~ eq : eq_poly_colors gen_poly gen_poly_colors
type letters = | A [ @ weight 0 ] 0 | B
let test_weight = Test . make ~ name " : gen_letters always produces B " ( make gen_letters ) gen_letters ( function | A -> false | B -> true ) true |> QCheck_alcotest . to_alcotest
type poly_letters = [ | ` A [ @ weight 0 ] 0 | ` B ]
let test_weight_poly = Test . make ~ name " : gen_poly_letters always produces B " ( make gen_poly_letters ) gen_poly_letters ( function | ` A -> false | ` B -> true ) true |> QCheck_alcotest . to_alcotest
let ( ) = Alcotest . run " Test_Variant " [ ( " Variants " , Alcotest [ . test_case " test_variants " ` Quick test_variants ; test_case " test_poly_variants " ` Quick test_poly_variants ; test_weight ; test_weight_poly ] ) ]
module Nested_inside_variant = struct type t = A of [ ` A of int ] [ @@ 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_v...
module Nested_inside_record = struct type t = { a : [ ` A of int ] } [ @@ 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...
module V1 = struct type t = unit let compare ( ) ( ) = 0 let hash ( ) = 0 let to_string ( ) = " unit " end
module V2 = struct type t = X | Y let compare = Pervasives . compare let hash = function | X -> 0 | Y -> 1 let to_string = function | X -> " X " | Y -> " Y " end
module C = struct type t = Int32 . t let compare = Pervasives . compare let equal a b = compare a b = 0 let hash a = Int32 . to_int a let to_string = Int32 . to_string end
module R = struct include C let zero = 0l let one = 1l let sum = Int32 . add let prod = Int32 . mul end
let one_variable ( ) = let module F1 = Vcr . Make ( V1 ) ( C ) ( R ) in let domain = [ 0l ; 1l ; 2l ; 3l ; 4l ; 5l ] in let mk_t f = List . fold_left ( fun t x -> F1 . ( sum t ( atom ( ( ) , x ) ( f x ) 0l ) ) ) ( F1 . const 0l ) domain in let agree t f = List . for_all ( fun x -> match F1 . ( peek ( restrict [ ( ( ) ,...
let two_variable ( ) = let module F2 = Vcr . Make ( V2 ) ( C ) ( R ) in let domain = [ 0l ; 1l ; 2l ; 3l ; 4l ; 5l ] in let mk_t f = List . fold_left ( fun t x -> let cx = F2 . atom ( V2 . X , x ) 1l 0l in List . fold_left ( fun t y -> let cy = F2 . atom ( V2 . Y , y ) ( f x y ) 0l in F2 . ( sum t ( prod cx cy ) ) ) t ...
let disjoint ( ) = let module F1 = Vcr . Make ( V1 ) ( C ) ( R ) in let f = F1 . atom ( ( ) , 0l ) 1l 0l in let g = F1 . atom ( ( ) , 1l ) 1l 0l in " diagrams with disjoint domains are zero " @? F1 . ( equal ( prod f g ) ( const 0l ) )
let rec was_successful = function | [ ] -> true | RSuccess _ :: t | RSkip _ :: t -> was_successful t | RFailure _ :: _ | RError _ :: _ | RTodo _ :: _ -> false
let _ = let suites = [ " disjoint " >:: disjoint ; " one - variable " >:: one_variable ; " two - variable " >:: two_variable ] in let verbose = ref false in let set_verbose _ = verbose := true in Arg . parse [ ( " - verbose " , Arg . Unit set_verbose , " Run the test in verbose mode . " ) ; ] ( fun x -> raise ( Arg . B...
let test_vec_float32 ( ) = let f n l = of_list_dyn float32 n l in let ( ) = x y = Slap . S . Vec . ssqr_diff x y < 1e - 6 in " v_emp " @? ( f zero [ ] = [ % vec . float32 [ ] ] ) ; " v_sgl " @? ( f one [ 42 . ] = [ % vec . float32 [ 42 . ] ] ) ; " v_ord " @? ( f five [ 1 . ; 2 . ; 3 . ; 4 . ; 5 . ] = [ % vec . float32 ...
let test_vec_float64 ( ) = let f n l = of_list_dyn float64 n l in let ( ) = x y = Slap . D . Vec . ssqr_diff x y < 1e - 6 in " v_emp " @? ( f zero [ ] = [ % vec . float64 [ ] ] ) ; " v_sgl " @? ( f one [ 42 . ] = [ % vec . float64 [ 42 . ] ] ) ; " v_ord " @? ( f five [ 1 . ; 2 . ; 3 . ; 4 . ; 5 . ] = [ % vec . float64 ...
let test_vec_complex32 ( ) = let f n l = of_list_dyn complex32 n l in let ( ) = x y = Complex . norm ( Slap . C . Vec . ssqr_diff x y ) < 1e - 6 in let c x = Complex . ( { re = x ; im = x } ) in " v_emp " @? ( f zero [ ] = [ % vec . complex32 [ ] ] ) ; " v_sgl " @? ( f one [ c 42 . ] = [ % vec . complex32 [ c 42 . ] ] ...
let test_vec_complex64 ( ) = let f n l = of_list_dyn complex64 n l in let ( ) = x y = Complex . norm ( Slap . Z . Vec . ssqr_diff x y ) < 1e - 6 in let c x = Complex . ( { re = x ; im = x } ) in " v_emp " @? ( f zero [ ] = [ % vec . complex64 [ ] ] ) ; " v_sgl " @? ( f one [ c 42 . ] = [ % vec . complex64 [ c 42 . ] ] ...
let test_vec_char ( ) = let f n l = of_list_dyn char n l in " v_emp " @? ( f zero [ ] = [ % vec . char [ ] ] ) ; " v_sgl " @? ( f one [ ' x ' ] = [ % vec . char [ ' x ' ] ] ) ; " v_ord " @? ( f five [ ' a ' ; ' b ' ; ' c ' ; ' d ' ; ' e ' ] = [ % vec . char [ ' a ' ; ' b ' ; ' c ' ; ' d ' ; ' e ' ] ] )
let test_vec_sint8 ( ) = let f n l = of_list_dyn int8_signed n l in " v_emp " @? ( f zero [ ] = [ % vec . sint8 [ ] ] ) ; " v_sgl " @? ( f one [ 42 ] = [ % vec . sint8 [ 42 ] ] ) ; " v_ord " @? ( f five [ 1 ; 2 ; 3 ; 4 ; 5 ] = [ % vec . sint8 [ 1 ; 2 ; 3 ; 4 ; 5 ] ] )
let test_vec_uint8 ( ) = let f n l = of_list_dyn int8_unsigned n l in " v_emp " @? ( f zero [ ] = [ % vec . uint8 [ ] ] ) ; " v_sgl " @? ( f one [ 42 ] = [ % vec . uint8 [ 42 ] ] ) ; " v_ord " @? ( f five [ 1 ; 2 ; 3 ; 4 ; 5 ] = [ % vec . uint8 [ 1 ; 2 ; 3 ; 4 ; 5 ] ] )
let test_vec_sint16 ( ) = let f n l = of_list_dyn int16_signed n l in " v_emp " @? ( f zero [ ] = [ % vec . sint16 [ ] ] ) ; " v_sgl " @? ( f one [ 42 ] = [ % vec . sint16 [ 42 ] ] ) ; " v_ord " @? ( f five [ 1 ; 2 ; 3 ; 4 ; 5 ] = [ % vec . sint16 [ 1 ; 2 ; 3 ; 4 ; 5 ] ] )
let test_vec_uint16 ( ) = let f n l = of_list_dyn int16_unsigned n l in " v_emp " @? ( f zero [ ] = [ % vec . uint16 [ ] ] ) ; " v_sgl " @? ( f one [ 42 ] = [ % vec . uint16 [ 42 ] ] ) ; " v_ord " @? ( f five [ 1 ; 2 ; 3 ; 4 ; 5 ] = [ % vec . uint16 [ 1 ; 2 ; 3 ; 4 ; 5 ] ] )
let test_vec_int ( ) = let f n l = of_list_dyn int n l in " v_emp " @? ( f zero [ ] = [ % vec . int [ ] ] ) ; " v_sgl " @? ( f one [ 42 ] = [ % vec . int [ 42 ] ] ) ; " v_ord " @? ( f five [ 1 ; 2 ; 3 ; 4 ; 5 ] = [ % vec . int [ 1 ; 2 ; 3 ; 4 ; 5 ] ] )
let test_vec_int32 ( ) = let d = Int32 . of_int in let f n l = of_list_dyn int32 n l in " v_emp " @? ( f zero [ ] = [ % vec . int32 [ ] ] ) ; " v_sgl " @? ( f one [ d 42 ] = [ % vec . int32 [ d 42 ] ] ) ; " v_ord " @? ( f five [ d 1 ; d 2 ; d 3 ; d 4 ; d 5 ] = [ % vec . int32 [ d 1 ; d 2 ; d 3 ; d 4 ; d 5 ] ] )
let test_vec_int64 ( ) = let d = Int64 . of_int in let f n l = of_list_dyn int64 n l in " v_emp " @? ( f zero [ ] = [ % vec . int64 [ ] ] ) ; " v_sgl " @? ( f one [ d 42 ] = [ % vec . int64 [ d 42 ] ] ) ; " v_ord " @? ( f five [ d 1 ; d 2 ; d 3 ; d 4 ; d 5 ] = [ % vec . int64 [ d 1 ; d 2 ; d 3 ; d 4 ; d 5 ] ] )